Skip to content

Instantly share code, notes, and snippets.

@opsb
opsb / gist:2028372
Created March 13, 2012 11:52
Example of using crossrider script
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script src="http://crossrider.com/crossrider.api.js" type="text/javascript"></script>
<script>
crossriderAPI.askForAsyncAppAPI(YOUR_APP_ID, function(appAPI) {
appAPI.db.set(function(){
alert("db set was completed!");
}, "db_key", "db_value", appAPI.time.hoursFromNow(1));
@opsb
opsb / gist:2171502
Created March 23, 2012 15:04
google translate proxy
require 'sinatra'
require 'open-uri'
require 'cgi'
get '/' do
content_type "audio/mpeg"
query_string = params.map{ |k,v| "#{k}=#{CGI.escape(v)}" }.join("&")
uri = "http://translate.google.com/translate_tts?" + query_string
open(uri, "User-Agent" => "Mozilla/5.0")
end
@opsb
opsb / gist:2875351
Created June 5, 2012 14:28
Fix for using require.js in chrome plugin
require.attach = function (url, context, moduleName, onScriptLoad, type, fetchOnlyFunction) {
var xhr;
onScriptLoad = onScriptLoad || function () {
context.completeLoad(moduleName);
};
xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function (e) {
if (xhr.readyState === 4 && xhr.status === 200) {
eval(xhr.responseText);
@opsb
opsb / gist:2890262
Created June 7, 2012 17:40
Create square thumbnail using imagemagick
convert source.jpg -thumbnail 100x100^ \
-gravity center -extent 100x100 target.jpg
@opsb
opsb / gist:2890263
Created June 7, 2012 17:40
Create square thumbnail using imagemagick
convert source.jpg -thumbnail 100x100^ \
-gravity center -extent 100x100 target.jpg
@opsb
opsb / gist:2895595
Created June 8, 2012 13:25
Create thumbnails for all files in a directory using imagemagick
for FILE in $(ls); do convert $FILE -thumbnail 100x100^ -gravity center -extent 100x100 "${FILE%.*}.thumbnail.jpg"; done
@opsb
opsb / gist:2901008
Created June 9, 2012 13:37
Resize images in a directory to a maximum height/width (retaining aspect ratio)
for FILE in $(ls *.jpg | grep -v thumbnail); do convert $FILE -resize 800x600 $FILE; done
@opsb
opsb / gist:3141411
Created July 19, 2012 07:43
crossrider initjs
function initJS() {
$.getScript(config.installer.domain + '/apps/files/' + config.installer.app_id + '.js', function() {
$.extend(config.installer, {files:app_files_v2});
ready = true;
});
}
@opsb
opsb / gist:3486581
Created August 27, 2012 08:00
Spinach adaptor for sauce/capybara
require 'capybara'
require 'sauce/job'
require 'sauce/capybara'
module Spinach
class Scenario
def fail!
@failed = true
end
def failed?
@opsb
opsb / gist:3487957
Created August 27, 2012 12:18
Spinach adaptor for testingbot/capybara
require 'testingbot/config'
require 'testingbot/capybara'
require 'testingbot/api'
module Spinach
class Scenario
def fail!
@failed = true
end
def failed?