Skip to content

Instantly share code, notes, and snippets.

View kevgathuku's full-sized avatar

Kevin Gathuku kevgathuku

View GitHub Profile
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 9, 2024 10:41
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@theju
theju / dropbox_upload_handler.py
Created July 17, 2012 11:18
Upload files to dropbox from your django app
from django.core.files.uploadhandler import TemporaryFileUploadHandler
from django.core.files.base import File
from dropbox.client import DropboxClient
from dropbox.session import DropboxSession
from django.conf import settings
import os
class DropboxFileUploadHandler(TemporaryFileUploadHandler):
def __init__(self, *args, **kwargs):
super(DropboxFileUploadHandler, self).__init__(*args, **kwargs)
@hkulekci
hkulekci / detect.js
Created August 23, 2012 07:31
Detect Operating System with Javascript
// This script sets OSName variable as follows:
// "Windows" for all versions of Windows
// "MacOS" for all versions of Macintosh OS
// "Linux" for all versions of Linux
// "UNIX" for all other UNIX flavors
// "Unknown OS" indicates failure to detect the OS
var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
@karlwestin
karlwestin / gist:3487951
Created August 27, 2012 12:17
Handlebars logging - tips for debugging templates!
/*
* Use this to turn on logging: (in your local extensions file)
*/
Handlebars.logger.log = function(level) {
if(level >= Handlebars.logger.level) {
console.log.apply(console, [].concat(["Handlebars: "], _.toArray(arguments)));
}
};
// DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3,
@billroy
billroy / jsonio.py
Created September 21, 2012 13:38
Read/write JSON object from file in python
import simplejson
import json
def put(data, filename):
try:
jsondata = simplejson.dumps(data, indent=4, skipkeys=True, sort_keys=True)
fd = open(filename, 'w')
fd.write(jsondata)
fd.close()
except:
@luhn
luhn / getter_and_setter.py
Created November 29, 2012 18:35
Using getters and setters with SQLAlchemy
class Table(Base):
id = Column(Integer, primary_key=True)
_name = Column('name', String(24))
@property
def name(self):
return self._name;
@name.setter
def name(self, value):
@sagar-ganatra
sagar-ganatra / WrapRenderFunction.js
Created January 25, 2013 05:52
Adding beforeRender and afterRender functions to a Backbone View Refer to the blog post http://www.sagarganatra.com/2013/01/adding-beforerender-and-afterrender-functions-to-backbone-view.html
(function () {
var TestView = Backbone.View.extend({
el: '#container',
initialize: function () {
console.log('Inside Init');
@justinbmeyer
justinbmeyer / jsmem.md
Last active August 19, 2022 04:50
JS Memory

JavaScript Code

var str = "hi";

Memory allocation:

Address Value Description
...... ...
@joaoneto
joaoneto / login.test.js
Created March 13, 2013 13:49
Login session test with mocha
var request = require('supertest'),
should = require('should'),
app = require('../server');
var Cookies;
describe('Functional Test <Sessions>:', function () {
it('should create user session for valid user', function (done) {
request(app)
.post('/v1/sessions')