Skip to content

Instantly share code, notes, and snippets.

View samccone's full-sized avatar
🐐

Sam Saccone samccone

🐐
  • Google
  • ∆∆∆<script>alert(prompt('why'))</script>
  • X @samccone
View GitHub Profile
@samccone
samccone / gist:4186853
Created December 2, 2012 03:39
83 char fizzbuzz in JS
for(i=0;i<100;++i){a="";!(i%3)&&(a+="fizz");!(i%5)&&(a+="buzz");console.log(a?a:i)}
@samccone
samccone / gist:4192296
Created December 3, 2012 02:47
active audio removal
var ctx = new window.webkitAudioContext();
var processor = ctx.createJavaScriptNode(512, 2, 1);
var url = 'http://static1.kevincennis.com/sounds/callmemaybe.mp3';
var audio = new Audio(url);
var micEnabled = false;
var songReady = false;
audio.addEventListener('canplaythrough', function() {
micEnabled && audio.play();
songReady = true;
@samccone
samccone / gist:4361346
Created December 22, 2012 21:40
using domains in node.js to catch errors at a single point
var domain = require('domain');
domain.create().on('error', function(error) {
console.log(error);
}).run(foo);
function foo() {
// async call.. will throw an error
zap();
}
generateLineInfo = (x, y) ->
x: x
y: y
xVelocity: Math.random() * 20 * (if (~~(Math.random() * 2) == 1) then -1 else 1)
yVelocity: Math.random() * 10 * (if (~~(Math.random() * 2) == 1)then -1 else 1)
window.onload = () ->
width = window.innerWidth
height = window.innerHeight
# within the router
initialize: () ->
@history = []
@bind 'all', @routeChange
routeChange: ->
if @history[@history.length - 1] != Backbone.history.fragment
@history.push Backbone.history.fragment
if @history.length == 2
// port from your server
req.protocol + '://' + req.host + ( port == 80 || port == 443 ? '' : ':'+port ) + req.path;
@samccone
samccone / gist:5026668
Last active December 14, 2015 04:09
chain JS pattern
function operation(prop, val) {
if (val) { obj[prop] = val; }
else { obj[prop](); }
return operation;
}
// now you can do operation('foo', '1')('saySomething')('zap bar', '123')
@samccone
samccone / gist:5034411
Created February 25, 2013 23:42
Run CasperJS tests on semaphoreapp.com
require 'open3'
namespace :casper do
namespace :test do
task :start_jasmine_runner => :environment do
Open3.popen3("rails s -p 5555")
# TODO MAKE THIS NOT BE A SIMPLE WAIT
sleep 30
puts "Rails + jasminerice started!"
end
@samccone
samccone / gist:5088204
Last active December 14, 2015 12:39
jokes for kids
what did the lamp say to the table
nice legs
what is a brit's favorite game?
teaball
what is a royal cow called?
sir loin
how do you cure a pig?
@samccone
samccone / gist:5108606
Last active December 14, 2015 15:29
Github randomly super zoomed in

1

See the browser is not zoomed in

2

chrome dev tools are even wacked out

3