Skip to content

Instantly share code, notes, and snippets.

@fredrick
fredrick / screen.md
Created Sep 14, 2011
GNU Screen Cheat Sheet
View screen.md

#GNU Screen Cheat Sheet

##Basics

  • ctrl a c -> cre­ate new win­dow
  • ctrl a A -> set win­dow name
  • ctrl a w -> show all win­dow
  • ctrl a 1|2|3|… -> switch to win­dow n
  • ctrl a " -> choose win­dow
  • ctrl a ctrl a -> switch between win­dow
  • ctrl a d -> detach win­dow
@fredrick
fredrick / async.py
Created Mar 17, 2011
Using Python's multiprocessing module, it's easy to create asynchronous subprocesses
View async.py
#!/usr/bin/env python
# encoding: utf-8
import random
import time
import multiprocessing
if __name__ == '__main__':
"""Demonstration of GIL-friendly asynchronous development with Python's multiprocessing module"""
@fredrick
fredrick / String.format.js
Created May 16, 2011
printf()/format() for JavaScript String
View String.format.js
/*
* Extend JavaScript String object with printf() like functionality
* "{0} is dead, but {1} is alive!".format("This", "that");
*/
String.prototype.format = function() {
var formatted = this;
for(arg in arguments) {
formatted = formatted.replace("{" + arg + "}", arguments[arg]);
}
return formatted;
@fredrick
fredrick / App-example-test.js
Last active Apr 6, 2018
React Router Test Context Helper
View App-example-test.js
var React = require('react/addons'),
TestUtils = React.addons.TestUtils,
TestContext = require('./TestContext'),
App = require('./App.jsx'),
app = TestContext.getRouterComponent(App);
describe('App', function() {
it('has something', function() {
expect(app.getDOMNode().textContent).toContain('something');
});
View run_survival.py
%matplotlib inline
import numpy as np
from lifelines import KaplanMeierFitter
from matplotlib import pyplot as plt
from pylab import rcParams
rcParams['figure.figsize'] = 20, 10
plt.style.use('ggplot')
@fredrick
fredrick / UserQuery.js
Created Feb 1, 2012
Async.js and Node.js
View UserQuery.js
var async = require('async');
// Waterfall through callbacks using Mongoose to query for a user
async.waterfall([
function(callback) {
/** Function 1. Find User.
* Pass `user` to Function 2.
*/
User.findOne({ username: 'fred' }, function(error, user) {
@fredrick
fredrick / couchdb.conf
Created Nov 28, 2011 — forked from kowsik/couchdb.conf
Upstart script for CouchDB
View couchdb.conf
# Upstart file at /etc/init/couchdb.conf
# CouchDB
start on runlevel [2345]
stop on runlevel [06]
pre-start script
chown -R couchdb /usr/local/etc/couchdb
chown -R couchdb /usr/local/lib/couchdb
chown -R couchdb /usr/local/var/log/couchdb
View hp35.txt
7 7
~:,,:~
7 +:,.~~~~~~:~7
777777 7~:.?7~~~~~~~~~,:+7
77 777 7 7 77~,.:,,:..7~~~~~~~~~.:7
7777777777777777777 77~:,7,:~::::,:..~~:~~~~~~~,:7 7
7777777777777777777777 777 7 77~:.7::::.:~:::..:::?~~~~~~~~~~,~7 7
777777777777777777777777777777777:,=,:::?::::..:~::,~::,.7~~~~~~~~~~,~77
77777777777777777777777777777::.7::~::~:...~:::.~?,::::::,.7~~~~~~~~~~,~ 7777777
77777777777777777777777777:.~,::::.:~,~:::,~~:::..:~~::::::..+~~~~~~~~~,,~777777
@fredrick
fredrick / powermean.r
Last active Dec 16, 2015
Generalized/power mean with R
View powermean.r
# Power mean
## Examples:
## p = 1, arithmetic mean
## p = 2, quadratic mean (RMS)
pmean <- function(x, p) {
library(TTR)
return(tail(TTR::SMA(x^p, length(x))^(1/p), n=1))
}
View Preferences.sublime-settings
{
"color_scheme": "Packages/User/Monokai Soda.tmTheme",
"ensure_newline_at_eof_on_save": true,
"translate_tabs_to_spaces": true,
"font_face": "Monaco",
"font_size": 12,
"theme": "Soda Light.sublime-theme"
}
You can’t perform that action at this time.