To fix this issue, open CuteFTP and go to:
Tools > Global Options > Connection > Smart Keep Alive
And disable “Smart Keep Alive”, apparently it’s not very smart…
If you are not using anything like GIT and you just use simple folders for development then I’m sure you have had situations where you needed to make some changes but broke the whole thing.
Or consider the situation where you had a huge idea and it required rewrite of a lot of things OR some dramatic changes to your source code files so you went half way through and (unless you had a copy of the whole code) you didn’t have a way to go back anymore.
Or when you wanted to backup your codebase, did you have to zip it and copy it to some external hard disk or server? That’s a pain.
Or when you wanted to develop something with your friend and you know what kind of a mess that is, right?
If these sound familiar then GIT is designed just to help you do these tasks faster, nicer and more reliable. It will also take care of a lot of things for you.
First let’s install git, on Windows (which is my platform for now) you will need to install this:
http://code.google.com/p/msysgit/
NOTE: you will have some options during installation, choose these options: 1 – GIT should use the regular Windows Command line 2 – GIT should add itself to Windows path 3 – GIT should NOT change the line endings. You will see these options during installation…
On MAC try:
http://help.github.com/mac-git-installation/
On Linux try: (note: you might already have it, got to Terminal and type “git” and hit “Enter”)
yum install git-core
After you installed GIT open your Terminal or Command Line for Windows and type these commands:
> git config --global user.name "YOUR NAME" > git config --global user.email "YOUR EMAIL"
For Windows:
> git config –global core.editor “notepad.exe”
It’s obvioud what these do so now let’s try GIT, make a folder somewhere and paste one of your projects in there let’s assume that the folder is at C:\git_test\ then do:
> cd C:\git_test
On Linux or Mac this would look like this:
> cd /git_test
Now let’s initialize our GIT repository:
> git init
After this command, GIT will create a .git folder inside git_test folder, the cool thing is that GIT won’t modify anything, GIT won’t keep the files in some other location, it just tracks the files inside your folder as you edit them normally, in other words, GIT won’t get in your way at all!
Then try:
> git status
This will show you all the files in this folder but it will also tell you that these files are not tracked by GIT yet so to let GIT track them try:
> git add .
You could add single files like:
> git add index.html
But the “.” will add everything so that’s what I always do.
Now we need to commit everything for the first time, so try:
> git commit -a -m "Initial commit"
So now go ahead and edit one of the files and change it a bit then go back to your command line and type:
> git status
As you can see GIT knows what file you edited, it doesn’t end there try:
> git diff
It even knows what you did exactly, so now you can commit the new changes:
> git commit -a -m "Test edit"
Note that you are entering a message with each commit, it’s best if you explain in a short sentence what you did…
You can see a history of your commits with:
> git log
You may notice that with each record there is a sha1 hash string, that is the hash of the content and it is useful for a bunch of things you can do with GIT.
Assume that the last edit you just did, broke something and you want to go back to the previous stable state, to do this you must know the sha1 hash of the commit that you want to revert to, for this example let’s revert to “Initial commit” state (our first commit), to do this type:
> git log
Then copy the sha1 hash that is associated to the “Initial commit” commit and type:
> git revert PASTE_THE_SHA1_HASH_HERE
Now go back and look for your changes, they are not there anymore!
Also you must be careful, GIT never asks questions like “are you sure you want to revert?” etc. it just does it so pay extra attention when doing things like this…
Now let me show you one last thing in this tutorial and that is the concept of branches, type:
> git branch
This will show you something like:
*master
The branch master was created automatically when you created this repo and the * means that this branch is active.
Let’s say that you have a crazy idea and that requires changing the code quite a bit but you don’t want to mess around with the code that is already stable and working, this is were branching comes into play and GIT does it better than any other system, it does it in a very simple and fast way.
Let’s create a branch and call it experiment:
> git branch experiment
This single line just created an entirely identical copy of the whole code – folders and files – in GIT’s database for you, that was fast right?
Now let’s switch to this new branch:
> git checkout experiment
If you try:
> git branch
You will see something like:
*experiment master
Confirming that you are now in the branch “experiment”.
So the cool part is this, try editing some of the files, maybe even remove some files and add some other files to the folder git_test to test how all of this works then try:
> git add .
This will add any new files you just pasted in your git_test folder for tracking and finally try:
> git commit -a -m "Committing in experiment to test branches"
Here is the magic, try:
> git checkout master
Go back to see your new edits and check for the files you removed or added; all the changes are gone! Your folder is now in it’s initial/stable state!
To remove a branch try:
> git branch -d "experiment"
Again remember, GIT won’t ask you “are you sure?” or questions like that so be careful when removing stuff…
I should also mention that GIT was written by Linus Torvalds who also made Linux Kernel…
That’s it for now, I will write more about this great tool soon and I hope this helps someone.
1 – Did you know that there were only 300 years of peace on Earth in total?
2 – GPS satellites have atomic clocks that tick at around a few billion times per second, did you know that their clocks tick a little faster than the clocks on earth? This is what Albert Einstein predicted, clocks that are closer to a strong source of gravity tick slower!!!!
http://en.wikipedia.org/wiki/Global_Positioning_System#Relativity
3 – Did you know that an unknown flying object followed Apollo 11 along it’s way to the moon? If you don’t believe me, listen to Buzz Aldrin talking about it:
4 – Did you know that there are 100,000 little machines inside each of our cells?
5 – Did you know that some people who we thought that were in vegetative state are actually aware but can’t communicate?
Ignore my last post, the more I know about it, the more problems I have with this pretty device…
Here are my mail reasons:
1 – It doesn’t have the OSX, the OS is like the one on iPhone.
2 – No multitasking support.
3 – No Flash support!!!!
4 – No camera.
It’s basically a giant iPhone with less features!!
Sadly, Apple got it wrong this time. I also noticed that Steve Jobs wasn’t very excited when he introduced it, it wasn’t like the iPhone keynote, maybe he wasn’t very pleased with it either.
It’s too bad…
If you get this error message after updating your Facebook library files:
Fatal error: Call to undefined method FacebookRestClient::users_isAppAdded()
Try changing this code:
<?php /* ... */ try { if (!$facebook->api_client->users_isAppAdded()) { $facebook->redirect($facebook->get_add_url()); } } catch (Exception $ex) { //this will clear cookies for your application and redirect them to a login prompt $facebook->set_user(null, null); $facebook->redirect($appcallbackurl); } /* ... */ ?>
With this:
<?php /* ... */ try { if (!$facebook->api_client->users_isAppUser()) { $facebook->redirect($facebook->get_add_url()); } } catch (Exception $ex) { //this will clear cookies for your application and redirect them to a login prompt $facebook->set_user(null, null); $facebook->redirect($appcallbackurl); } /* ... */ ?>
Use this at your own risk, it seems to fix the problem and I’m hoping it won’t introduce bugs in other places…
This is just a bare-bone script, you will have to adopt it for your own use, this is to demonstrate how it’s done:
<?php if (empty($_POST) || @count($_POST) < 1) exit; $query = array('cmd=_notify-validate'); foreach ($_POST as $key => $val) { if (!empty($val)) { $query[] = $key .'=' .urlencode($val); $$key = trim(strip_tags($val)); } } $query = implode('&', $query); $has_curl = false; if (function_exists('curl_init') && $ch = curl_init()) { curl_setopt($ch, CURLOPT_URL, 'http://www.paypal.com/cgi-bin/webscr'); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $query); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Codehead + Curl'); $result = curl_exec($ch); curl_close($ch); $has_curl = true; } if (!$has_curl) { $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Host: www.paypal.com\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($query) . "\r\n\r\n"; if ($fp = fsockopen(www.paypal.com, 80, $errno, $errstr, 30)) { socket_set_timeout($fp, 15); fwrite($fp, $header . $query); while (!feof($fp)) { $result = fgets($fp, 1024); if (strcmp($result, 'VERIFIED') == 0) break; } fclose($fp); } } if ($result == 'VERIFIED' || strtolower($result) == 'verified') { if($txn_type == 'subscr_signup') { /* Do something */ exit; } else if($txn_type == 'subscr_modify') { /* Do something */ exit; } else if($txn_type == 'subscr_cancel') { /* Do something */ exit; } else if($txn_type == 'subscr_payment') { /* This will go bellow so the payments can be recorded */ } else if($txn_type == 'subscr_failed') { /* Do something */ exit; } else { /* Do something */ exit(); } $paypal = array(); $paypal['user_id'] = $user_id; $paypal['payment_date'] = time(); $paypal['completed_date'] = ($payment_status == 'Completed' ? time() : ''); $paypal['item_name'] = $item_name; $paypal['payment_type'] = $payment_type; $paypal['payment_status'] = $payment_status; $paypal['pending_reason'] = $pending_reason; $paypal['payment_amount'] = $mc_gross; $paypal['paypal_fee'] = (isset($mc_fee) ? $mc_fee : 0); $paypal['payment_currency'] = $mc_currency; $paypal['txn_id'] = $txn_id; $paypal['receiver_email'] = $receiver_email; $paypal['payer_name'] = $first_name .' ' .$last_name; $paypal['payer_email'] = $payer_email; $paypal['custom'] = $custom; $paypal['raw_payment_data'] = serialize($_POST); if (DO YOU HAVE A PAYMENT WITH THIS INFO IN THE DB? IF YOU DO, THIS WAS PROBABLY CLEARED SA YOU DONT HAVE ) { /* Insert this row */ } else if (YOU DO HAVE?) { /* Update this row */ } $user = array(); if ($payment_status == 'Completed') { /* Do something */ } elseif ($payment_status == 'Pending') { /* Do something */ } elseif ($payment_status == 'Failed') { /* If this is a subscription payment that is failed, then the code won't reach here and the $txn_type will be 'subscr_failed', see line 57 */ /* Do something */ } } header('HTTP/1.1 200 OK'); ?>
I hope this helps someone
One of the ways to experiment with Paypal is to setup some fake payments – in Sandbox of course – and send the $_POST variable that comes to the IPN script in an email to yourself…
Lately, I’m running to all sorts of issues that require math, strong math, and I finally decided to learn math again. I should say remember though…
When I was second grade in high school, the school took a math exam to find out who to send to mathematics Olympiads.
The exam was for 3rd graders but me and one of my friends made it into the mathematics Olympiads in our province.
I became 8th in that exam and it was very hard, I didn’t make it to the country wide exam but I was very good at math for my age, I was reading more advanced books.
When I was a third grader, everyone thought I would make it all the way to the world mathematics Olympiads but I missed the opportunity to signup for the exam and I was late; that was a huge disappointment for me…
To put it in perspective, when we were in 3rd grade, I scored 19.25 out of 20 in our “Calculus, Differential and Integral” final exam, where NO ONE in our school scored more than 15!
Those days are gone and since I didn’t use math I forgot almost everything but a few theorems and I have to learn them again.
So I started with an absolute beginner math book, and now I’m reading “Calculus Made Easy” by Silvanus P. Thompson and Martin Gardner.
This book as absolutely amazing, it’s in print for 75 years!!!! and it was rewritten at 1946, then Martin Gardner updated and expanded the book in 1998 to make it even better.
If you want to learn math over again, you need to know calculus, then you can move on to more advanced topics like linear algebra etc.
This book is so much fun that I can’t stop reading it and I pick it up every little chance I get and hey I understand all of what I read!
The new Calculus books are a mess, they are so big and so thick and so poorly written that they make you hate the topic, but this book is exactly the opposite.