Skip to content

Instantly share code, notes, and snippets.

View nLight's full-sized avatar
:shipit:

Dmitriy (Dima) Rozhkov nLight

:shipit:
View GitHub Profile
@zipcode
zipcode / lens.js
Created February 6, 2014 19:59
A quick and dirty jQuery implementation of Lenses. If you're into that sort of thing.
(function ($) {
$.lens = {};
$.lens.of = function (get, set) {
var lens = function (d) { return get(d); }
lens.set = set;
lens.modify = function (d, f) { return set(d, f(get(d))); }
lens.compose = function (other_lens) {
return $.lens.of(
function (d) { return other_lens(get(d)); },
#!/bin/sh
# Shell script to install your public key on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
#
# http://www.devthought.com/2009/09/19/get-ssh-copy-id-in-mac-os-x/
#
@joelburget
joelburget / lenses.js
Created January 10, 2014 21:51
js lenses
var getter = function(obj, lens) {
return _(lens).foldl(function(focused, element) {
return focused[element];
}, obj);
};
var modifier = function(obj, lens, mod) {
if (lens.length === 0) {
return mod(obj);
} else {
@jramb
jramb / core.clj
Created February 14, 2012 20:01
Comparison of Aleph and Ring performance
(ns alephtest.core
(:require [lamina.core :as l])
(:require [aleph.http :as a])
(:require [ring.adapter.jetty :as jetty]))
;; https://github.com/ztellman/aleph
(def counter (atom 0))
(defn say-hello []
(let [n (swap! counter inc)]
@tonsky
tonsky / user.keymap
Created June 4, 2014 12:04
LightTable keymap of Sublime shortcuts
{ :+
{ :editor
{ "pmeta-/" [:toggle-comment-selection]
"ctrl-shift-up" [:editor.sublime.selectLinesUpward]
"ctrl-shift-down" [:editor.sublime.selectLinesDownward]
"pmeta-d" [:editor.sublime.selectNextOccurrence]
"ctrl-m" [:editor.sublime.goToBracket]
"ctrl-shift-m" [:editor.sublime.selectBetweenBrackets]
"shift-pmeta-space" [:editor.sublime.selectScope]
"ctrl-pmeta-up" [:editor.sublime.swapLineUp]
@piatra
piatra / app.js
Created June 27, 2012 12:14
xhr2 + nodejs + filereader = resumable uploads
var http = require('http')
, formidable = require('formidable')
, fs = require('fs')
, qs = require('querystring')
, util = require('util')
, uploads = {};
http.createServer(function(req, res){
if(req.method == 'GET') {
if(req.url != '/favicon.ico') {
@rweald
rweald / simple-linear-regression.rb
Created August 29, 2012 19:13
Simple Linear Regression in Ruby
class SimpleLinearRegression
def initialize(xs, ys)
@xs, @ys = xs, ys
if @xs.length != @ys.length
raise "Unbalanced data. xs need to be same length as ys"
end
end
def y_intercept
mean(@ys) - (slope * mean(@xs))
@benschw
benschw / Dockerfile
Last active October 1, 2018 18:30
MySQL Docker Container
FROM ubuntu
RUN dpkg-divert --local --rename --add /sbin/initctl
RUN ln -s /bin/true /sbin/initctl
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get -y install mysql-client mysql-server
@jorgenpt
jorgenpt / stream.sh
Created April 21, 2012 06:59
Commands to stream desktop to justin.tv on OS X
#!/bin/sh -xe
API_KEY="YOUR_API_KEY_GOES_HERE"
FPS="10"
VLC_PATH="/Applications/VLC.app/Contents/MacOS/VLC"
# I don't know how this'll behave on multimon, so you might want to hard-code.
# INRES='1440x900'
INRES=$(osascript -e 'tell application "Finder" to get bounds of window of desktop'|sed 's/, /x/g'|cut -f3- -dx)
OUTRES='1280x800'
# You can change this to record microphone or something else, from man soxformat (under coreaudio):
@weavejester
weavejester / gist:1001206
Created May 31, 2011 20:27
Clojure on Heroku
~/$ lein new ring-on-heroku
Created new project in: /home/jim/Development/ring-on-heroku
~/$ cd ring-on-heroku
~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile
~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj
(ns ring-on-heroku.core
(:use ring.util.response
ring.adapter.jetty))
(defn app [req]