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
#!/bin/bash | |
# Get directory of project where this script is | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
# Go to directory | |
cd $DIR | |
# Get the remote SSH command | |
SSH="$( git remote -v | grep live | grep push | awk '{ print $2; }' | cut -f1 -d":" )" | |
# Do the command as root over ssh | |
ssh -t $SSH "cd $DIR; sql/sqlbackup.sh && git add . && git commit -a -m 'Puppy' && git push" |
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
if ($('.shorty').height() > 300) { | |
$('.shorty').css('max-height', '300px'); | |
$('.shorty').css('overflow', 'hidden'); | |
$('.shorty').after('<a href="#" class="readmore">Läs mer</a>'); | |
$('a.readmore').click(function() { | |
$('.shorty').css('max-height', ''); | |
$(this).remove(); | |
return false; | |
}); | |
} |
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 os | |
ROOT_DIR = os.path.dirname(os.path.realpath(__file__)) |
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
#!/bin/sh | |
CMD=$1 | |
SUBJECT=$2 | |
FROM_EMAIL="server@example.com" | |
EMAIL=`cat ~/.email_addr` | |
if [ -z "$SUBJECT" ] | |
then | |
SUBJECT="'$CMD' `date +\"%A %d/%m/%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
from math import sqrt | |
def score(phat, n, z=1.0): | |
#z 1.0 = 85%, 1.6 = 95% | |
return ((phat + z*z/(2*n) - z * sqrt((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)) | |
def confidence(ups, downs): | |
n = ups + downs | |
if n == 0: |
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
OUT=mongobackup/$(date +%Y%m%d-%H%M) | |
mkdir -p $OUT | |
mongodump --out $OUT |
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 redis | |
r = redis.Redis() | |
def ratelimit(key): | |
EXPIRE = 10 | |
RATE = 10 | |
value = r.incr(str(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
build-essential | |
libz-dev | |
libreadline-dev | |
libncursesw5-dev | |
libssl-dev | |
libgdbm-dev | |
libsqlite3-dev | |
libbz2-dev |
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
GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES,CREATE TEMPORARY TABLES, DROP, REFERENCES ON database.* TO user@localhost IDENTIFIED BY 'password'; |
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
# self.app can be None | |
# self.app.config.get('DATABASE') can be None | |
try: | |
db = self.app.config['DATABASE'] | |
logger.debug('Using database "{db}"'.format(db=db)) | |
except: | |
db = 'test' | |
logger.warning('DATABASE setting not set, using database "test"') |
OlderNewer