Skip to content

Instantly share code, notes, and snippets.

@trilopin
trilopin / fabfile.py
Created November 20, 2015 07:15
fabfile with google compute engine (GCE) support + releases + virtualenv + supervisor
from fabric.api import env, run, sudo, local, runs_once
# Uncomment this two lines if you need debug mode
# import paramiko
# paramiko.common.logging.basicConfig(level=paramiko.common.DEBUG)
# gce conf
GCE_PROJECT = 'my-project'
GCE_ZONE = 'europe-west1-b'
GCE_HOSTMATCH = 'frontend.*'
GCE_GS_URL = 'gs://bucket/dir/'
@willprice
willprice / .travis.yml
Last active June 15, 2024 04:29
How to set up TravisCI for projects that push back to github
# Ruby is our language as asciidoctor is a ruby gem.
lang: ruby
before_install:
- sudo apt-get install pandoc
- gem install asciidoctor
script:
- make
after_success:
- .travis/push.sh
env:
@mitchwongho
mitchwongho / Docker
Last active September 23, 2024 12:09
Docker 'run' command to start an interactive BaSH session
# Assuming an Ubuntu Docker image
$ docker run -it <image> /bin/bash
@justecorruptio
justecorruptio / 2048.c
Created April 4, 2014 03:49
Tiny 2048 in C!
M[16],X=16,W,k;main(){T(system("stty cbreak")
);puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i
,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M
[w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<<
(l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k)
]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d
-1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X]
*i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4;
)s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4||
puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2
@Benoss
Benoss / config_local.py
Created March 17, 2014 01:09
Django add Debug Toolbar for non HTML response ex: Json rest response
DEBUG=True
SOUTH_TESTS_MIGRATE = True
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'geo', # Or path to database file if using sqlite3.
'USER': 'postgres', # Not used with sqlite3.
'PASSWORD': 'postgres', # Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
@simonc
simonc / gist:7578108
Last active December 28, 2015 23:19
Shell tips

Here are some shell/term tips I use on a day to day basis.

Escape-dot

When typing a command, using esc-. inserts the last argument of the previous command.

$ ls aaa.txt bbb.txt ccc.txt
...
$ ls <esc-.>

$ ls ccc.txt

@konklone
konklone / Dockerfile
Created September 22, 2013 18:17
Dockerfile for installing Ruby 2.0 and RVM
FROM ubuntu
MAINTAINER Eric Mill "[email protected]"
# turn on universe packages
RUN echo "deb http://archive.ubuntu.com/ubuntu raring main universe" > /etc/apt/sources.list
RUN apt-get update
# basics
RUN apt-get install -y nginx openssh-server git-core openssh-client curl
RUN apt-get install -y nano
@stantonk
stantonk / django_orm_query_stacktrace.py
Created May 4, 2013 00:49
Django logging config to dump a stack trace for every ORM query, so you can find the code that is producing queries that are icky.
DEBUG=True
LOG_FILE_SIZE=1024*1000
LOGGING = {
'version' : 1,
'disable_existing_loggers':True,
'formatters' : {
'simple' : {
'format' : '%(levelname)s %(name)s %(message)s'
},