« first day (699 days earlier)      last day (4249 days later) » 

hey everyone :)
are there anyone who experienced with Git ?
 
Yes, there are people who are experienced with git.
 
:)
I need a little help. I just commit and push a file (test.php) but i forgot to delete a line from this file.
I want to edit a file from a commit and push it to Gİthub server
 
So delete the line, commit, and push again
 
But repository is public and everyone can see that line, if they look at to old commits
I have to remove this line (it's containing some sensitive datas)
 
1:14 PM
Oh, in that case, delete your repository and start again
 
maybe -amend will help me?
git commit -amend
 
@Anthony INSERT IGNORE would skip the row completely and it would not be entered into the DB, neither would you be notified of that fact. I doubt it's what you want here.
 
@Eray You'll need to rebase, then amend
 
actually is better to let it to throw exception
 
145
Q: How to modify a specified commit?

arsaneI usually submit a list of commits for review, so I have a problem: If I have commit1, commit2, commit3, head. I know that I can modify head commit with git commit --amend, but how can I modify commit1 that is not head commit.

 
1:18 PM
If you've pushed a commit I don't think you can ammend it
unless you push -f to force it
but if anyone's pulled it already you might fk up their path
 
user1125394
yep
 
dbf
def.
 
user1125394
push -f works on github for example, but not on all other git provider
 
@cyril He did specify github, so all good
 
user1125394
k
 
user1125394
1:20 PM
Shouldn't all params in php construct be '= null' by default
 
@cyril why?
 
user1125394
because I keep putting it for last params
 
user1125394
well not sure it's a good idea, just asking
 
I don't think I understand what you mean now
 
user1125394
public function __construct(
IRequestHandler $handler,
$namespace = null,
$id = null,
$index = null
) {
 
1:22 PM
If you don't specify a default, it's a required parameter. If you specify one with = null it's optional and will be null if it isn't specified.
 
user1125394
ah so I don't need to put '= null' ;) thx
 
If you don't, you have to specify that parameter when you construct the object
 
user1125394
ok
 
@MikeB @cyril no one pull it , yet. I'm sure. I'll @Leigh's way : stackoverflow.com/questions/1186535/…
I'll try*
 
well ... i parameters in the constructor are not mandatory , then i kinda doubt that they should be even passed through the constructor
and passing more the 3 parameter to a method might be considered a code smell
 
user1125394
1:33 PM
it throws a warning
 
Does anyone have any thoughts on how to make stackoverflow.com/a/12425241 easier to understand for a complete PHP novice? Grateful for any edits or suggestions.
 
user1125394
@tereško ircmaxwell -> up-to 6 params
 
what ? what are you referring to and in what context
 
@eggyal What part do you not understand?
 
@Leigh I'm not sure how to make it more comprehensible for a novice... I fear the fourth paragraph in particular might cause some furrowed brows. And, given the apparent level of the OP, perhaps it moves forward too quickly after the fifth para?
 
"In your case, the sole parameter...", nothing advanced PHP there, flowery use of english, sure.
 
Hi all. Does anybody know Drupal 7?
 
dbf
I've heard of it ..
 
php.net is down :(
 
1:57 PM
use local mirror then
@Eugene ee.php.net
 
@tereško
 
0
Q: troubleshoot javascript

user1631838I've been trying to solve what's wrong with this javascript code but I can't find my way around it. This is the javascript function I got: function picValidate(arrInputs) { var _validFileExtensions = [ ".jpg", ".jpeg", ".bmp", ".gif", ".png" ]; if (typeof arrInputs == "undef...

Check out the 10 level nested if in the fourth code block
 
i actually tend to use UK mirror , because LV one is quite unstable
 
@tereško okey. I will keep that in mind. Thanks again.
 
OK i followed this steps : stackoverflow.com/questions/1186535/how-to-modify-a-specified-commit modify file and amend my commit. Now i want to git rebase --continue but i'm getting
error: could not apply 57d8d88... We don't need array shifting anymore. Performance improved.

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".
Could not apply 57d8d88... We don't need array shifting anymore. Performance improved.
error
@Leigh @MikeB @cyril check please
"We don't need array shifting anymore. Performance improved" -> commit message of my latest commit.
 
user1125394
2:13 PM
" We don't need array shifting anymore". ah seems they have changed since
 
yes ?
 
user1125394
So you probably can't with github also
 
I was working on same file for that two files
for that two commits*
 
git status for conflicts
fix the conflict, git add it, then git rebase --continue
 
# Not currently on any branch.
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: index.php
#
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both modified: GLS.class.php
#
 
2:16 PM
open GLS.class.php and look for conflicts
 
Successfully rebased and updated refs/heads/master.
Yes there was a conflict, i didn't notice it :) Thank you :) Now how i'll push that commit change ?

git push origin <commit-SHA>
?
 
Ahoy hoy
 
git push
You don't push commits, you push your branch
 
@cyril it's a heuristic. Sometimes 3 is a smell. Sometimes 6. It all depends on what you're doing
 
2:18 PM
@MikeB this will update my old (-updated-) commit, too. Right ?
 
You're pushing your branch to origin. If it's incompatible, because you re-arranged some nodes that it can't merge, then you'll have to force it
 
@ircmaxell , can you really think of a good example of method with 6 parameters in context of OOP ?
 
eray@eray-vaio-ubuntu:/var/www/GPRO-live-standings$ git push
To git@github.com:erayalakese/GPRO-live-standings.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:erayalakese/GPRO-live-standings.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.


But if i execute `git pull` , this will pull old version of file from GitHub
oh ok i will force it
git push -f
 
@tereško implementing an algorithm like PBKDF2 which has algo, password, salt, iterations, length... (ok, so 5, plus a possible "raw output")
 
2:21 PM
that's for function or method ?
 
Now my last commit (which has message "We don't need array shifting anymore ....") disappeared @MikeB
 
@tereško generally function. As a method I dropped it down to 4: github.com/ircmaxell/PHP-CryptLib/blob/master/lib/CryptLib/Key/…
 
I'm not so sure that you really need to add $iterations and $klen there
usually they would be same for each generation
 
Well, not quite. Iterations might be made a state, but lenght wouldn't...
 
@Eray You shouldn't have pushed your branch with -f without looking at it first
 
2:27 PM
I'm not sure how to respond to this. I definitely don't agree, but that doesn't mean he's wrong. Thoughts? https://github.com/ircmaxell/password_compat/pull/4
 
@MikeB, so i lost my last updates, right? (i don't lose too much datas, no problem, it's a big lesson for me :) )
WHy i lost my last commit ? Why it's come back when i execute git rebase --continue
 
@ircmaxell . . . not even sure what he's trying to say . . .
 
oh .. it's friday afternoon
the perfect time for doing -f push
 
he wants it in a class so that it can be run in 5.5 together with the existing code, to somehow enable testability... (How, I have no idea)
 
@ircmaxell You're offering direct compatibility with the 5.5 implementation, he is breaking that compatibility. If he wants to offer a class based solution as an alternative, or a fork of yours, that's cool too.
 
user1125394
2:35 PM
git destroy -f .
 
yeah, that's a good point
 
@cyril , it's for me? :)
 
it's supposed to be a drop in replacement. If someone uses your compat code, then upgrades to 5.5 and wants to go native, they'll actually have to change their code to work with the procedural version.
 
user1125394
yes ;)
 
@cyril, what is it's mean? SHould i execute it now ?
 
user1125394
2:37 PM
@Eray normally you never lose your local branches, I don't know what you did
 
Oh he does actually provide procedural ones too
and wraps his class - however, if someone builds dependency onto that class, it will go away if they go native, therefore it will no longer be compat code
 
I just followed stackoverflow.com/questions/1186535/how-to-modify-a-specified-commit this queston's answer, and @MikeB helped me. My questions is this : Why my latest commit come back when i execute git rebase --continue
 
Correct
 
Hmm, how do I set a PHP variable when a javascript function is called with 'onclick' from a link? Right now the javascript does its thing just fine, but I need to get some information over to PHP.
 
@Eray (sorry got pulled away) I'm not exactly sure why you lost a commit. Rebasing usually doesn't lose commits unless you abort and throw away your stash. Did you do any resettings with --hard?
 
2:41 PM
@MikeB no i don't any reset.
 
@Chris Google -> AJAX
 
Is AJAX my only option? Are there no alternatives which allow me to also set a PHP variable at the same time, possibly through the JS function itself or a PHP which is triggered simultaneously?
 
OK, i'm looking @cyril's advice :) (git destroy) . Let's say i have these commits : C1 C2 C3 C4 C5 . Is it possible to delete (destroy) all commits before C3 ? (Also destroy commits on remote server)
 
@Chris You know what server-side and client-side mean?
 
@Leigh Yes, I think so.
 
2:44 PM
destroy commits before a commit?
 
@Leigh Is the problem that JS is only clientside?
 
@ircmaxell yes i want to delete C1 and C2 for example
 
@Chris There is no way for your client to relay to the server that it wants to do something, without creating a connection between the two. Yes browser JS is client side, and PHP is server side, they are isolated from each other.
 
is C1 and C2 the first two commits in the repo? Or is there stuff before that?
 
@ircmaxell maybe :) it's just for example. Is it matter ?
 
2:47 PM
yes
 
so can you answer for that 2 case ?
 
first commit: not possible. later commit: just revert those commits
it won't destroy the commit
but it will remove the changes
 
Thank you so much for your all help ircmaxell, Leigh, cyril and MikeB . :)
 
@ircmaxell He accidentally committed sensitive data, he wants to destroy the commits so nobody can see them historically.
 
@Leigh Alright. So I need to send, for example, a GET request through AJAX and then retrieve it through PHP?
 
2:49 PM
@Chris Send the request to a PHP script that directly handles it.
 
did you push the change to master?
 
@Leigh @ircmaxell , actually i fixed that problem with rebase :) Now i just wondering, is it possible to destroy some stupid commits (like initial commit, fixed blablabla)
 
If you want to destroy a commit I would have done an interactive rebase and erased it
then push -f
# If you remove a line here THAT COMMIT WILL BE LOST.
 
@Leigh Ah alright. So in my case, I need a number increased by a certain amount (simplified, I actually need PHP for this), and that is used as a variable in JS. I perform the request from JS, which has the original number, through AJAX, 'onto' a separate PHP script and so retrieve my answer for continued use in JS. Is that correct?
@Leigh JS --(AJAX)--> PHP ----> JS
 
@MikeB , lets say i just add this *test.php* file on C1

line1content

and than add 2 more lines on C2

line1content
line2content
line3content

. Now i want to destroy C1. If i erase it with interactive rebase (like you said) , my *test.php* file will be stay like this :

line1content
line2content
line3content

right?

In shortly, i won't lose changes (because they are committed C2, too)
 
2:56 PM
I believe so, in theory, CYA, etc :p
Whenever I'm afraid of losing work I back up my whole project folder.. there's probably a better/more-efficient way but it gives me peace of mind
 
@MikeB , i'll try it with a repository :D

BTW, did you remember, i said "i lost my latest commit". now i notice something. Actually, i don't lost it. It's merged with rebased commit.
 
excellent!
I have nightmares about lost commits :(
 
So i didn't lose any changes, just it merged. I don't understand why, but i won't ask it :D
 
The very first thing I did when my company switched to git was push our develop branch straight into origin/master instead of origin/develop
early release! :\
 
hahah :) It think "pushing" should be more harder . It should ask a few times "Your pushing to origin/master . Are you sure???" . Because i made same mistake :))
"You're pushing to.." (typo)
 
viperpad.com/FcpLPc <-- thoughts please. Seems like a problem that should already be well solved but I can't find a satisfactory solution.
 
hiiiiiiiiii
 
morning
 
Gooden morning
 
@DaveRandom , i think you killed it
 
3:21 PM
@tereško lol, been a bit flaky all day.
	function quoted_string_split ($str, $delims = '"\'', $escape = '\\') {

		// Convert delimiters to an array of values suitable for use directly in a regex
		$delims = str_split(preg_replace('/\s+/', '', $delims), 1);
		$delims = array_map('preg_quote', $delims, array_fill(0, count($delims), '/'));

		// Convert escape char to regex sequence
		$escape = preg_quote($escape[0]);

		// This expression will split the string into it's constituent parts...
		$splitExpr = '/\s*(('.implode('|', $delims).')(?:(?!(?<!'.$escape.')\2).)*\2|\S+)/';
 
also , it's begs for refactoring
 
It may have taken one look and said "too much PCRE!" and died though
Logical analysis is all I'm after, I'm aware it's not pretty.
 
@ircmaxell Makes me think all future PHP features should be classes. Why not?
 
@DaveRandom de2.php.net/manual/en/function.str-getcsv.php with ' ' delimiter?
 
@ircmaxell Thinking of turning your password_hash functionality into classes?
I remember someone criticizing you for that and you seemed to defend functions pretty well
 
3:30 PM
@NikiC I suppose so. Would have to filter empties out afterwards and does not allow for multiple delimiters though. Realistically delimiters are unlikely to be more than '" but I would like to allow mixing of both kinds.
 
Hey guys. I have a form with 5 different input fields (per record). <Name>s are arrays since there is optional numbers of records. Can you help me with printing out (foreach) the individual records? I know how to handle it with one array (for example multiple checkboxes selected), but got stuck with so many different input arrays...
 
winner of the "how many bad ideas can you fit into a single line of code" competition. — SDC 3 mins ago
<input type="text" name="user[<?php echo $userId; ?>][name]" />
Then you can loop over $_REQUEST['user'] as $userId => $field
 
@MikeB thanks mike
 
@MikeB the opposite
 
@MikeB $_REQUEST == $sucky IMHO
 
3:37 PM
@DaveRandom You prefer specific $_POST/$_GET? I choose request b/c I didn't know the form type
Ideally there would be a $request object
 
0
Q: Model, View and Controller differentiated by colours

Umair AshrafI need to know what usable colours can be used to represent Model, View and Controller. So the goal is to assign different colours to Model, View and Controller so one can easily recognize it at a glimpse. Do you have any suggestions of colour for me?

 
@MikeB Aye, and fair enough, but use $_REQUEST in your code samples and people are liable to use it in real life. Demonstrate the wrong one and people will simply change it. If you don't know the request method being used to arrive at your script, bad design says I.
 
@tereško what category would one cv that under
off topic or not constructive?
 
.. I honestly have no idea
 
@Lusitanian NC, will definitely solicit debate, arguments, polling, or extended discussion. But only because there is no WTF close reason
 
3:41 PM
Right, but it won't. Who would get into a debate over..........whatever this is?
That's the category I chose though.
 
@DaveRandom This is how I would have implemented it: viperpad.com/ojD5zY
I just love the SKIP FAIL so much :P
 
@DaveRandom I don't know. Sometimes I feel like apps that use $_REQUEST over discriminating $_GET vs $_POST are more robust
 
To me, a $_GET request is something that's easy to pass from browser to browser. $_POST is something where you don't want to readily publish the request (think logging in), but they shouldn't be treated differently in the app
 
@NikiC in RegEx-Fu...coming to theatres worldwide
 
3:46 PM
is it full moon outside , or something ?
 
Not until 9/30
I edited my question. See it. I know the answers but need to confirm it. — Umair Ashraf 1 min ago
 
what the fak is going on
 
hello, can i set the php to show which file was where the error occured ?
 
@cscsaba , usually the error message mentions the file and the line where the error is.
unless you have disabled error reporting
 
3:54 PM
teresko, hm, we have a cms app which uses log4php and i doesnt show the file name
 
log4php
 
maybe i have to set the screen to display the general errors
teresko: thanks for your reply
 
@ircmaxell Final methods. Point is we should probably require a strong case to add procedural APIs to PHP.
 
wat.
 
Good afternoon
 
3:57 PM
My reply;
@mrclay_org http://nikic.github.com/2012/08/10/Are-PHP-developers-functophobic.html
 
display_errors = On
i meant this
log4php is not enough detailed
 
@NikiC What does the SKIP FAIL do and more to the point where is it documented? never seen that before.
 
@DaveRandom It's magic
 
it actually is
it means that *SKIP FAIL*ing to do what I want. (In other words, just do what I want it to)
 
@MikeB POST/Redirect/GET FTW! GET requests should relate only to fetching data from the server, if you need to send data to the server that will affect anything on the server beyond the lifespan of the request, it's POST. Idempotence, y'know. In my view they absolutely should be treated differently on the server because they related to different information stores/types. The way I see it it's quite clear cut.
Holy crap there's a whole new dimension of PCRE I've never even heard of. Yet more things to add to the list of things to do...
 
4:11 PM
^-- magic document that knows everything about PCRE
 
I know I've just been reading it, I've always steered away from it in the past where possible because plain-text docs like that are so hard to read, and everything I've ever needed to do generally I have been able to using the PHP PCRE docs. I really should persevere with it, and having seen that I probably now will.
 
Why this won't work?
<?php
$query 	= $conn->prepare("SELECT * FROM courses");
$query->execute();

foreach($query->fetchAll() as $rivi){

	print_r($rivi);

}
?>
 
@DaveRandom Fair enough :)
@Olli Why can't you?
 
@MikeB what you mean
I mean why it wont work
 
4:19 PM
@Olli, exactly what is the unexpected behavior, and is this the only file you're using? What is $conn?
 
@Sommer $conn = new PDO("mysql:host=localhost;dbname= - -
 
PHP Warning: Invalid argument supplied for foreach()
thats the error message
so what causes the error actually?
 
Yo
@Olli You're not giving foreach an array
 
why is fetchall now array
 
4:23 PM
@Olli Check the return value of $query->execute();, I suspect you'll find it's failing, PDO::errorInfo() will tell you why.
 
ah execute should have an array
 
Set PDO to throw exceptions on errors please.
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
@Olli Only if the statement you are preparing has placeholders in it, which the one you show does not.
 
@Madara I already have it
 
And +1 for PDO Exceptions on error.
 
4:25 PM
@DaveRandom ok.
 
And turn emulated prepares off as well: $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
 
My name is Levi Morrison and I am functophobic.
7
 
try `print_r($query->fetchAll());`
See what that gives you
@DaveRandom Though that's not the cause of the problem here
But yeah, should have that
 
@Madara it gives Array ( )
 
@MadaraUchiha var_dump() over print_r(), if the value he's passing to foreach is not iterable, chances are print_r() won't show anything useful as it'll be either NULL or FALSE
...or not
 
4:28 PM
An empty array should still be "iteratable", though nothing should show up. I don't see why you'd see that error
 
@Olli Well in that case the error is somewhere else in the code, an empty array would not trigger that error.
 
Let me do some testing of my own
 
i think fetchAll wont give an array ?
 
@Olli But it gives an array, an empty one but still an array
your print_r proves that
 
ok..
what causes the problem them
then*
 
4:30 PM
Could you show us the place where $conn is defined?
 
try {
	$conn = new PDO("mysql:host=localhost;dbname=XXX", "XXX", "XXX");
} catch (PDOException $e) {
	die("Err: " . $e->getMessage());
}
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
$conn->exec("SET NAMES utf8");
That's it.
 
...and the line number/file shown by Invalid argument supplied for foreach() 110% definitely matches the line number/file where the code you show is?
 
yes
999%
 
Could you paste the full code of the page?
 
4:34 PM
@Mikeb upvoted without reading at all :D
@Madara no I'm too lazy doing it... i'll try to debug it myself first
 
I finally found a source of all these people who think it's a good idea to store images in a db
@Olli Why?
 
@MikeB: it's not necessarially wrong to do it that way
it depends heavily on requirements
 
It's usually impractical to have an entirely different server to do as he says
 
@mikeb becoz you linked i t
 
@ircmaxell The question is asking about user-avatars. Those need to be served often and quickly
I agree there are times where it's appropriate to store binary data in a DB.. but not for this
 
4:38 PM
@Olli Maybe you aren't aware of this fact, but StackOverflow is community driven. It's perfectly valid to alert other members to questions and answers that are harmful.
3
 
@MikeB Actually, that case is one where I'd recommend storing them in a DB
and using a CDN to deliver them (so it can cache the items)...
 
@Levi yes but sometimes it's bad that its community driven
good questions will get easily deleted
 
CDN is the way to go but it can work just as well by storing files on a file-system accessible by apache
 
@Olli Deletion is not easy
It takes 5 people to close a question, and 3 to delete it
 
yep
 
4:42 PM
Usually a question is closed, and can be edited to reopened later if it improves
 
but still
 
@Olli Usually the reason is that the good question is actually bad.
 
Deletions are for questions which add zero value to the site, and will have very low chance of improving
 
8 mins ago, by Olli
@Mikeb upvoted without reading at all :D
Some people like to watch the world burn
 
@MikeB have you worked on a large scale system with dozens of servers before?
 
4:43 PM
PHP Fatal error: Call to a member function prepare() on a non-object
now it says that error
 
@ircmaxell I have
 
and how did you handle asset syncronization between servers?
 
I could take off my vote, but stupid SO: You last voted on this answer
9 mins ago
Your vote is now locked in
unless this answer is edited
(click on this box to dismiss)
 
We uploaded shared assets to the CDN upon creation
But we didn't keep a local copy
 
@Olli This means that the PDOStatement object isn't even created
What did you change?
 
4:45 PM
@Madara how I could check, is the connection details correct
I mean password, user etc.
what code i should use to check that
 
@ircmaxell I think I see what you're driving at, the all-in-one persistance store for ALL user-contributed content outlined by this guy stackoverflow.com/a/8932522/46675
It's certainly attractive
But for the simple stuff where people think they can get away with serving ALL images through something like image.php?id=1234 is what annoys me
 
No, that's fair, but he did a good breakdown in that asnwer
 
true enough, I'll update my comment to make that distinction
 
@Olli $pdo->errorInfo()
is an array with information on the last error
 
and where i should put it
 
4:50 PM
check that out
 
Array ( [0] => 00000 [1] => [2] => )
 
What did you change in your code?
 
nothing
 
or actually i fetchAll-->fetch
 
4:52 PM
try var_dump($query)
what does that give you?
 
now i detecgteed the problem. The table was empty.
quite strange that PHP didnt say it
 
:D
Works now?
 
yes
but I do have this kind of datrabase:
table courses [id subject course finished_period finished_year]
table subjects [id name]
and the courses' id comes from the subjects table
so how I could link these
 
do I need to create different query for fethcing the subject
<?php
$query 	= $conn->prepare("SELECT * FROM courses");
$query->execute();

foreach($query->fetchAll() as $row){

	print"".$row['id']." - ".$row['subject']." - ".$row['course']." - ".$row['finished_period']." - ".$row['finished_year']." -";

}
?>
I would like to get the subject name instead of the ID
currently it gives subject ID
 
You could use a simple JOIN to select them
 
@Madara how
 

« first day (699 days earlier)      last day (4249 days later) »