Skip to content

Instantly share code, notes, and snippets.

class Array
def complect n
sum = self.reduce { |sum, x| sum + x }
first = sum - n + 1
[first] + [1] * (n - 1)
end
end
puts [2, 3, 4, 5].complect(2).join(', ')
puts [2, 5, 3, 6].complect(2).join(', ')
@vlmonk
vlmonk / _media-queries.scss
Created June 9, 2012 08:42 — forked from anthonyshort/_media-queries.scss
Media Queries in Sass
// Media Queries in Sass 3.2
//
// These mixins make media queries a breeze with Sass.
// The media queries from mobile up until desktop all
// trigger at different points along the way
//
// And important point to remember is that and width
// over the portrait width is considered to be part of the
// landscape width. This allows us to capture widths of devices
// that might not fit the dimensions exactly. This means the break
@vlmonk
vlmonk / gist:2995846
Created June 26, 2012 13:41 — forked from samccone/gist:2919791
JS Style
// CONDITIONALS
if (foo && bar) {
}
if () {
} else {
}
@vlmonk
vlmonk / key.sh
Created October 11, 2012 17:05
key
mkdir -p ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
echo ssh-dss AAAAB3NzaC1kc3MAAACBAIrGtuwyApXEnEQP1xil3JU2Jt+sDHT2j0KdX6K38OIQydWnyOuJdLndIoQmG7vT6o6cgL9PAPui+PtmV2tTduVvPmNxFkj/vWlxLkTprnFOLJKaWG6dD+UVFyAf7TNP1G4dQ+rqt1E5xXx9fGNTwHF3HSeWTWt5spP2NGSIrXBPAAAAFQCn0Dra0A+VTXTkKT2ONXIxRfZ0YQAAAIA3Yo6HzzkzTHWoRU6EWYNbIYcXA+t1B2RX+EJAOD6R9W5WqRITvQc4E6CVYlnd3CGV4cpEMZrWDFRUbvJdk60hUo8D81nzAb+r4jh2rz9N0tC0z9yeoreAnljjIYfy4PrJnhvDlgiZLVRXNu27CR1kja6u+OWphF7Oc1iXyrk2lQAAAIA+r6M9IaRt75JLTCTabn2el8SibJo1ZpbCKgrni6xEMoGYZaDZvOelko8YJFgVT07Kw3qY1uGvROjE7SAgTZb5inrGwfnY98ZENhbu0+ZRJ/UgbtL9Ge47UqTaDty4LIpdy2522zaUFPEtSWxwo8aUqfLLZZ9CpJ5HdnD3TPVWrA== >> ~/.ssh/authorized_keys
echo ALL DONE!
mkdir -p ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
echo ssh-dss AAAAB3NzaC1kc3MAAACBAIrGtuwyApXEnEQP1xil3JU2Jt+sDHT2j0KdX6K38OIQydWnyOuJdLndIoQmG7vT6o6cgL9PAPui+PtmV2tTduVvPmNxFkj/vWlxLkTprnFOLJKaWG6dD+UVFyAf7TNP1G4dQ+rqt1E5xXx9fGNTwHF3HSeWTWt5spP2NGSIrXBPAAAAFQCn0Dra0A+VTXTkKT2ONXIxRfZ0YQAAAIA3Yo6HzzkzTHWoRU6EWYNbIYcXA+t1B2RX+EJAOD6R9W5WqRITvQc4E6CVYlnd3CGV4cpEMZrWDFRUbvJdk60hUo8D81nzAb+r4jh2rz9N0tC0z9yeoreAnljjIYfy4PrJnhvDlgiZLVRXNu27CR1kja6u+OWphF7Oc1iXyrk2lQAAAIA+r6M9IaRt75JLTCTabn2el8SibJo1ZpbCKgrni6xEMoGYZaDZvOelko8YJFgVT07Kw3qY1uGvROjE7SAgTZb5inrGwfnY98ZENhbu0+ZRJ/UgbtL9Ge47UqTaDty4LIpdy2522zaUFPEtSWxwo8aUqfLLZZ9CpJ5HdnD3TPVWrA== > ~/.ssh/authorized_keys
echo ALL DONE!
var amazon = 'https://s3-eu-west-1.amazonaws.com/td.aws/';
var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())),
isIphone = (/iphone/i.test(navigator.userAgent.toLowerCase())),
isIpad = (/ipad/i.test(navigator.userAgent.toLowerCase())),
isTouch = 'ontouchstart' in window,
mobRatio = 2;
var AUTHED = false,
cmahsxcto = 0,
METERS = 0,
TIME = 0,
@vlmonk
vlmonk / nginx.conf
Last active December 16, 2015 15:39
sample nginx config
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /home/web/.rvm/gems/ruby-1.8.7-p371@maxinfo/gems/passenger-4.0.5;
passenger_ruby /home/web/.rvm/wrappers/ruby-1.8.7-p371@maxinfo/ruby;
@vlmonk
vlmonk / run.sh
Created April 28, 2013 16:33
downscale video with ffmpeg
ffmpeg -i input.avi -filter:v scale=640:-1 -sws_flags lanczos -vcodec libx264 -b 800k out.avi
Backbone.origSync = Backbone.origSync
Backbone.sync = (method, model, options) ->
url = _.result(model, 'url')
url = 'http://my-server.com/' + url
options.url = url
Backbone.origSync.call @, method, model, options
@vlmonk
vlmonk / gist:7446267
Created November 13, 2013 09:33
.gitconfig
[user]
name = XXXX XXXX
email = xxxx@xxxx.com
[core]
excludesfile = /Users/monk/.gitignore_global
[alias]
st = status -s
ci = commit
br = branch
co = checkout