Skip to content

Instantly share code, notes, and snippets.

View ecounysis's full-sized avatar

Eric Christensen ecounysis

View GitHub Profile
@ecounysis
ecounysis / pp.el
Last active August 29, 2015 13:56
pair-program virtual emacs
(defun pair-program (revert-interval save-interval)
(interactive "nRevert Interval: \nnSave Interval: ")
(setq auto-revert-interval revert-interval)
(auto-revert-mode)
(run-at-time "1 sec" save-interval 'save-buffer))
@ecounysis
ecounysis / edit_distance.py
Last active December 28, 2015 20:18
levenshtein
def minimum (a,b,c):
val1 = a
if (b<a):
val1 = b
val2 = b
if (c<b):
val2 = c
if val1<val2:
return val1
return val2
@ecounysis
ecounysis / perepl
Created November 19, 2013 20:23
Rudimentary REPL for PERL
#!/usr/bin/env perl
use warnings;
@_history=();
$_prompt1 = "perl> ";
$_prompt2 = "... ";
print "\nPERL interactive\n";
_printlicense();
print "\n\n$_prompt1";
@ecounysis
ecounysis / cycling.py
Created October 18, 2013 14:21
How much power in watts do you need on a stationary bicycle in order to replicate outdoor riding conditions given your weight, speed, wind resistance, and grade?
#http://en.wikipedia.org/wiki/Bicycle_performance#Aerodynamics_vs_power
G = 9.8 #earth's gravitational constant
K1 = 0.0053 #lumped constant for all frictional losses (tires, bearings, chain), and is generally reported with a value of 0.0053
K2 = 0.185 #lumped constant for aerodynamic drag and is generally reported with a value of 0.185 kg/m
def power(velocity_ground, velocity_air, grade, mass):
"""
mass is in kg
velocity_ground and velocity_air are in meters per second
grade is percent eg 0.05, 0.12
export MARKPATH=$HOME/.marks
function jump {
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
}
function mark {
mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1"
}
function unmark {
rm -i "$MARKPATH/$1"
}
@ecounysis
ecounysis / shortcut.js
Created July 9, 2013 23:11
shortcut.js
/**
* http://www.openjs.com/scripts/events/keyboard_shortcuts/
* Version : 2.01.B
* By Binny V A
* License : BSD
*/
shortcut = {
'all_shortcuts':{},//All the shortcuts are stored in this array
'add': function(shortcut_combination,callback,opt) {
//Provide a set of default options
@ecounysis
ecounysis / editable.js
Last active December 19, 2015 13:28
jQuery plugin to make a dom element editableeditable.js
(function ($) {
$.fn.editable = function (func) {
// func returns true or false - if true the dom element is updated and the popup is removed
// func can have side effects
// depends on shortcut.js and your definition of the "editable-popup" and "bluelink" classes
this.css("cursor", "pointer");
this.click(function (evt) {
// cleanup
$(".editable-popup").remove();
shortcut.remove("Enter");
// depends on jQuery and handlebars
// http://jquery.com/
// http://handlebarsjs.com/
// less is always nice too
// http://lesscss.org/
// as is jqueryui
// http://jqueryui.com/
@ecounysis
ecounysis / make_adder.py
Created October 24, 2012 18:20
Some Functions
def make_adder_function(x):
return lambda y:x+y
plus={}
add=[]
for i in range(20):
plus[i]=make_adder_function(i)
add.append(make_adder_function(i))
@ecounysis
ecounysis / scheme.el
Created June 6, 2012 05:46
scheme.el
; unix
(setq scheme-program-name "csi -:c")
;(setq scheme-program-name "racket")
; winblows
; (setq scheme-program-name "C:/Progra~1/Racket/racket")
; winblows 7
; (setq scheme-program-name "C:/Progra~2/Racket/racket")