Instantly share code, notes, and snippets.

View couchclone.sh
#!/bin/sh
#
# Janos Kasza (@janoskk)
#
# Creates (if necessary) and replicates all databases from a couchdb server to another one
#
if [ -z "$2" ]; then
cat <<EOF
Usage: $0 <sourceUrl> <targetUrl>
View gist:fa3cfb4816efad2bc2ee13371fa343a4
{"id":"user.mmckay","rev":"483-3aa701c325713bc5188c725b2cff5eed","rev_tree":[{"pos":481,"ids":["56bc58ec9e722170a1f7e1e853b9e80a",{"status":"available"},[["5c8362fc2fdd4202bc96b4aed9f42388",{"status":"available"},[["a7a68d1e78f54bbba45d5dfb4b90a8fa",{"status":"available"},[["3825e6364907403d9509c023b1a4872c",{"status":"available"},[["020734783608439ba9b2beb4e910d7d0",{"status":"available"},[]]]]]]]]]]},{"pos":483,"ids":["3aa701c325713bc5188c725b2cff5eed",{"status":"available"},[]]}],"winningRev":"485-020734783608439ba9b2beb4e910d7d0","deleted":false,"seq":715}
View gist:dbc535cf96d5cd7d1e967dc2787bc602
db = new PouchDB()
user = "user.mmckay"
db.get user,
revs_info: true
.then (result) ->
availableRevs = _(result._revs_info).chain().filter (rev) ->
rev.status is "available"
.pluck("rev").value()
_(availableRevs).each (rev) ->
db.get user,
View gist:0dc7f46a81adb270f05622d6d87a7cdd
originalResultSync = Result::sync
Result::sync = (method, model, options) =>
console.log method
console.log model
console.log options
if method is "update" or method is "create"
newModelAttributes = {
_id: model.get "_id"
}
View executeViews.coffee
request = require 'request'
glob = require 'glob'
_ = require 'underscore'
database = process.argv.pop()
glob "**/*.coffee", (er, files) ->
_(files).each (view) ->
return if view.match(/__reduce/) or view is "executeViews.coffee"
View pushViews.rb
#! /usr/bin/env ruby
require 'rubygems'
require 'couchrest'
require 'json'
@db = CouchRest.new(ARGV[0]).database!(ARGV[1])
#Get all .coffee files
Dir.glob("*.coffee").each do |view|
next unless view.match(/__reduce/).nil?
View index.js
'use strict';
var tablesort = require('tablesort');
function cleanNumber(i) {
return i.replace(/[^\-?0-9.]/g, '');
}
function compareNumber(a, b) {
a = parseFloat(a);
View gist:00daafd5d55306242b6c
cat Pandora\ Songs | sed -r 's/^/gvsearch1:/' | xargs -d '\n' --max-args=1 youtube-dl -x --audio-format mp3
View gist:a0c38311f0dcfebcb635
JSONC = require './public/JSONC.js'
s = "H8KLCADCswRiVAIDbVdNb8OcNhDDvSvDgl56w4klPcO6NsKywrhawopLUcKQw4QVwrzChVEEwq7DkRgIaiNNDkXDkMO/w543H8Kkw5ZtwpHDgDscccK5w4N5b8Oewox+HH59w7nDrXB3w6jCn1/Cm8OTw4vDs8OXT1/Cnz7Dv3XDuHDDuFzDrcK7H8KHwpAXP8O6ZnLCsSVew5/CnyjCuEbDvh7Drn7DoSXDvsKPHl/Do8OPwoHCisKdw4bCnmB0wqlLw7gIwr5NIcOJwqPDoMOvT3nDrDfCssOVw5nCj8KdWBvCnR0+I3V4wpzDhVrDjcOVw6bCq8KXw63DscOowoPDn8O4w6DDmMK7wrPCi2rCpV7Cj8KOw6/CjsKOIcONaTnDmSPDnMKiwrczLjnCqnPDrMOIwr45w7Y/UWzDpcOgKQ/Cum/DocKzw5hYfcOrZz9ew5nDjjjCvMOTw7MvfsOFJcOTw4DDtkYzw4nDhyYrwrfCnHh5w7USw4rCo8OEw4LCliYMwpnCrAnDq2lzJWMhw6HCj8KYGVt6w7UPCXFxEgJvw5bCnMK5wrHCk1Bhw7RuEMOLL8O4wq1mwqLDscKqw4vCksOewpzDsV9yGXDCkB7DiTYiw58swrV9wrZ8wrXDuSHCq8OVUw8ULMKjDmdaekcqOHgYFk4cfGzDjcKNIB9Kw6QxFBxXXMOZK8KSa8K9RcOMw7A6w419DcKNw4ErfEIOwqMvwqYXwo4sK8KdwqjDpTNxwq1VfzNvIMOCwqggIG10eMO8wpvCk8K1BMKJdSfCrlxFwpItKHh2fzgcPQLClsKMHcKzw7HDkMKPSRPDjsKPFm80RW7Cmj1Dw6BywqdkHcKcEgNJw6XCqxnChRnDucOGLsK2U8K0w7lYUmrCoEd/wqrDnGXDljUbwrIqFMKKXBZJwojCmwM1wpHDuhPDjcOgw6HCjWdhTxDDj8KKSijCnMOFwr3CmsK4U8
View gist:0912613ef885261663a1
resizeCanvas = function (largerOrSmaller){
scaleValue = (largerOrSmaller == "larger") ? 0.1 : -0.1
$('#canvasHolder').css({ scale: ($('#canvasHolder').css('scale') + scaleValue) });
offset = $("#canvasHolder").offset()
if (largerOrSmaller == "larger")
if (offset.top > 0 && offset.left > 0)
resizeCanvas("larger")
else
$('#canvasHolder').css({ scale: ($('#canvasHolder').css('scale') - scaleValue) });