This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getSApiSidHash(SAPISID, origin) { | |
function sha1(str) { | |
return window.crypto.subtle.digest("SHA-1", new TextEncoder("utf-8").encode(str)).then(buf => { | |
return Array.prototype.map.call(new Uint8Array(buf), x=>(('00'+x.toString(16)).slice(-2))).join(''); | |
}); | |
} | |
const TIMESTAMP_MS = Date.now(); | |
const digest = await sha1(`${TIMESTAMP_MS} ${SAPISID} ${origin}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "Asynchronous specs", -> | |
funcRunInBackground = -> | |
value = 1 | |
wrapFuncRunInBackground = (done) -> | |
# setup for simmulating the async operation, a function run in the background | |
setTimeout -> | |
funcRunInBackground() | |
done() | |
, 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sync: ( method, collection, options ) -> | |
return Backbone.sync(method, collection, options) unless 'localStorage' in window | |
content = localStorage.getItem( @url() ) | |
if content and not navigator.onLine | |
options.success JSON.parse content | |
else | |
return Backbone.sync( method, collection, options ).done ( response ) => | |
localStorage.setItem( @url(), JSON.stringify( response ) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Rack | |
class EnforceValidEncoding | |
def initialize app | |
@app = app | |
end | |
def call env | |
full_path = (env.fetch('PATH_INFO', '') + env.fetch('QUERY_STRING', '')) | |
if full_path.valid_encoding? && Rack::Utils.unescape(full_path).valid_encoding? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Invisibility | |
def self.included base | |
base.send :attr_reader, :visible | |
end | |
def activate | |
@visible = false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function on() { | |
for (var i = 0, len = arguments.length - 1; i < len; i++) if (RegExp(arguments[i]).test(document.location.pathname)) { | |
arguments[len]() | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery._ajax = jQuery.ajax; | |
// jQuery.ajax = function(opts){ | |
// var self = this; | |
// return setTimeout(function(){ | |
// jQuery._ajax.call(self, opts); | |
// }, 2000); | |
// }; | |
// As if man :-) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
## | |
# alertme | |
# | |
# A simple delay timer to send a growl notification at specific time with a | |
# message. Useful for when you need to check on something later | |
# | |
# echo "Go look at system 42" | alertme in 2 hours | |
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Integer | |
def prime? | |
!("1" * self).match(/^1?$|^(11+?)\1+$/).nil? | |
end | |
end | |
class DHHException < Exception; end | |
raise DHHException, 'Whoops!' if !1.prime? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var table = $([ | |
'<table>', | |
'<thead>, | |
'<tr'>, | |
'<th>Foo</th>', | |
'<th>Bar</th>', | |
'</tr>', | |
'</thead>', | |
'<tfoot />', | |
'<tbody />' |
NewerOlder