This file contains hidden or 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 delete branch with force | |
git branch -D branch_name | |
# git rename branch | |
git branch -m <oldname> <newname> | |
# ... or if the current branch | |
git branch -m <newname> | |
# change up stream |
This file contains hidden or 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
sudo /usr/sbin/useradd --shell /bin/bash --home /home/adminwebsite -g www-data adminwebsite | |
sudo mkdir /home/adminwebsite | |
sudo chown -R adminwebsite:www-data /home/adminwebsite | |
sudo chmod 0700 /home/adminwebsite | |
sudo passwd adminwebsite |
This file contains hidden or 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
#!/usr/bin/ruby | |
class Utopiantree | |
def cycle n | |
size = 1 | |
if n > 0 | |
for val in 0..n-1 |
This file contains hidden or 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
def genFibo(arr): | |
arr.append( arr[-1]+arr[-2] ) | |
def isFibo(n, fibos): | |
if n in fibos: | |
foo = 'IsFibo' | |
else: | |
foo = 'IsNotFibo' | |
return foo |
This file contains hidden or 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
#find string inside files | |
grep -rnw 'directory' -e "pattern" | |
#replaces string inside files, recursive | |
cd /home/www | |
find . -type f -print0 | xargs -0 sed -i 's/split(/explode(/g' |
This file contains hidden or 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
class Test | |
def initialize | |
@hash = {prop1: 'prop 1 value', prop2: 'prop2 value'} | |
end | |
def method_missing(m, *args) | |
#setter | |
if /^(\w+)=$/ =~ m | |
@hash[:"#{$1}"] = args[0] | |
end |
This file contains hidden or 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
db.contests_tbbt2013.aggregate( | |
{ $group: {_id: "$country", total: {$sum: 1} } } | |
); | |
db.contests_tbbt2013.aggregate( | |
{$group: | |
{ | |
_id:{ $dayOfYear:'$regdate' }, | |
sum:{$sum:1}, | |
date:{$first: '$regdate'} |
This file contains hidden or 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
db.copyDatabase("test","test_copy","127.0.0.1"); |
This file contains hidden or 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
#!/bin/bash | |
#save HTML content to file.html | |
curl -o /tmp/file.html http://glowgaze.com/ | |
#search by grep content in file.html | |
function get { | |
arr=(`cat /tmp/file.html | grep -o -E '(goto-+([0-9]*-)('$1')(\w)*)'`) | |
echo ${arr[0]} |
This file contains hidden or 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
error_reporting(E_ALL); | |
ini_set('display_errors', '1'); |
NewerOlder