Skip to content

Instantly share code, notes, and snippets.

@rweald
rweald / Thumbnail to Video
Created February 9, 2011 22:15
A simple script that replicates the Mac Finder UI that allows you to swap a thumbnail for a video when a play button is clicked.
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Test Page</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.thumbnail').bind("mouseenter", function(){
$(this).append('<img class="play_button" src="http://www.hamptonbid.com/17BullRun.com/play-button_png_1058132788.png" />');
@rweald
rweald / simple_rspec_watchr.rb
Created March 29, 2011 18:15
This is a simple script that will run spec test suite for files in lib directory. Ideal for testing a gem
We couldn’t find that file to show.
@rweald
rweald / gist:969981
Created May 13, 2011 04:42
Multi-threaded Non blocking file uploads using EventMachine and EM-Http-Request
#!/usr/bin/env ruby
require 'em-http-request'
require 'fiber'
require "ruby-debug"
class AsynUploader
@successes = []
@failures = []
@rweald
rweald / jammit.rake
Created June 1, 2011 19:58
Using Barista with Jammit to package and compile CoffeeScript
# simply run rake jammit:package to compile your coffeescript and then package up all your assets
# including the newly compiled javascripts
namespace :jammit do
task :package do
Rake::Task["barista:brew"].invoke
Jammit.package!
end
end
require 'em-synchrony'
require 'em-synchrony/em-http'
require 'em-synchrony/em-jack'
require 'nokogiri'
module MendeleyScraper
class MasterScraper
# get all the necessary urls from the mendeley sitemap
# this opperation appear sync due to fibers
@rweald
rweald / gist:1149468
Created August 16, 2011 16:22
Custom GVim config without peepopen
if has("gui_macvim")
" Fullscreen takes up entire screen
set fuoptions=maxhorz,maxvert
" Command-T for CommandT
macmenu &File.New\ Tab key=<D-T>
map <D-t> :CommandT<CR>
imap <D-t> <Esc>:CommandT<CR>
" Command-Return for fullscreen
@rweald
rweald / goliath_redis_server_sent_events.rb
Created September 25, 2011 22:47
A simple Goliath server that sends data to client using SSE after receiving a message on a redis pubsub channel
require 'goliath'
require 'em-hiredis'
class EventGenerator < Goliath::API
def response(env)
redis = EM::Hiredis.connect
redis.subscribe(:one)
@rweald
rweald / gist:1251481
Created September 29, 2011 18:16
Installing Git on UCSD cs lab accounts
  1. Download the latest version of the git source
curl -O http://git-core.googlecode.com/files/git-1.7.6.4.tar.gz
  1. unpack git source
tar -xzf git-1.7.6.4.tar.gz
@rweald
rweald / gist:1274276
Created October 9, 2011 22:12
How Twitter configures a tweet button with only markup
<script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
<div>
<a href="https://twitter.com/share" class="twitter-share-button"
data-url="https://dev.twitter.com/pages/tweet_button"
data-via="your_screen_name"
data-text="Checking out this page about Tweet Buttons"
data-related="anywhere:The Javascript API"
data-count="vertical">Tweet</a>
</div>
@rweald
rweald / gist:1301763
Created October 20, 2011 17:40
Way to get colored bash prompt based on git status
#configuration for my bash prompt
prompt_function() {
local BLACK='\[\033[0;30m\]'
local LIGHT_BLACK='\[\033[1;30m\]'
local RED='\[\033[0;31m\]'
local LIGHT_RED='\[\033[1;31m\]'
local GREEN='\[\033[0;32m\]'
local LIGHT_GREEN='\[\033[1;32m\]'
local YELLOW='\[\033[0;33m\]'
local LIGHT_YELLOW='\[\033[1;33m\]'