Web Dev Questions That Don't Need Their Own Thread v4
5,001 replies, posted
what if I don't know the name of the object?
[QUOTE=Pat.Lithium;46260199]what if I don't know the name of the object?[/QUOTE]
How are you getting that json string? A "json object" is just a string. You have to parse the string into an array using what I sent you. If you expect multiple names and want all the IDs, you could work with a foreach() loop to get all the ['id']s of your $value (just an example).
If you i.e. get the json string using file_get_contents(), you'd do something like this:
[code]
$json_array = json_decode(file_get_contents( /* Your source */ ), true);
[/code]
[QUOTE=Cyberuben;46260236]How are you getting that json string? A "json object" is just a string. You have to parse the string into an array using what I sent you. If you expect multiple names and want all the IDs, you could work with a foreach() loop to get all the ['id']s of your $value (just an example).
If you i.e. get the json string using file_get_contents(), you'd do something like this:
[code]
$json_array = json_decode(file_get_contents( /* Your source */ ), true);
[/code][/QUOTE]
The JSON string comes from the LoL server, I send a URL request to get it.
[editline]17th October 2014[/editline]
I don't know the player name before the JSON string comes back, I send a summonerId.
[QUOTE=Pat.Lithium;46260242]The JSON string comes from the LoL server, I send a URL request to get it.
[editline]17th October 2014[/editline]
I don't know the player name before the JSON string comes back, I send a summonerId.[/QUOTE]
[CODE]$id = $json_array[0]['id'];[/CODE]
[QUOTE=TrinityX;46260535][CODE]$id = $json_array[0]['id'];[/CODE][/QUOTE]
That won't work, since json_decode sets the name of the subarray (and doesn't allocate it to a nameless value, like PDO's results do)
[URL="http://viper-7.com/wpkfNu"]I just tried[/URL], to be sure.
that's a shitty API result btw, you shouldn't put a VALUE as the KEY. The nick should be the value of (what should exist) the key "user_name".
[editline]17th October 2014[/editline]
^Not directed at Lithium.
[QUOTE=Coment;46260640]That won't work, since json_decode sets the name of the subarray (and doesn't allocate it to a nameless value, like PDO's results do)
[URL="http://viper-7.com/wpkfNu"]I just tried[/URL], to be sure.
that's a shitty API result btw, you shouldn't put a VALUE as the KEY. The nick should be the value of (what should exist) the key "user_name".
[editline]17th October 2014[/editline]
^Not directed at Lithium.[/QUOTE]
He can be really hacky though...
[code]
$json_array = json_decode($string, true);
$hacky_shit = array_keys($json_array);
$id = $json_array[$hacky_shit[0]]['id'];
[/code]
[QUOTE=Coment;46260640]That won't work, since json_decode sets the name of the subarray (and doesn't allocate it to a nameless value, like PDO's results do)
[URL="http://viper-7.com/wpkfNu"]I just tried[/URL], to be sure.
that's a shitty API result btw, you shouldn't put a VALUE as the KEY. The nick should be the value of (what should exist) the key "user_name".
[editline]17th October 2014[/editline]
^Not directed at Lithium.[/QUOTE]
Riiight. (following code is PHP 5.4+)
[CODE]$id = array_values($json_r)[0]['id'];[/CODE]
what language would you guys suggest I learn for pretty much a clone of [url=http://minecraftservers.org/]this[/url]?
[QUOTE=PortalGod;46271133]what language would you guys suggest I learn for pretty much a clone of [url=http://minecraftservers.org/]this[/url]?[/QUOTE]
Anything will do the job, it's up to your preference.
I tried learning node.js with learnyounode, and it sucked
can anyone recommend me a good tutorial?
[url]http://nodejs.org/community/#index_md_learning[/url]
try these. and if you're gonna use nodejs, maybe you can take a look at this [url]http://mean.io/[/url]
Has anyone tried or currently using [URL="https://ghost.org/"]Ghost[/URL]?
I would like if someone could give some good thoughts about it, most of it I read on the interwebs is coming from people who are used to a fully packed CMS. I would prefer something lightweight to throw on my domain, and Ghost kind of seems like it but then again quite not. I am not a huge node.js expert so I am unsure if using Ghost is reliable.
From what I've heard the express dev left and as seeing Ghost uses express I am currently just waiting for it to collapse because the tools it uses does. :v:
Also would only install node.js just for that, so not sure if the lightweight really counts here. I tried looking at PHP solutions since that's standard to have, but really most of those solutions are not very good or bloated.
express "dev" left? it's maintained by strongloop. it won't go away in a near future, most nodejs web applications uses express
Guys, got couple of questions:
1)
Scenario:
I have huge folder of images (characters, eyes, hats, shoes etc..) about 120 files.
Say if each user logs into my website, say there is 100 users currently online, it needs to load each users character.
What would be better approach (server load wise)
1) Load each of accessories as layers on top of another so it creates a whole character.
(7 pieces for character so 100 * 7 = 700 images to load. (small sized).
2) Once user creates his character, PHP would combine all layers into one, and save whole character as single .png file, so it only loads 100 images?
Which will be easier on server?
2) Has anyone ever here conbined php-fpm and Node.js + express together? I have both installed, both running but my structure of website is as follows:
index.php (loads fine, PHP rendered, no node or express though)
/:3000 (sockets, express and jade works fine, no problem, but doesn't render PHP, just prints it as standard text. There is no file like index or anything, just port (not sure how that works).
Do I need to point PHP-FPM to port 3000 somehow?
Note: node server with socket.io, jade, express is launched via server.js
3) If question 2 is impossible to do:
Any simple way to parse data from index.php to /:3000 node server? (User details ,registration etc.. ) by simple way - I mean no additional libs or anything.
Thanks.
[QUOTE=Cuel;46285929]express "dev" left? it's maintained by strongloop. it won't go away in a near future, most nodejs web applications uses express[/QUOTE]
Yea sorry I kind of put that in a bad way, what I really meant was people was leaving from nodejs from what I heard not anyone in particular, I think Kaukassus here from Facepunch mentioned one of the express developers tweeted about switching to go-lang or something and that's what I was thinking of.
don't worry, nodejs is more popular than ever
How would I activate server-status on the latest version of Apache on Ubuntu? Everywhere I go I see "/etc/httpd" here, "httpd" there, but there's not a single folder called like that anywhere on /etc/.
Should I put
[code]
<IfModule mod_status.c>
<Location /server-status>
SetHandler server-status
Order deny,allow
Allow from all
</Location>
</IfModule>
[/code]
on apache2.conf for it to work?
Okay fun question here. I've done very little CSS and HTML, a lot more JS, Java, C#. How hard would it be to replicate presenting an article similarly to this?
[url]http://www.nytimes.com/newsgraphics/2013/10/27/south-china-sea/[/url]
Is this extremely complicated or just artistic? Could replicating something like that be done in a week?
I'm currently gonna read through the pages HTML and try and to decide for myself.
[QUOTE=MadPro119;46289844]Okay fun question here. I've done very little CSS and HTML, a lot more JS, Java, C#. How hard would it be to replicate presenting an article similarly to this?
[url]http://www.nytimes.com/newsgraphics/2013/10/27/south-china-sea/[/url]
Is this extremely complicated or just artistic? Could replicating something like that be done in a week?
I'm currently gonna read through the pages HTML and try and to decide for myself.[/QUOTE]
I think that's called parallax scrolling, there are lots of tutorials on how to make it work like that.
The one you showed is pretty simple compared to what is out there.
Some websites that use parallax scrolling just look mad and unbelievable.
[QUOTE=KinderBueno;46289991]I think that's called parallax scrolling, there are lots of tutorials on how to make it work like that.
The one you showed is pretty simple compared to what is out there.
Some websites that use parallax scrolling just look mad and unbelievable.[/QUOTE]
Yes they holy fucking do. [url]http://discover.store.sony.com/be-moved/[/url]
So I'm taking a look at [url=http://www.nytimes.com/newsgraphics/2013/10/27/south-china-sea//]this ones source[/url] but its got thousands of lines of javascript behind it. Wrapping my head around 600 lines of HTML and CS didn't seem bad but all this js.
[editline]20th October 2014[/editline]
oh wait i found that was the demo for a tutorial silly me
[url]https://ihatetomatoes.net/how-to-create-a-parallax-scrolling-website/[/url]
[QUOTE=MadPro119;46290027]Yes they holy fucking do. [url]http://discover.store.sony.com/be-moved/[/url]
So I'm taking a look at [url=http://discover.store.sony.com/be-moved/]this ones source[/url] but its got thousands of lines of javascript behind it. Wrapping my head around 600 lines of HTML and CS didn't seem bad but all this js.
[editline]20th October 2014[/editline]
oh wait i found that was the demo for a tutorial silly me
[url]https://ihatetomatoes.net/how-to-create-a-parallax-scrolling-website/[/url][/QUOTE]
I never bothered looking into it.
Tbh I think that unless you are some kind of day-to-day web designer doing some ads/promotions for someones product that needs simple yet interactive website - there isn't much use of that besides that.
Or I could be just blind, idk.
[QUOTE=KinderBueno;46290165]I never bothered looking into it.
Tbh I think that unless you are some kind of day-to-day web designer doing some ads/promotions for someones product that needs simple yet interactive website - there isn't much use of that besides that.
Or I could be just blind, idk.[/QUOTE]
I think its pretty <3
Pedantic side note: There's not actually any parallax on that page (the first page that is) other than parallax created from the movement in the videos. Everything else is either stationery or moving the same speed so it's not parallax.
[QUOTE=KinderBueno;46289991]I think that's called parallax scrolling[/QUOTE]
[url=http://en.wikipedia.org/wiki/Parallax_scrolling]Unless we're looking at different things, I don't think it is.[/url]
Goddamnit kmart, stop being a samurai. Or, wait, I mean ninja.
As I said: I was never really into these long scrolling websites, so I always thought that any website that does animation while scrolling means parallax.
Sorry for misleading :rolleyes:
[QUOTE=MadPro119;46289844]
Is this extremely complicated or just artistic? Could replicating something like that be done in a week?
[/QUOTE]
It could be done in a day or less if you know how to do it, you can look up parallax scrolling on codepen for some examples with code.
[editline]21st October 2014[/editline]
Sorry, didn't notice we hit another page. Late :suicide:
[QUOTE=Moofy;46291482]It could be done in a day or less if you know how to do it, you can look up parallax scrolling on codepen for some examples with code.[/QUOTE]
I'm working on parallax now but its more than that with the fades and whatnot. I'll probably just settle for using parallax though.
[QUOTE=MadPro119;46291566]I'm working on parallax now but its more than that with the fades and whatnot. I'll probably just settle for using parallax though.[/QUOTE]
There's probably some good javascript libraries to achieve some cool effects fast and efficiently, just search it up on GitHub
I have a friend that wants to get into UI/Frontend development, she doesnt come from a computing background and is starting from the grounds up.
What would be the best resource to point her towards for HTML/CSS/JS?
I'd definitely say codecademy for the HTML, CSS and JS. Maybe something like treehouse for the fundamentals of UI design?
Sorry, you need to Log In to post a reply to this thread.