Skip to content

Instantly share code, notes, and snippets.

View edwinwebb's full-sized avatar

Edwin Webb edwinwebb

View GitHub Profile
@edwinwebb
edwinwebb / bulk rename
Created October 26, 2011 13:13
Rename files in directory to 1,2 ... 11,12 ... 102,103
j=0; for i in *.png; do ((j = $j+1)); k=$j".png"; mv $i $k; done
@edwinwebb
edwinwebb / secondsToTimeString
Created November 18, 2011 16:07
Javascript Media Seconds to MM:SS:MS string
secondsToTimeString = function (seconds) {
var ms = Math.floor((seconds*1000) % 1000);
var s = Math.floor(seconds%60);
var m = Math.floor((seconds*1000/(1000*60))%60);
var strFormat = "MM:SS:XX";
if(s < 10) s = "0" + s;
if(m < 10) m = "0" + m;
if(ms < 10) ms = "0" + ms;
@edwinwebb
edwinwebb / equivalent.js
Created July 30, 2012 22:37 — forked from tj/equivalent.js
example of backbone-style routing with Express
app.get('/help', function(req, res){
res.send('some help');
});
app.get('/search/:query/p:page', function(req, res){
var query = req.params.query
, page = req.params.page;
res.send('search "' + query + '", page ' + (page || 1));
});
@edwinwebb
edwinwebb / gist:4024311
Created November 6, 2012 12:15
raty loop
$.fn.raty.defaults.click = function(s,e) {
$(this).siblings(".text").text(s);
};
<div class="star"></div><p class="text"></p>
$(".star").each(function(i) {
var target = $(this);
target.raty({scoreName: "score" + i})
@edwinwebb
edwinwebb / bootstrap-login
Created November 20, 2012 15:32
Bootstrap Login form
<form action="/login" method="post" class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputEmail">Email:</label>
<div class="controls">
<input type="email" name="email" placeholder="someone@example.com" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="password">Password</label>
<div class="controls">
http://blog.jonnay.net/archives/423-More-ASCII-Bunnies..html
(\(\
( - -)
((') (')
(\_/)
('.')
(')(')
@edwinwebb
edwinwebb / gist:5143085
Created March 12, 2013 14:00
Small function for leading 0s
function (a,b){return(1e15+a+"").slice(-b)}
@edwinwebb
edwinwebb / gist:5143089
Created March 12, 2013 14:00
Small function for leading 0s
function (a,b){return(1e15+a+"").slice(-b)}
@edwinwebb
edwinwebb / simpleserver.sh
Created March 12, 2013 14:45
Simple Python Server
#!/bin/bash
python -m SimpleHTTPServer
@edwinwebb
edwinwebb / jquery.number.animation.js
Created March 13, 2013 08:51
Animate numbers with JQuery animate. Useful for animating updates to numbers.
jQuery.Animation(
{'test' : 0}, // 'element'
{'test' : 100}, // match props in 'element'
{
duration:100, //standard options
step : function(a) {
console.log(a); //step
}
}
);