Skip to content

Instantly share code, notes, and snippets.

View ryanmcgrath's full-sized avatar
💭
==bG9s

Ryan McGrath ryanmcgrath

💭
==bG9s
View GitHub Profile
@ryanmcgrath
ryanmcgrath / hack.sh
Created March 31, 2012 18:21 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@ryanmcgrath
ryanmcgrath / renew_dhcp_lease_4_mins.rb
Created March 18, 2012 22:35
Renew a DHCP lease every 4 minutes. Don't ask.
while true do
system "ipconfig set en1 DHCP"
puts "Renewed DHCP Lease...\n"
sleep 60 * 4
end
@ryanmcgrath
ryanmcgrath / gist:2054634
Created March 17, 2012 03:08
Swap this in PhoneGap/Callback iOS apps, stops rubberbanding effects at native level instead of JS crap.
- (void)webViewDidStartLoad:(UIWebView *)theWebView
{
for (id subview in theWebView.subviews)
if ([[subview class] isSubclassOfClass: [UIScrollView class]]) {
((UIScrollView *)subview).bounces = NO;
((UIScrollView *)subview).showsVerticalScrollIndicator = NO;
}
return [ super webViewDidStartLoad:theWebView ];
}
@ryanmcgrath
ryanmcgrath / ajax_breakdown.js
Created January 21, 2012 14:02
$.ajax breakdown for cross-domain requests.
// An AJAX query is broken down like this...
$.ajax({
// This means we're going to pull data; if you're
// creating something new on the server, this'll be POST
type: "GET",
// This tells jQuery to use a cross-domain fetching trick
dataType: "jsonp",
// The BASE URL we want to query data from
@ryanmcgrath
ryanmcgrath / mygengo_api_drupal.php
Created January 20, 2012 11:21
Hitting the myGengo API from within Drupal.
<?php
// ...
// Use like...
// $this->requestFromGengo('translate/service/languages', 'GET');
// $this->requestFromGengo('translate/job', 'GET', array(
// 'id' => 1
// ));
// ...
@ryanmcgrath
ryanmcgrath / fasdfhd.js
Created November 4, 2011 06:58
fasdfasdafsd
$('.blog-post-content').find('img').each(function() {
$(this).parent().mouseover(function() {
$(this).find('span').fadeIn('slow');
}).mouseout(function() {
$(this).find('span').fadeOut('fast');
}).css({'position': 'relative'}).append(function() {
return $('<span>This is an Attribution</span>').css({
'background-color': '#333',
'position': 'absolute',
'bottom': '0',
@ryanmcgrath
ryanmcgrath / decorators.py
Created October 26, 2011 08:54
An arguably nicer and less verbose way to handle defining view files in Django.
# -*- coding: utf-8 -*-
from django.shortcuts import render
def template(template_path, content_type = 'text/html'):
"""
A Decorator that simplifies a lot of Django view-related cruft, in
regards to rather verbose view serving.
This needs some optimization. This currently caches nothing.
@ryanmcgrath
ryanmcgrath / GitHubCommit.html
Created October 16, 2011 18:14
An example of how to use githubcommitembed.js to fetch data for a given commit from GitHub.
<!-- May want a pre/code tag combo here -->
<div id="code_block"></div>
<script type="text/javascript" src="path/to/githubcommitembed.min.js"></script>
<script type="text/javascript">
// Create a new commit to fetch; .fetch() actually fires calls (below).
var commit = new GitHubCommit({
username: 'mygengo',
reponame: 'mygengo-python',
fileSHA: 'cbb0816e1fb873019d8617500e4562299663bf4f',
@ryanmcgrath
ryanmcgrath / loader.css
Created September 6, 2011 21:55
HTML and CSS for a CSS3 (mobile-OS hardware accelerated) loading spinner.
#spinnerContainer {
display: none;
position: absolute;
top: 340px;
right: 350px;
width: 54px;
height: 54px;
}
#spinner {
@ryanmcgrath
ryanmcgrath / $.js
Created September 2, 2011 08:17
Mobile friendly easy as pie $().
var $ = window.$ = function $(selector) {
if(/^#[a-zA-Z_\-]+$/.test(selector))
return document.getElementById(selector.substr(1, selector.length));
return Array.prototype.slice.call(document.querySelectorAll(selector));
};