Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
SLAYING BUGS

Wes Bos wesbos

🔥
SLAYING BUGS
View GitHub Profile
View gist:9253844
// Why do we use:
Math.floor(Math.random() * 6) + 1;
// vs
Math.ceil(Math.random() * 6);
View .zshrc
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
View gist:e442913d6e8955e9c7d1
30 mins a day * 5 days a week === 150 mins a week
150 mins a week * 50 working weeks === 7500 mins
7500 mins per year is 125 hours, or 3.125 weeks.
@wesbos
wesbos / server.coffee
Created Aug 12, 2011
Basic Socket.io Server
View server.coffee
io = require('socket.io').listen(4000)
io.sockets.on 'connection', (socket) ->
console.log('Connected!')
View scripts.coffee
# setup our application with its own namespace
App = {}
###
Init
###
App.init = ->
App.canvas = document.createElement 'canvas' #create the canvas element
App.canvas.height = 400
App.canvas.width = 800 #size it up
@wesbos
wesbos / index.html
Created Aug 12, 2011
Socket.io / Canvas Markup
View index.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.event.drag-2.0.js"></script>
<script src="http://localhost:4000/socket.io/socket.io.js"></script>
<script type="text/javascript" src="scripts.js"></script>
<link rel="stylesheet" href="style.css" />
@wesbos
wesbos / log.coffee
Created Aug 31, 2011
log - Coffeescript version of Paul Irish's log() Wrapper
View log.coffee
# Based on http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
# Converter to coffeescript by Wes Bos - http://wesbos.com
window.log = ->
log.history = log.history or []
log.history.push arguments
console.log Array::slice.call arguments if @console
return
View PulledPork.yuummy
Get a Pork Shoulder (called Pork but or picknick but/shoulder sometimes at the grocery store)
1. Cut the skin off the pork but and then trim most of the fat. Leaving some marbled fat is good b.c it melts away and adds to the favour
2. cover the pork but in normal yellow mustard. If you have dry mustard, that is fine too. I've used both.
3. prepare a "dry rub" which is just a bowl full of tons of spices. I include the following
-garlic salt
-normal salt
-paprika
@wesbos
wesbos / jsconf-hotel.html
Created Jan 26, 2012
$55/night Hotel for JSCONF 2012
View jsconf-hotel.html
If you were lucky enough to get a ticket to JSConf this year, you're probably in hotel mode.
The kimpton is quite fancy, but at $200/night, its a little expensive for my tastes.
So, after a little detective work, I've found a hotel a 5 min walk down the road from the conference for $55/night (give or take a few bucks) for three adults. The hotel is the scottsdale days inn (http://www.daysinnscottsdale.com/)
Here are the steps.
1. Go to http://hotwire.com and search 'scottsdale, AZ' and fill out the rest of the info. W
2. Find the "2-star Hotel in Scottsdale Old Town" it looks like this: http://wes.io/DfS0
@wesbos
wesbos / gist:1739883
Created Feb 4, 2012
PhantomJS Media Query Screenshot
View gist:1739883
var page = new WebPage(),
address, output, size;
address = "http://www.wesbos.com/";
width = 1024; height = 600;
output = "./screenshots/screenshot-"+width+"X"+height+".png";
page.viewportSize = { width: width, height: height };
if (phantom.args.length === 3 && phantom.args[1].substr(-4) === ".pdf") {