Skip to content

Instantly share code, notes, and snippets.

View dawnerd's full-sized avatar
🌮

Troy Whiteley dawnerd

🌮
View GitHub Profile
@dawnerd
dawnerd / news.css
Created November 10, 2011 23:44
short Ticker.js
#news { background: #666; color: #fff; padding: 4px 0; width: 100%; height: 30px; line-height: 30px; overflow: hidden; }
#news .container { float: left; }
#news .overflow { width: 900000px; }
#news .item { padding: 0 20px; }
@dawnerd
dawnerd / style.css
Created November 11, 2011 02:47
Just The Tip (The tooltip that is)
.TooltipContainer { position: absolute; z-index: 100; font-size: 10px; display: none; background: #333; color: #fff; -moz-border-radius: 3px; -webkit-border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; border-radius: 3px; box-shadow: 0 2px 5px 0 rgba(0,0,0, .4); }
.TooltipContainer .arrow { position: absolute; bottom: -4px; left: 15px; z-index: 1950; background: #333; height: 10px; width: 10px; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); }
.TooltipContainer .content { padding: 5px; position: relative; z-index: 2000; }
@dawnerd
dawnerd / gitprompt.sh
Created December 14, 2011 18:36
gitprompt
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
then
gitver=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
@dawnerd
dawnerd / parseTweet.js
Created December 16, 2011 02:38
Parse Tweet text
function parseTweet(text) {
return text.replace(/[\w]+:\/\/[\w\d-]+\.[\w\d-:%&~\?\/.=]+/gi, function(url) {
return url.link(url);
}).replace(/[@]+[\w\d-]+/gi, function(u) {
return u.link("http://twitter.com/"+u.replace("@",""));
}).replace(/[#]+[\w\d-]+/gi, function(t) {
return t.link("http://search.twitter.com/search?q="+t.replace("#","%23"));
});
}
var easings = {
bacon: function(pos) {
return 1 - (Math.cos(pos * 2 * Math.PI) * Math.exp(-pos * 5));
}
};
var foo = Math.PI;
Number(foo);
parseInt(foo, 10);
var foo = Math.PI;
//Most common
Math.floor(foo);
//Double bitwise NOT
~~foo;
//Bitwise OR
foo | foo;
function reverse(input){
return '‮'+input;
}
document.body.innerHTML = reverse('this is a test')
@dawnerd
dawnerd / debounce.txt
Created April 9, 2012 21:13
Debounce JS programming challenge
Debounce
Debouncing is a way of ensuring that a function is only called once when fired multiple times in a short period. Almost all keyboards have some form of built in debouncing since the keys will hit the sensor quite a few times per keystroke. For keyboards, the delay is somewhere around 50ms.
In Javascript, debouncing is important for rapidly firing events, such as text input. Instead of firing a keydown event and processing input data on every keypress, you fire the event once after no more keypresses are detected in a certain amount of time.
--
Scoring:
1 point for correctly working solution
@dawnerd
dawnerd / debounce.html
Created April 10, 2012 00:07
debounce solution
<html>
<body onload="onLoad()">
<script>
function onLoad(){
var UserInput = document.getElementById('UserInput');
var UserOutput = document.getElementById('UserOutput');
//YOUR CODE HERE
Function.prototype.debounce = function(delay_period) {