This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There are times when you need to keep the date and time of your system to be correct. | |
Ntpdate in linux helps you do the same | |
sudo ntpdate -u ntp.ubuntu.org | |
ntpdate are installed on most distributions, if not install using apt-get. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh -C2qTnN -D 8080 username@xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx is the ip which allows ssh access) (can change the port from 8080 to as per requirement) | |
You are connected to the proxy. To use the proxy, go the one of your browser | |
and change the proxy settings to use SOCKS protocol and localhost (127.0.0.1) with port 8080. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating a date from format yyyy-mm-dd | |
$date = DateTime::createFromFormat('Y-m-d', $generatedFrom); | |
if (!($date instanceof DateTime)) { | |
throw new ValidationError('Not valid start date'); | |
} | |
Similarly other formats can be validated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git ls-files -z | xargs -0n1 git blame -w | perl -n -e '/^.*\((.*?)\s*[\d]{4}/; print $1,"\n"' | sort -f | uniq -c | sort -n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After into mysql cli | |
use command " pager less -SFX " and then use mysql cli normally | |
You can use arrow keys as well as pageup/down keys. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime | |
import sublime_plugin | |
class NumberCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
selection = self.view.sel() | |
for region in selection: | |
try: | |
value = int(self.view.substr(region)) | |
self.view.replace(edit, region, str(self.op(value))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
delete from my_table mt1, my_table mt2 where mt1.fieldX = mt2.fieldX and mt1.fieldY = mt2.fieldY and mt1.primary_key > mt2.primary_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' | sort -k5n -k2M -k3n -k4n | grep 'user' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get install -y ppa-purge | |
add-apt-repository -y ppa:ondrej/php5-oldstable | |
apt-get update | |
ppa-purge ppa:ondrej/php5 | |
apt-get update && apt-get upgrade -y && apt-get autoremove -y && apt-get autoclean -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function fibo($n, $first =1, $second=1) | |
{ | |
if($n==1 || $n==2) | |
return $second; | |
else | |
return fibo($n-1, $second,($first + $second)); | |
} |
OlderNewer