• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
Might be a bit off-topic, but I'm wondering what are some good strategics when it comes to recruiting people for a forum/community? It's a bit of a niche forum, but I'm 100% sure there's a target group for it, but I don't know how to get it going.
This might be a silly question but when using normalize CSS there's a gap at my header, I realise this is my H1 having some margin, but it seems tedious having to set the margin to 0 on every element that has a gap I do not wish. Is there some reasoning to this, and would i really have to make something like: [code] h1, h2, h3, h4, h5, h6 { margin: 0; padding: 0; } [/code] - Every time I want to use normalize? It seems tedious, especially because I have a feeling this isn't the only element that's going to screw me up along the way.
Headers are designed like p tags where they have spacing around them so it is easily differentiated from normal text, but yeah if you want to remove the spacing around them then that's the best way to do it
[QUOTE=Moofy;44110426]This might be a silly question but when using normalize CSS there's a gap at my header, I realise this is my H1 having some margin, but it seems tedious having to set the margin to 0 on every element that has a gap I do not wish. Is there some reasoning to this, and would i really have to make something like: [code] h1, h2, h3, h4, h5, h6 { margin: 0; padding: 0; } [/code] - Every time I want to use normalize? It seems tedious, especially because I have a feeling this isn't the only element that's going to screw me up along the way.[/QUOTE] It's actually nice to remove the default spacing around the elements you work with since it seems to be different in different browsers (and operating systems.)
I'm working on a new version of an [url=http://maps.marlam.in/]old hobby project of mine[/url] of which I still get monthly PMs on Facepunch because of [url=http://facepunch.com/showthread.php?t=1184658&p=35995644&viewfull=1#post35995644]this post[/url]. Very early WIP of the new version can be found [url=http://marlamin.com/minimaps/]here[/url]. I managed to fully automate the game data extraction/map compiling/google maps tiling (yay! saves me hours of manual work) but the frontend is still awful as I'm absolutely terrible at UX. I don't really want to use bootstrap and this is NOT a good way to navigate through the submenus especially seeing the amount of maps grow each expansion. Any ideas on how to display a large amount of options per version without it being terrible like it is now? I've tried a lot of things but keep coming back to the submenus.
I'm currently working on a gallery plugin for a wordpress theme (PHP), and I've discovered a really strange error that I've only previous encountered with javascript. So, I've got a loop that's going through each post, taking any gallery images and displaying them. The problem is, there is a slight gap between new post loops. There is no difference in CSS, and there is nothing separating them. The CSS itself displays like this: [QUOTE]<div class="useful-gallery-images"></div> <div class="useful-gallery-images"></div> <div class="useful-gallery-images"></div> <div class="useful-gallery-images"></div>[/QUOTE] The third one down is at the start of the new post. This is what it looks like live: [img]http://i.imgur.com/9TUtCc2.png[/img] The inside of the loop itself looks like this: [QUOTE]$r = array_random_assoc($post_img, 10); foreach($r as $key => $value){ if($key !== 0) { $post_images = @$post_img[$key]['file']; $image=$post_images; if ($image) { echo '<div class="useful-gallery-images">'; echo '<a href="'. get_permalink($post->ID) .'"><img height="auto" src="'. $image .'" /></a>'; echo '</div>'; } } }[/QUOTE] And here it is live: [url]http://ukweddingandpartydirectory.com/gallery-test/[/url] Any help would be greatly appreciated.
[QUOTE=voltlight;44124513]-random div spacing-[/QUOTE] We had a discussion on this earlier in this thread... Have a look: [url]http://facepunch.com/showthread.php?t=1250244&p=44029022&viewfull=1#post44029022[/url] (I reccomend the HTML comment solution)
[QUOTE=voltlight;44124513]I'm currently working on a gallery plugin for a wordpress theme (PHP), and I've discovered a really strange error that I've only previous encountered with javascript. So, I've got a loop that's going through each post, taking any gallery images and displaying them.[/QUOTE] [code] <div class="useful-gallery-images"><a href="http://ukweddingandpartydirectory.com/city/walsall/listing/test3/"><img src="http://ukweddingandpartydirectory.com/wp-content/uploads/2014/02/red2.jpg" height="auto"></a></div><div class="useful-gallery-images"><a href="http://ukweddingandpartydirectory.com/city/walsall/listing/test3/"><img src="http://ukweddingandpartydirectory.com/wp-content/uploads/2014/02/red3.jpg" height="auto"></a></div> <!-- All of this line space is being treated as a new line --> <div class="useful-gallery-images"><a href="http://ukweddingandpartydirectory.com/city/walsall/listing/test/"><img src="http://ukweddingandpartydirectory.com/wp-content/uploads/2014/02/12.jpg" height="auto"></a></div><div class="useful-gallery- <!-- [/code] The gap is HTML treating the newline as a space, I believe
Fixed, thanks for that. I left a gap after a ?> and that created a new line. I thought it was some sort of conspiracy about browsers knowing more than they should, ooooh~
PHP... Trying to do this... [code]<? include 'squares.php?square_youtube'; ?>[/code] Am I allowed to use query strings with includes this way? I can't seem to get that to execute. I have this document that I'm including setup as a form of class, when you view the document by going to it, it will load the header, footer, etc and displays all of the "squares" (interactive widgets) available for use. When using a query string it loads just the function needed to display a single widget depending on the string given, the header footer etc will be included elsewhere in the document. This way for each square I may specify a bunch of includes [code]<? include 'squares.php?square_this'; include 'squares.php?square_that'; include 'squares.php?square_anotherThing'; ?>[/code] I was wondering if I could just have the document be able to tell if it is being included or viewed in the browser. Then if its being included, it will just make the functions available in the document and not show header/footer/othershit but if its being viewed it will show all of the squares available and the header/footer
Include is just opening that file on the system and dumping it into the file it was called from. You're using it like an HTTP request.
[QUOTE=Banana Lord.;44128625]Include is just opening that file on the system and dumping it into the file it was called from. You're using it like an HTTP request.[/QUOTE] That actually makes things much clearer, do you have a recommendation on what I should be doing?
[QUOTE=lkymky;44128679]That actually makes things much clearer, do you have a recommendation on what I should be doing?[/QUOTE] Well if you're using GET parameters you can just include the file and check the parameters there.
[QUOTE=lkymky;44128679]That actually makes things much clearer, do you have a recommendation on what I should be doing?[/QUOTE] If you want to cheat: [code]$_GET['square_youtube'] = true; include('squares.php');[/code] If you want to do it cool: [code]$square = 'youtube'; include('squares.php');[/code] Then check if square is defined and render accordingly.
[QUOTE=supersnail11;44128759]If you want to cheat: [code]$_GET['square_youtube'] = true; include('squares.php');[/code] If you want to do it cool: [code]$square = 'youtube'; include('squares.php');[/code] Then check if square is defined and render accordingly.[/QUOTE] I [I]think[/I] I understand how to use variables that way for your cool method. However I am still basically looking for a PHP that can be used as a class for the server, and a page for a user I've been doing it this way... [code]<?php if(!file_exists("import.php")) { die("Error! <br />import.php wasn't imported; File cannot be found.<br /> Almost There cannot be loaded"); } else { include 'import.php'; } $qs = $_SERVER['QUERY_STRING']; switch ($qs) { case "404": notfound(); break; case "no": no(); break; case "redirect": redirect(); break; case "login": login(); break; case "logout": logout(); break; case "admin": logout(); break; default: sayHello(); break; }; $A = '<!DOCTYPE html><html><head>'; $B = '<title>Almost There - ' . $title . '</title></head><body>'; $C = '</body></html>'; function sayHello() { global $A, $B, $C; $title="Fractal"; echo $A; head(); echo $B; preBody(); echo "<p>This document has different arguements that can be passed to it.<br />You can try the following Query Strings <ul> <li>notfound</li> <li>no</li> <li>redirect</li> <li>login</li> <li>logout</li> <li>admin</li> </ul>"; postBody(); echo $C; };[/code] [I]import.php contains template functions (preBody, postBody, and head)[/I] Is there a better way of doing this?
Oh jesus please don't ever name your variables things like $A, $B, $C. Code is supposed to be readable to humans, name them things that actually explain what they are. I [I]really[/I] think you need to learn OOP properly and do some research on application structure. This already looks super spaghetti-code to me. You shouldn't be setting/switching variables before an include to get the include to do what you want it to. You should have a Square class that you include once, and then create instances of for each square you want to render. [quote]However I am still basically looking for a PHP that can be used as a class for the server, and a page for a user[/quote] You should be creating the class first, and then if you want a page that essentially just displays that class you should create a php file that loads an instance of the class and renders it however you want it rendered. You absolutely should [B]not[/B] be thinking of a PHP file as a "class" that you will use by setting some variables and then including it. I'm really really really getting the vibe that you're coupling your presentational code to things that it doesn't need to be couple to in weird ways.
[QUOTE=KmartSqrl;44129053]Oh jesus please don't ever name your variables things like $A, $B, $C. Code is supposed to be readable to humans, name them things that actually explain what they are. I [I]really[/I] think you need to learn OOP properly and do some research on application structure. This already looks super spaghetti-code to me. You shouldn't be setting/switching variables before an include to get the include to do what you want it to. You should have a Square class that you include once, and then create instances of for each square you want to render. You should be creating the class first, and then if you want a page that essentially just displays that class you should create a php file that loads an instance of the class and renders it however you want it rendered. You absolutely should [B]not[/B] be thinking of a PHP file as a "class" that you will use by setting some variables and then including it. I'm really really really getting the vibe that you're coupling your presentational code to things that it doesn't need to be couple to in weird ways.[/QUOTE] I probably am going to laugh at myself when I do learn [I]better[/I] right now I'm coding the way I feel works best for me. I also didn't plan on keeping the variables $A, $B, $C I wasn't feeling comfortable using that method to build a page anyways, I just had that there temporarily as well. I'm trying to find out exactly what is the best way to do the complex things I'm trying to achieve, however I don't know all of the capabilities of PHP yet, I'm just using what I know to get things done. I need lots more education... :eng101:
[QUOTE=lkymky;44129305]I probably am going to laugh at myself when I do learn [I]better[/I] right now I'm coding the way I feel works best for me.[/QUOTE] It's good if you look back and laugh at the way you did something, it means you're learning :) [QUOTE=lkymky;44129305]I need lots more education... [/QUOTE] Start here: [url]http://code.tutsplus.com/tutorials/solid-part-1-the-single-responsibility-principle--net-36074[/url] There's 4 parts to this and they all give a really good overview of some important OOP concepts. You might get a bit of a "this doesn't matter to me right now" feeling, but these are things you will understand the value of quickly once you start following them. If you can, I would focus your learning on more conceptual things like this because it will apply to any other OOP languages you work with. It's knowledge that's more important to grind in to your head than things like "how to print a file with php". Minor implementation details like that are easily googled, so definitely focus on the stuff that's more generally applicable.
does anyone have experience in working with AWS? their API seems to be pretty unreliable, I've written a quick and dirty scraper in python to get a bunch of images from a bunch of ASINS and it seems to get all of the images once out of ten-fifteen tries, usually it gets a few and the rest come out blank [editline]4th March 2014[/editline] here's the code: [code]import requests from time import sleep import xml.etree.ElementTree as et from scraper import asinImageScrape def getImageFile(ASIN,outputfile): outputfile.write(ASIN + '\n') AS_TAG = 'happytoysandg-21' AWS_ACCESS_KEY_ID = '' AWS_SECRET_ACCESS_KEY = '' APIDATE = '{http://webservices.amazon.com/AWSECommerceService/2011-08-01}' #ASIN = raw_input('Enter product ASIN: ') url = asinImageScrape(AS_TAG,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,ASIN)[0] print url + '\n' r = requests.get(url) #print r.text xml = et.fromstring(r.text)[1] try: print xml[1][3][0].text except IndexError: print #for image in xml.iter(): # if image.tag == APIDATE + 'LargeImage': # print image[0].text # if image[0].text == "": # print '\n' # outputfile.write(image[0].text + '\n') # #with open(ASIN + '.jpg','wb') as imgfile: # # imgfile.write(requests.get(image[0].text).content) return #ASIN = 'B001JT1ZGO' outputfile = open('ASINIMAGEOUT.txt','a') f = open('ASINS.txt','r') for line in f: sanitized = line.replace('\n','') print sanitized getImageFile(sanitized,outputfile) f.close() outputfile.close() [/code] the URLs it gets work because if i go to them manually they seem fine, i've commented out the search-through-the-xml-for-the-right-tag thing to make sure that wasn't breaking it
I think I'm onto something (After alot of reading) fucking classes are awesome, I can't believe I was going to try to write all of these via functions... [t]http://i.imgur.com/8WgRaXf.png[/t] [code]square_default->buildSquare();[/code] Doesn't seem to be working for me quite yet though, i've been trying very hard.
A good thing to learn would be how to separate views from your program logic so you don't have HTML scattered around in your PHP and vice-versa. The following is a very basic View class that uses output buffering to load the variables into a view file. [code] class View{ public static function generate($template, $data){ extract($data); //Unpack the data array into variables named after the array keys ob_start(); // Start gathering output require $template; // Include the template file and generate the HTML $output = ob_get_contents(); // Get the content of the output buffer ob_end_clean(); return $output; } } [/code] Usage: [code] $data['banana'] = 5; $data['facts'] = array('a banana plant is actually a herb', 'bananas are radioactive', 'over 100 billion bananas are eaten each year', ); echo View::generate('template.php', $data); [/code] In template.php: [code] <h2>My page about banana facts</h2> <div class="full"> <?php foreach($facts as $fact): ?> <p><?php echo $fact ?></p> <?php endforeach; ?> <p>I have <?php echo $answer ?> bananas</p> </div> [/code] This means you can divide your code into distinct files based on what they do. Another thing you can do with this is instead of immediately echoing the view's output you can put that data into another view. Doing this you can have a single template for the code that is on every page and individual files for each distinct page's inner area. There's a lot you can do when you start using things like this and I hope it will help you understand the benefit of a framework.
[QUOTE=CBastard;44134672]A good thing to learn would be how to separate views from your program logic so you don't have HTML scattered around in your PHP and vice-versa. This means you can divide your code into distinct files based on what they do. Another thing you can do with this is instead of immediately echoing the view's output you can put that data into another view. Doing this you can have a single template for the code that is on every page and individual files for each distinct page's inner area. There's a lot you can do when you start using things like this and I hope it will help you understand the benefit of a framework.[/QUOTE] I feel as though I'm inching towards this. I would love to begin getting rid of all of this HTML...
Is there any way of doing .toggleClass('class',300) without having to use the whole jquery UI library? (It's for a userscript on a site without jquery UI)
[img]http://pictures.gabrielecirulli.com/2048-20140305-130212.png[/img] This game is so addicting. It needs animations though.
[QUOTE=gokiyono;44134745]Is there any way of doing .toggleClass('class',300) without having to use the whole jquery UI library? (It's for a userscript on a site without jquery UI)[/QUOTE] Look up "removing class javascript" There are a few examples
Question regarding working outside home / work whatever. At home I just use Samba to the server and I can edit it just like it was my own drive, because it's mounted. BUT, when I'm not home, what would be the best suggestion? I haven't used git before, but I assume pulling when starting to work and pushing when done would be viable? (Since it's dev anyways) [sp]Also, if it's different software, keep in mind I'm on a mac when out[/sp]
I have a quite weird problem. I've been receiving DDoS notices from my VPS provider and I have no idea who or what is causing that. The vps has crashed a few times last few days until I enabled CloudFlare's "I'm under attack" mode. I've been browsing through a lot of suggestions on how to determine whether I am being attacked or not and I noticed something really weird in the Apache error log. Apparently something in [URL="http://knowledge.tw.yahoo.com"]http://tw.[/URL][URL="http://knowledge.tw.yahoo.com/"]knowledge.[/URL]yahoo.com has been trying to pull nonexistent resources/ sending people to my site. So the question is, how can I solve this?
[QUOTE=lkymky;44134531]I think I'm onto something (After alot of reading) fucking classes are awesome, I can't believe I was going to try to write all of these via functions... [t]http://i.imgur.com/8WgRaXf.png[/t] [code]square_default->buildSquare();[/code] Doesn't seem to be working for me quite yet though, i've been trying very hard.[/QUOTE] It's really cool seeing this progress! Keep at it :) Definitely start working towards what CBastard is suggesting ASAP as well. The less logic you have in your templates, the better. I would [B][I]really[/I][/B] strive to having nothing but simple conditionals, simple loops, and echo statements in any php file that has HTML in it. Having that really strong separation between your templates and your business logic is incredibly helpful.
[QUOTE=lkymky;44134711]I feel as though I'm inching towards this. I would love to begin getting rid of all of this HTML...[/QUOTE] Try out a templating engine (like [URL="http://twig.sensiolabs.org/"]Twig[/URL]). You handle the logic in your script, then send the data to the templating engine and get back the full HTML.
Does Brackets have a proper FTP/SFTP plugin yet? There's FTP sync but honestly it's so bad you have to click an icon and enter your password every time you want o upload. Saving doesn't work, you have to go through this procedure of steps for it to work. [editline]edited:[/editline] Also I love sublime with all my heart but one thing that annoys me is that with the SFTP plugin you can't browse with the sidebar file tree, is there no setting for this of any kind? It would make everything faster, I have looked into some settings but simply can't find it.
Sorry, you need to Log In to post a reply to this thread.