« first day (1386 days earlier)      last day (3544 days later) » 
00:00 - 17:0017:00 - 00:00

12:00 AM
Question to all problem solvers.
If I have a folder with images inside listing from 1–10. And the link to them is asd.com/thefile/1.jpg etc.. Whats the best way to STOP people from going to 2.jpg or 3 ....
 
12:35 AM
use a random predefined substring of md5 hash of strings "1".."10" as your file names in that folder
example: 1.jpg => md5('1') = c4ca4238a0b923820dcc509a6f75849b => substr(md5('1'), 6, 6).jpg => 38a0b9.jpg
and so on
 
Nice idea!
thanks.
 
what if 2 different users upload 2 different pictures with the same name
?....
the name is never enough. mix it with the date cause it changes every second, this way the hashed code will be 100% unique
 
12:55 AM
Its ok
im only gonna be uploading
@zeeks You available to help me with something or still busy?
 
still busy, i will message you. no worries
 
Ok np
@zeeks Should I just force the downloads?
no one will ever see the url's
 
if your website gets a lot of visits
and you win lots of money
people will be interested
in finding holes
in your websites
but you have a long way to reach there :p
 
ikr
@zeeks Im stuck on this so im gonna leave it :D
 
just leave it :p return to it some other day :p
 
1:06 AM
yup I need to fix it soon though or users cant download
so yup another time
 
 
4 hours later…
4:41 AM
Link only answers should be deleted or not?
 
4:53 AM
I think they should
@DaveRandom again about REST: how would you organize entity state change? Like, an entity was enabled, we need to disable it. DELETE /entities/<id>/enabled?
 
user895378
5:04 AM
Well the cool thing about HTTP is that its methods are extensible. You could create your own methods ... say ENABLE and DISABLE and then make requests using those methods to /entities/<id>
 
user895378
But if you wanted to use the standard methods it makes sense to use PUT or PATCH (probably PATCH /entities/<id> HTTP/1.1) ...
 
user895378
And let the entity body reflect the change (whether you use JSON or any other format)
 
@rdlowrey yep, I also thought about PUT /entities/<id> body: {enabled: false} but wasn't sure
 
user895378
Yeah that's perfectly fine.
 
good, thanks
 
5:13 AM
 
@YogeshSuthar that's silly
 
This is the response i got from moderator
 
provide a link to delete vote
 
13
A: Convert boolean to int in Java

JH.From apache, which has awesome libraries! http://commons.apache.org/proper/commons-lang//javadocs/api-2.4/org/apache/commons/lang/BooleanUtils.html#toInteger(boolean)

 
flagged as well
 
5:15 AM
flagged
 
5:30 AM
 
6:19 AM
Btw, could anyone recommend any good book about sql for a junior developer that is available for kindle (or any other electronic format)?
Martin Gruber is not available electronically :-(
 
@zerkms I learned from this book amazon.in/SQL-The-Complete-Reference-Edition/dp/0071592555 but it's costly. :(
 
oh shit
 
Its free preview available on goolge books books.google.co.in/…
 
Amazing M. Gruber paperback is available for $24
this one
 
ohhh, its in half of what i recommend.
 
6:59 AM
Morning
 
8:26 AM
bonjoursly
 
@hakre Ohayou
 
@SecondRikudo :)
 
8:43 AM
@zerkms this one is better: cs.sfu.ca/~cameron/REX.html
 
@zerkms what's this Sikh Wall you speak of? ;-)
morning all
 
@Jack not sure I can understand it
 
"Learn how Buddha jumps over the Sikh wall in 28 days."
nevermind me, just woke up ;-)
 
anyone have a link for me why things like simplynoise.com are supposedly helpful for concentrating?
 
I didn''t think of look at the documentation. I thought w3school was reliable enought. Obviously not. Sorry — ahmad albayati 1 min ago
 
Do we have a "What is the difference between PHP runtime and JavaScript runtime" question?
 
lol
@SecondRikudo what would be the answer to such a question? :)
 
@Jack my exact first thought
 
welp, my lack of knowledge on how to insert tags into chat is showing, tonight, lol
 
noob :)
bcoz of u i lost my reputation — user3867153 1 min ago
hahaha
 
^
 
they've had ... 7 rep ...
 
9:29 AM
@Jack A brief explanation of the request-response cycle, and then where JS and PHP fit in that.
 
@Gordon helpful for concentrating? - it's not in the list what that site itself suggests: ► Sleep Aid ► Block Distractions ► Mask Tinnitus ► Pacify Children ► Soothe Migraines ► Increase Focus
 
@hakre block distractions + increase focus = helpful concentrating
 
@SecondRikudo Personally I think such a question is a bad fit; as a canonical, maybe ...
 
@Jack Yeah, that's what I mean
 
@Gordon not necessarily. however I know from the Masking Tinnitus effect and it might also have similar working like blocking distractions.
 
9:31 AM
I'm concentrating listening classics: open.spotify.com/user/1245615136/playlist/…
 
this explanation is quite okay to grasp the concept: sleepjunkies.com/features/sleep-soundly-with-white-noise
> The idea of adding more noise in your bedroom to help you sleep may sound counter intuitive, but it works because white noise blends the external sounds (barking dog,traffic etc) into the overall background noise, so your brain pays less attention.
so you add constant noise to mask other noise in it and your brain will ignore it then
now only to find out more about the different colors
 
@YogeshSuthar it's fair though
 
@Gordon oh yes, white noise is what my friend used when she just had a baby heh
not to the point where she would ignore the kid obviously ;-)
 
@Jack did it work?
 
9:37 AM
yeah, she said it was a rather odd thing.
you would just zone out haha
 
thanks for the close-votes; night
 
Morning
@Gordon when my daughter was a baby, I had the shocking experience that she stops crying under the influence of white noise even she has gas pain. But I was afraid to intervene the natural process so I did not subject her to white noise. After all she is not a guinea pig.
@Gordon My theory is: White noise is an input which has no correlation to any memory or neural network combination. So to evaluate it, all the resources related to input evaluation
 
9:51 AM
you were afraid she'd get hypnotised? heh
 
is dedicated, and this pacifies the rest of th brain.
@Jack yep, in fact yes.
@Gordon for grown ups, this "misuse" of resources isolates "you" (whatever thingy we called mind) from "environment" which means less distraction.
 
explaining white noise in that fashion makes it sound like a drug ;-)
 
@Jack Hahaha
 
how have you been btw? haven't seen you in a while.
you were writing a book were you not?
 
Fine, No I was building a medical robot.
I succeded. It makes allergy tests.
 
10:06 AM
ah so
did it make you rich and famous?
 
Not yet. Now I have a new job. I work as IT advisor to the Rector in a new university.
I moved to another city. Many things changed in my life, including a new car. I wish you all have better of things that I have now.
I will work on educational material of the university, which means I am learning moodle.
 
cool, student again eh?
 
I am a lifelong student @Jack
:D
 
as we all are, stay curious :)
 
0
Q: When does JavaScript run, and when does PHP run? Can I combine the two?

Second RikudoWhen does a client-side language like JavaScript runs, and when does a server-side language like PHP runs? Do the two correlate? I want to run a PHP function on click of a button on my site, or to run a JavaScript function from PHP, is it possible? Can I combine the two?

Comments and edits will be welcomed.
 
10:12 AM
The question should include "Where" clouse I think.
 
@Ihsan How's that? (See the title)
 
@SecondRikudo wow that IS an answer.... Beautiful. Congratulations....
 
@SecondRikudo imo Ajax is not the exception to "You cannot run PHP functions from JavaScript".
 
@Ihsan Thank you :) If you find something to improve, feel free to tell me about it, or even submit an edit :)
@Jack It's a beginner oriented Q&A, do you have a better way of saying it? (You know what I mean)
 
I'll see if I can rephrase that.
 
10:15 AM
@Jack XmlIBYCIWQUEBYCUWEBRYU FUNCTİON ... for beginners ? no no...
:D
 
No no :)
 
At least he didnot say MAGIC or JQUERY
@SecondRikudo That is a very fine answer and appropriate. When jumpers from google come in they will become satisfied consumers. Good job.
 
@SecondRikudo should i add an example code like <button name="test" onclick="<?php echo $_GET['test] + 1; ?>"> ? :)
not sure how others would formulate it
 
@Jack You mean to the question? Like "Would this snippet of bad code work?"
 
yeah
 
10:22 AM
Bye good people
 
okay, my kiddo is summoning me to the dinner table.
 
Hi Guys, Morning!
I have to run a piece of php code after the javascript. I mean after the page load and all javascript runs
 
check SecondRikudo's latest question/answer.
 
Can I have that link @YogeshSuthar
 
=P I can see the future.
1
Q: When and where does JavaScript run, how about PHP? Can I combine the two?

Second RikudoWhen does a client-side language like JavaScript run and when does a server-side language like PHP run? How can I mix both? I want to run a PHP function when a button on my site is clicked, or run a JavaScript function from PHP; is that possible?

 
Thanks @YogeshSuthar
 
@SecondRikudo change your name to "rep whore".
 
@YogeshSuthar "Badge whore"
The reasoning is mainly the JS badge.
 
yeah, now I noticed you earned lots of badges in short term.
 
Hello guys, I just managed to make chat app using php websockets. So what I do is opening connection on a port and all the users that connect to that port can chat. My question is if I want to have multiple chat rooms, I need to open port for each one? If yes what is the limit of ports that I can have open?
 
10:39 AM
@rdlowrey PAUL GEORGE NOOOOOOO!
 
@Ihsan thanks
 
 
1 hour later…
11:55 AM
Monring
 
Morning @PeeHaa
 
heya @Prasanth
 
hey i was just looking at your opcachegui issues
 
yes
 
i'm looking to get into bug fixing :)
 
11:59 AM
cool!
 
do you have any suggestions for where to start?
this project's surely interesting and i'll take a look but if there is something else please ping me..
 
Monring @PeeHee et al.
 
@Prasanth I often just try out software / libraries and if I find something annoying / broken I fix it. Or if I am really bored I just open up random popular github repo's and find vulnerabilities
Hey @salathe!
 
awesome! i'll see ya later.. hopefully with a pull request :)
 
Great! later
 
12:33 PM
Which answer do you think is better? Be honest. A or B?
 
@SecondRikudo I especially like stackoverflow.com/a/17403881/2153758
 
12:55 PM
@SecondRikudo why are the pictures so small in your answer?
 
1:07 PM
yay, it's a hurricane behind the window
some unlucky person will find fallen tree on his car (:
 
1:30 PM
Morning
@PeeHaa :)
 
1:49 PM
Hi All, Please look
0
Q: Unable to increment Static Class Variable PHP

Faisal NaseerI have created an Interface class SellableItems which is implemented by the two products tv and tennisBall. The both contain a static variable $count, which I need to perform post increment and decrement. However there is a StoreFactory class responsible for initializing objects with a static fa...

static variables can not be incremented ?
 
"asked 6 mins ago"
 
user895378
@Fabien oh man, so gruesome. Usually things like that don't bother me but I saw the replay once and it was more than enough.
 
@HarshalMahajan You need to start using an IDE, there are obvious bugs in your code.
 
this not my quest
but yes I want to know that , can we perform increment operation on static variables
 
1:52 PM
"there are obvious bugs in your code."
 
user895378
So, the apocalypse might be upon us. I gave PhpStorm another shot last night and I really liked it. Last week composer, this week an IDE. What is the world coming to?
 
You can't do anything if you can't write code that runs.
@rdlowrey Productivity gains. Productivity gains everywhere.
Although I understand people who don't use an IDE, whenever I have to revert to not using one, I spend so much time just having to remember stupid details, rather than just letting the IDE fill all the boring stuff in for me.
 
user895378
My PhpStorm experience was so pleasant that I programmed until 3 in the morning last night.
 
@rdlowrey And to make using Auryn better in PHPStorm - plugins.jetbrains.com/plugin/…
 
can be incremented , @Danack thx man ;)
 
1:56 PM
{
    "methodCalls": [
        {
            "class": "\\Auryn\\Provider",
            "method": "make",
            "position": 0
        }
    ],
    "functionCalls": [
    ]
}
 
user895378
Ah nifty!
 
user895378
There are so many things to play with and configure I've only scratched the surface.
 
user895378
Just little things like small diff indications by color showing what you've changed in an open file are awesome.
 
Yeah....there's quite a few things....though I don't agree with using all of them. For example, PHPstorm does have builtin support for PHPUnit......but I agree with something you said earlier, that you need to be able to run phpunit from the command line, at which point having a special way of running in in the ide just becomes duplication and doesn't actually add anything useful.
 
user895378
Yeah, phpunit and git I want to do in a console.
 
2:00 PM
@Danack actually, while I do source control in the console, unit testing through the IDE is really nice
 
user895378
I prefer to keep a console up in the adjacent monitor with a watch script running that runs the test suite any time a change is detected in the source directory.
 
@BenjaminGruenbaum Oh I still run it in the IDE - but by just calling the command line version, just not the 'special' run type.
 
Especially if you run the unit tests often. I don't commit to git more than once every half an hour.
 
grr… Not remembering if strpos has $needle or $haystack first :-(
 
user895378
@bwoebi haystack
 
2:02 PM
@rdlowrey Could you share that watch script somewhere please?
 
@rdlowrey yeah, php.net told me. But I never remember it...
 
user895378
It's just pywatch
 
@bwoebi It's a string function
@Fabien morning :)
 
@PeeHaa it's not consistent there.
it's just consistent for arrays I believe
 
user895378
And you can also use regular built-in watch on nix systems, but on Fedora you can't get colored output from your phpunit run (which highly annoys me).
 
2:04 PM
@bwoebi It is consistent AFAIK unless some callback gets throw into the mix IIRC
 
@rdlowrey Yeah - not having colours totally spoils the effect
 
@PeeHaa too many exceptions.
 
user895378
awesome
 
user895378
@bwoebi I only know that one by heart because I use strpos/stripos all the time because it's one of the fastest ways to parse things.
 
user895378
As a broad rule though, string functions are haystack first and array functions are needle first.
 
user895378
2:07 PM
That simple rule will get you the correct order most of the time
 
Last time I thought it was the inverse :-(
 
user895378
That's the problem with a binary rule ... it's really easy to get it switched in your head and then it's totally useless :)
 
Exact ;-)
 
Hey
What is the best way to execute a java application and get reponse from it in php? Exec() command?
 
2:31 PM
Hi is there something wrong with this: pastebin.com/ZQnAFUEx
I keep getting broken files.
I echo'ed the link, it works fine. But its the headers I think are bad.
 
instead of echo($weburl."/upload/".$hiddenpassage."/".$download->link);
have you tried, readfile($weburl."/upload/".$hiddenpassage."/".$download->link);?
 
I just realised I did that.
Updated the link again ^
@DaveChen I keep getting It may be damaged or use a file format that Preview doesn’t recognize.
 
@RahulKhosla wait, why is it on octet/stream?
 
I heard its better thn image/jpeg.
 
@RahulKhosla if you right-click on the damaged file, and view with notepad/text editor...
part of an image, or a PHP error response?
 
2:45 PM
Cant open .jpg's
 
@RahulKhosla try right clicking and opening it with a text editor, not with the default previewer... you can also try renaming it to *.txt and before opening
 
It gives me the page content I downloaded it from.
Weird.
 
what kind of page content?
 
The page I clicked download from.
 
so what is $download->name? also state all the other variables such as $weburl."/upload/".$hiddenpassage."/".$download->link
 
2:51 PM
All of it is fine.
It gets requested.
 
is $weburl another website or is it on the filesystem?
 
absolute meaning set?
its set in a var.
 
no I mean, is it a website like http://*** or is it a local path, like /var/www/..., this would help if you could provide the variables
 
website
http://
@DaveChen I think the problem is with the headers.
 
@PeeHaa Busy? :)
 
3:05 PM
@RahulKhosla since it's off site, it's possible that download->link is not what you are expecting, you should provide what these variables are
 
3:20 PM
I have a script that detects how many folders are in a directory and then creates a basic slider out of the images in each folder. Folders with images are created every 5 - 10 minutes, how can I limit the amount of sliders displayed to 8 at a time?
 
Try show people some code?
 
I'm sorry, I'm still newer, how do I correctly paste code in chat. @RahulKhosla
`<?php
$a = 0;
$b = 0;
$c = 0;

if ($handle = opendir('.')) {
$blacklist = array('.', '..', 'frames', 'sort.php', 'compress.php', 'test.txt', 'css', 'fonts', '.DS_Store', 'js');
while (false !== ($file = readdir($handle))) {
if (!in_array($file, $blacklist)) {
$atime = substr($file, 0, 2) . ':' . substr($file, 2);
$gtime = substr($atime, 0, 5) . ' ' . substr($atime, 5);
echo '<div style="width:230px;position:relative;display:inline-block;margin:20px;" class="panel panel-default">
<div class="panel-heading"><h3 style="text-align:center;" class="panel-title">'. $gtime .'</h3></div><div class=
 
Use pastebin or something.
 
@RahulKhosla OK Thank you, here it is: pastebin.com/9SnuKBHZ
 
Im not that pro in php btw, I was just helping you get help from others.
 
3:34 PM
@notchris Your question is relatively simple. Though the code is somewhat questionable. You should be able to figure it out by understanding your code rather than copy pasting it.
Question is do you want to learn or just be told the answer?
 
I like a bit of both.
 
Help!!!
:[
My source code is fucked up.
It says 0000 0000 0000 0000
In the whole file, instead of showing the php
I tried 2 text editors, but failed.
 
What?
 
In my .php file
I had coded a class.
 
Code?
Oh
 
3:47 PM
yea
php code
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
That code got replaced with this
... ;[
 
Your code is f*cked up? What a funny sad thing
 
neat, I want an editor like that as well!
 
I was using Notepad++ and Sublime Text
;[
It had so many lines.. I have to work again now...
fuck..
 
You got a loop?
In your code?
foreach or something?
 
Nope.
 
3:49 PM
Localhost?
 
I had a while loop to fetch data, but I never ran the code. Yes, localhost.
 
Try server or something? Maybe its something to do with your localhost.
 
user895378
$wishlist += "PhpStorm: Binary Edition";
 
@hakre Mobile friendly, and better load times
If you want to see more clearly, click the image.
 
3:53 PM
So, how's things ?
 
mobile friendly. OMG did you convert into an ipad lover? ^^
i'm experimenting with stream filters in PHP.
 
I'm at sushi bar and have only a phone
 
It had almost 200 lines.. lol
 
@tereško How's the sushi?
 
@HassanAlthaf even version control is not a backup, but you could then at least revert to an earlier version if. also it's easier to backup version control.
 
3:58 PM
Alrighty
 
What do you mean @hakre
l0
I was coding.. and then I saved it
and i locked my laptop
 
Quite awesome. They just now brought it.
 
well, ask code review to get ready to review my 600+ line project.
LMFAO
 
pastebin.com/7yNS0C0B OMG 10 HOURS!
And still broken file.
 
wtf do u want from ti
l0l
*it
 
4:01 PM
$weburl = "http://www.mysite.com";
$hiddenpassage = "dssfosoifsajfjsdfjasdoifiasdf";
$download->link; = 1.jpg
Im trying to force a download.
 
lol
Redirect to a zip file
and the browser will automatically start downloading it.
l0l
 
the files not zipped.
 
So, what's new?
 
zip it then
 
I can't
 
4:03 PM
sup @tereško
You want them to download an image Rahul?
 
Yes.
 
Ok, I'll help ya.
 
Without showing URL
Thanks.
 
Without showing URL?
hmm
 
4:04 PM
Yeh thats why I've used headers.
 
1
Q: How can I force an Image download in the browser?

SteffiI want to force user to download images. Not open in browser. It is possible to use HTML5 this attribute download but currently only Chrome supports it. I tried .htaccess solution but it doesn't work. <Files *.jpg> ForceType application/octet-stream Header set Content-Disposition attach...

:]
 
Which reminds me, there's some Comicon type thing going on in Riga
 
What?
 
Saw quite a lot people walking around in cosplay
 
@Fabien I want to learn, but I do have a deadline to finish this today. Maybe I can accomplish both, could you give me a hint to start me off please?
 
4:07 PM
Will have to visit the event tomorrow
 
@notchris what do you need a hint for?
 
I can't be using links.
As in js etc.
 
@Hassan I wrote a script that generates image sliders from folders containing images with a similar prefix. New folders are generated every 5 - 10 minutes. I want to allow only 8 to be displayed at a time, removing the oldest folder when the newest is generated. pastebin.com/9SnuKBHZ
 
I suck in jQuery.
/JavaScript
 
@Hassan It's not all JS, the part I need to figure out is how to remove the oldest folder as a new one is generated.
 
4:15 PM
@tereško Pretty cool. Nothing like that really happens here.
@notchris The hint is to read through your code and understand it. Decide if you want to read and get only 8 files or get all files then select a random 8.
 
we have the hell not?
 
@Hassan @Fabien Thank you, I will do my best to figure that out. I'm putting up a live sample to help explain what I'm trying to do a little better.
Ah, can't tag more than one user per comment?
 
@notchris yes. Please do not ping me on every single comment.
 
Do you actually live in some obscure English village, or something ?
 
Nope. Southampton. Just not heard of any comic con style things.
 
4:20 PM
OK, sorry about that
 
There's some big ones in London.
 
OK WHAT IS WRONG WITH THIS
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$download->name.'.jpg"');
readfile($weburl."/upload/".$hiddenpassage."/".$download->link);
I echoed the read file, and //'s headers, and the echo'd link was perfect and lead to the file.
So I really don't see what the problem is!?
filename="'.$download->name.'.jpg"'); is the new name of the file correct?
 
@Hassan I've put the live example here just for reference: ctsciencecenter.org/360/gallery/sort.php
 
In Latvia there is basically ' Riga ' and ' the boonies '
 
Yay for hangover sushi!!
 
4:27 PM
No hangover here =)
 
lol, wish I could say the same
 
Then again I managed to drink quite a lot wine in the wake ... maybe my hangover us yet to come
 
deferred hangover?
 
Maybe
 
Maybe not (:
 
4:44 PM
not sure why that was downvoted
I guess because reddit
 
4:54 PM
-1
Q: Headers to push jpg download not working?

Rahul KhoslaWhat I'm trying to do: Im trying to push a jpg file to download witout user seeing the URL. In this case the file is located at: http://www.example.com/upload/asdasdsadpokdaspdso/36.jpg. My current code: header('Content-type: application/octet-stream'); header('Content-Disposition: attachment;...

 
00:00 - 17:0017:00 - 00:00

« first day (1386 days earlier)      last day (3544 days later) »