Skip to content

Instantly share code, notes, and snippets.

View danro's full-sized avatar
👀

Dan Rogers danro

👀
View GitHub Profile
@danro
danro / github_tree_slider.js
Created September 29, 2011 21:33 — forked from ryanb/github_tree_slider.js
This is how GitHub's new AJAX file browser works.
GitHub.TreeSlider = function () {
if (window.history && window.history.pushState) {
function a() {
if (e.sliding) {
e.sliding = false;
$(".frame-right").hide();
$(".frame-loading:visible").removeClass("frame-loading")
}
}
if (!($("#slider").length == 0 || !GitHub.shouldSlide)) if (!navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
@danro
danro / twitter-text.js
Created October 14, 2011 17:35
Parse links & usernames in twitter text.
// parses the text in a tweet and adds links to users, hash tags and urls
parseTweet: function (text) {
// parse urls
text = text.replace(/[A-Za-z]+:\/\/[A-Za-z0-9_-]+\.[A-Za-z0-9_:%&~\?\/.=-]+/g, function(url) {
return url.link(url)
})
// parse usernames
text = text.replace(/[@]+[A-Za-z0-9_-]+/g, function(u) {
var username = u.replace("@","")
return u.link("http://twitter.com/"+username)
@danro
danro / pretty-date.js
Created October 16, 2011 06:45
JavaScript Pretty Date
/*
* JavaScript Pretty Date
* Copyright (c) 2008 John Resig (jquery.com)
* Licensed under the MIT license.
*/
// Takes an ISO time and returns a string representing how
// long ago the date represents.
// modified to return DD MM format instead of undefined.
@danro
danro / twitter-date.js
Created October 18, 2011 20:02
Twitter date string regex replace, IE8 fix
var s = "Fri Apr 09 12:53:54 +0000 2010";
var date = new Date(s.replace(/^\w+ (\w+) (\d+) ([\d:]+) \+0000 (\d+)$/, "$1 $2 $4 $3 UTC"));
// Cross-browser, time-zone-aware parsing via JavaScript:
// Tested on IE, Firefox, Safari, Chrome and Opera.
@danro
danro / ua-sniff.js
Created October 26, 2011 00:37
Mobile UA sniffing (evil)
// with iPad
navigator.userAgent.match(/mobile|iphone|ipod|blackberry|android|palm|windows\s+ce/i)
// without iPad
navigator.userAgent.match(/iphone|ipod|blackberry|android|palm|windows\s+ce/i)
@danro
danro / HideMobileAddressBar.js
Created October 28, 2011 17:58 — forked from mhammonds/HideMobileAddressBar.js
Hide Browser Address Bar - Android + iPhone
function configAddressBar (addHeight) {
var defaultHeight = 50;
if (typeof addHeight == "undefined") addHeight = 1;
function hideAddressBar() {
if(!window.location.hash)
{
if(document.height < window.outerHeight)
{
document.body.style.height = (window.outerHeight + defaultHeight + addHeight) + 'px';
}
@danro
danro / ah-my-eyes.sh
Created October 30, 2011 01:18
Disable anti-aliasing in Titanium Studio
# disable font smoothing / anti aliasing in Titanium Studio
defaults write com.appcelerator.titanium AppleAntiAliasingThreshold 20
@danro
danro / blah.js
Created October 31, 2011 00:00 — forked from atypical/blah.js
Read and Clean
function parseTheDashboardData(resp){
var httpStatus = resp.meta.status,
httpMessage = resp.meta.msg,
dashboardPostsArray = resp.response.posts;
for (var i = 0; i < dashboardPostsArray.length; i++){
var current=dashboardPostsArray[i];
var blogName = current.blog_name
, blogID = current.id
@danro
danro / ajax-preload.js
Created October 31, 2011 17:27
Ajax preload w/ images
$.ajax({
...
success: function(data) {
var imageCount = $(data).filter('img').length;
var imagesLoaded = 0;
$(data).hide()
.appendTo('#someDiv')
.filter('img')
.load( function() {
++imagesLoaded;
@danro
danro / README.md
Created November 4, 2011 01:48 — forked from gasi/README.md
Node & npm Installation Instructions

Node

Installation

git clone https://github.com/joyent/node.git
cd node/
git checkout v0.4.5 # or any other version you'd like
./configure --debug
make install