Skip to content

Instantly share code, notes, and snippets.

<?php
// Pull from the db the list of channel names
$channels = array('music-for-japan-2011', '6819043', 'chelupa');
function live_channels($channels)
{
$live_channels = array();
$channels_string = implode(';', $channels);
$url = 'http://api.ustream.tv/php/channel/'.$channels_string.'/getinfo';
$ch = curl_init();
From fbd588741117556fd6f1b2ea59ebde87f39d72dc Mon Sep 17 00:00:00 2001
From: Gray Manley <[email protected]>
Date: Mon, 30 May 2011 21:04:20 -0500
Subject: [PATCH] index on master: db87927 Add check for duplicate short url
key.
---
app.rb | 10 ++++++-
lib/pagination_helper.rb | 43 +++++++++++++++++++++++++++
public/css/main.css | 73 ++++++++++++++++++++++++++++++++++++++++++++++
module IPGallery
class LegacyCategory
include DataMapper::Resource
storage_names[:default] = "gallery_categories"
has n, :albums, 'LegacyAlbum', child_key: [:category_id]
has n, :images, 'LegacyImage'
has n, :child_categories, self.name, child_key: [:parent]
@gmanley
gmanley / gist:1732830
Created February 3, 2012 21:38
Quick example of how to use backbone-rails
rvm use 1.9.3@rails_backbone_example --create
gem install rails
rails new rails_backbone_test --skip-bundle
cd rails_backbone_test
Add `gem 'rails-backbone'` to Gemfile
bundle
rails g backbone:install
rails g scaffold Post title:string content:string
rails g backbone:scaffold Post title:string content:string
rake db:migrate
@gmanley
gmanley / vim_notes.txt
Created February 19, 2012 08:28
VIM Notes
# Various notes relating to my switch vim
ctrl-o in insert mode to switches you to normal mode for one command
then back to insert mode.
Key Movement
h Left
l Right
k Up a line
@gmanley
gmanley / imgur_dl.rb
Created February 19, 2012 23:09
Concurrent imgur album downloader using typhoeus.
# encoding: UTF-8
# requires ruby 1.9.3 and up
# gem install nokogiri typhoeus
require 'nokogiri'
require 'typhoeus'
module Imgur
class AlbumDownloader
#(^|\s|\)|\(|\{|\}|>|\]|\[|href=\S)((http|https|news|ftp)://(?:[^<>\)\[\"\s]+|[a-zA-Z0-9/\._\-!&\#;,%\+\?:=]+))(</a>)?#
#(^|\s|\)|\(|\{|\}|>|\]|\[|href=\S)(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))(</a>)?#
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
rm -f ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
brew uninstall memcached
brew install https://raw.github.com/gist/2421766/1a210dbd360486631ff4fb22fd74a0eed5983d91/memcached.rb
cp /usr/local/Cellar/memcached/1.4.13/homebrew.mxcl.memcached.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
tail -f /usr/local/var/log/memcached.log
@gmanley
gmanley / gist:2469307
Created April 23, 2012 07:11
Regexp MatchData to_hash monkey patch
class MatchData
def to_hash
Hash[[names, captures].transpose]
end
alias :to_h :to_hash
end
@gmanley
gmanley / gist:2490296
Created April 25, 2012 14:48
Make rvmrc function!
function mkrvmrc () {
latest_ruby="$(rvm list strings | tail -n -1)"
echo "rvm $latest_ruby@$(basename $PWD) --create" > .rvmrc
source .rvmrc
}