Skip to content

Instantly share code, notes, and snippets.

View somebox's full-sized avatar
⌨️
coding nights

Jeremy Seitz somebox

⌨️
coding nights
View GitHub Profile
@somebox
somebox / README
Created September 20, 2011 23:47 — forked from indirect/README
Update WebKit nightly
To use this:
1. check out the gist somewhere
2. edit the plist to contain the path to the .rb file
3. run this:
chmod +x update-webkit.rb
launchctl load com.indirect.update-webkit.plist
@somebox
somebox / jquery.disable.js
Created September 20, 2011 11:42
jQuery snippet to make page elements unselectable (disable highlights)
/* disable user selections */
jQuery.fn.disableSelection = function(){
$(this).each(function(){
$(this).attr('unselectable', 'on')
.css('-moz-user-select', 'none')
.each(function() {
this.onselectstart = function() { return false; };
});
});
function debug(){
if (typeof console != "undefined"){
if (console.log){
if (arguments.length == 1){
console.log(arguments[0]);
} else {
console.log(arguments);
}
}
}
@somebox
somebox / gh-like.css
Created July 14, 2011 14:55
github markdown css+script with syntax highlighting. Works with http://markedapp.com
/*
Some simple Github-like styles, with syntax highlighting CSS via Pygments.
*/
body{
font-family: helvetica, arial, freesans, clean, sans-serif;
color: #333;
background-color: #fff;
border: none;
line-height: 1.5;
margin: 2em 3em;
@somebox
somebox / gist:1077974
Created July 12, 2011 13:25
DN Music App
The Democracy Now! music site will allow independent artists to submit original works for sharing with
other DN listeners, and potentially to be used as music on the show.
This is to be a standalone site, built in Rails 3. Users can fill out a form and upload a track.
After processing, they will receive and email containing a confirmation that the track was received,
and a link to the track on DN's site. By using this link, they can go to check for airplay, or
to request that a track be removed.
Home Page
Notices/Info/Events
@somebox
somebox / backbone.rails.js
Created June 30, 2011 10:42 — forked from trydionel/backbone.rails.js
Makes Backbone.js with Rails+CSRF
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.
@somebox
somebox / backbone.rails.js
Created June 30, 2011 00:59
Makes Backbone.js play nicely with default Rails setup
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- example at http://somebox.com/canvas-fun.html -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="http://ajax.cdnjs.com/ajax/libs/ocanvas/1.0/ocanvas.min.js"></script>
<title>Canvas Experiment</title>
<script type="text/javascript">
/*
@somebox
somebox / base_controller.rb
Created April 4, 2011 16:59
Authenticate in Rails with super-simple HTTP Auth.
class Admin::BaseController < ApplicationController
before_filter :authenticate
# ...
private
def authenticate
return true if Rails.env.development?
authenticate_or_request_with_http_basic do |id, password|
@somebox
somebox / timezone.js
Created November 21, 2010 22:35
Get the user's timezone
// script by Josh Fraser (http://www.onlineaspect.com)
// modded by Jeremy Seitz to only return offset as integer
function calculate_time_zone() {
var rightNow = new Date();
var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); // jan 1st
var june1 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0); // june 1st
var temp = jan1.toGMTString();
var jan2 = new Date(temp.substring(0, temp.lastIndexOf(" ")-1));
temp = june1.toGMTString();