Skip to content

Instantly share code, notes, and snippets.

Mike McKay mikeymckay

View GitHub Profile
View fuzzyFix.coffee
FuzzyMatch = require 'fuzzy-matching'
PouchDB = require 'pouchdb'
_ = require 'underscore'
database = new PouchDB("http://****:*******@gooseberry.tangerinecentral.org:5984/gooseberry")
database.get "tusome teacher zones"
.then (doc) =>
zones = _(doc.data).chain().map (row) =>
row.Zone.replace(/\(.*\)/, "").trim()
@mikeymckay
mikeymckay / couchclone.sh
Last active May 24, 2018 — forked from janoskk/couchclone.sh
Create (if necessary) and replicate all databases from a couchdb server to another one
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,
@mikeymckay
mikeymckay / gist:0dc7f46a81adb270f05622d6d87a7cdd
Created Jun 14, 2017
Adding a backbone filter to pre/post process data (useful for encoding data in the database)
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?
@mikeymckay
mikeymckay / index.js
Last active May 11, 2016 — forked from tristen/index.js
Using tablesort.extend in browserified tablesort
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);
@mikeymckay
mikeymckay / gist:00daafd5d55306242b6c
Created Feb 9, 2016
Download a list of songs from youtube
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.