Skip to content

Instantly share code, notes, and snippets.

View mikeymckay's full-sized avatar

Mike McKay mikeymckay

View GitHub Profile
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) });
@mikeymckay
mikeymckay / gist:9090984
Last active August 29, 2015 13:56
Embedding ruby in bash
echo "Retrieving application files from cloud to put in local database:"
printf '%s\n%s\n' `echo "
require 'rubygems'
require 'couchrest'
cloud_db_url = 'http://example.org/zanzibar'
local_db_url = 'http://localhost:5984/zanzibar'
@cloud_db = CouchRest.database(cloud_db_url)
@mikeymckay
mikeymckay / DeleteCouchViewDocs.coffee
Created January 21, 2014 20:20
How to remove all documents found by a couchdb view
$.couch.db("tangerine").view "tangerine/results",
include_docs: true
success: (result) ->
docs = for row in result.rows
row.doc
$.couch.db("tangerine").bulkRemove {docs: docs},
success: (result) ->
console.log result
@mikeymckay
mikeymckay / gist:8224041
Created January 2, 2014 18:31
Ruby script to post to any google form (no login required).
#!/usr/bin/env ruby
# usage:
# post.rb <live_form_url> arg1 arg2 arg3 ...
require "rest-client"
live_form_url = ARGV.shift
post_form_url = live_form_url.gsub(/viewform/,"formResponse")
params = RestClient.get(live_form_url).scan(/(entry\.\d+)/).flatten
@mikeymckay
mikeymckay / gist:7446173
Created November 13, 2013 09:25
Errors while trying to make a trb file.
for dir in tests/*; do \
(cd "$dir" && make) \
done
make[1]: Entering directory `/var/www/muvuku/tests/charset'
avr-gcc -c -D_MUVUKU_TINY_STRINGS -Os -Wall -fno-strict-aliasing -fomit-frame-pointer -std=gnu99 -mmcu=atmega128 -fno-jump-tables -Wimplicit-function-declaration -fno-builtin -I../../../turbo-devel-1.5.24/include -I../../src -I. charset.c -o charset.o
charset.c:11:17: error: variable ‘lc_test_str’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
charset.c:30:19: error: variable ‘l_test’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
charset.c:41:17: error: variable ‘lc_topmenu_name’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
charset.c:47:17: error: variable ‘lc_menu_top’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
charset.c:52:17: error: variable ‘lc_select_str’ must be const in order to be put
require 'rubygems'
require 'sinatra'
require 'rest-client'
require 'cgi'
set :port, 9494
get '/' do
"<form action='/send'>
<input id='phone' name='phone' type='text'></input>
@$el.html "
Value used for grouping:
<select id='groupBy'>
#{
_.map propertiesToGroupBy, (value,key) ->
"<option #{if key is groupBy then "selected='true'" else ''}>
#{key}
</option>"
}
</select>
@mikeymckay
mikeymckay / coconut.php
Created August 13, 2012 14:24
PHP file to allow for cross site posts
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Content-Type');
var_dump($_POST)
?>
@mikeymckay
mikeymckay / gist:3248391
Created August 3, 2012 14:56
coconut.php
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Content-Type');
var_dump($_POST)
?>
@mikeymckay
mikeymckay / gist:1885577
Created February 22, 2012 15:35
Setting up an android couchdb phonegap apk builder
Ubuntu 10.04
#Setup android SDK
sudo apt-get install openjdk-6-jdk ant1.8 wget
wget http://dl.google.com/android/android-sdk_r16-linux.tgz
tar -xvzf android-sdk_r16-linux.tgz
cd android-sdk-linux/tools
./android update sdk --no-ui --filter platform-tool
./android update sdk --no-ui --filter 9