Skip to content

Instantly share code, notes, and snippets.

View brandondrew's full-sized avatar

Brandon Zylstra brandondrew

  • UC Berkeley
  • the tubes
View GitHub Profile
require 'feedzirra'
# fetching a single feed
feed = Feedzirra::Feed.fetch_and_parse("http://feeds.feedburner.com/PaulDixExplainsNothing")
# feed and entries accessors
feed.title # => "Paul Dix Explains Nothing"
feed.url # => "http://www.pauldix.net"
feed.feed_url # => "http://feeds.feedburner.com/PaulDixExplainsNothing"
feed.etag # => "GunxqnEP4NeYhrqq9TyVKTuDnh0"
require 'rubygems'
require 'activerecord'
ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:host => 'localhost',
:username => 'root',
:database => 'craigslist'
)
require 'sinatra/base'
run Sinatra.new {
get('/') do
content_type "text/plain" # you can also use Rack::ContentType
# with Sinatra except here we want
# more control since Sinatra gives it
# to us. Rack::ContentType sets the
# Content-Type on every route/url for
# the current mapping.
#!/bin/bash
###########################################################
# TRIBUNE-SPECIFIC BUILD HOME script:
# This script sets up your home directory fast with basic
# necessities and amenities, to give you sanity when you
# work on a Unix box where you don't have root access.
###########################################################
# TO USE:
# curl https://raw.github.com/gist/259348/build_home.sh | bash
# OR:
@brandondrew
brandondrew / beanstalkd-macports-1.4.6_1.txt
Created September 30, 2011 00:50
How to fix beanstalkd 1.4.6 compile error (MacPorts)
Just a informational gist if you plan to install "beanstalkd" via MacPorts and get a compiler error:
:info:build net.c: In function 'make_server_socket':
:info:build net.c:35: warning: 'fd' may be used uninitialized in this function
:info:build make[1]: *** [net.o] Error 1
:info:build make[1]: *** Waiting for unfinished jobs....
This is a known issue within the "net.c" file. I've found a diff[1] for said file on the web and applied it locally which then allowed me to install the port without problems.
If your install fails like:
@jpmckinney
jpmckinney / twitter-bootstrap-ie6.scss
Created November 14, 2011 23:31
SCSS additions to make Twitter Bootstrap work in IE6
// Assumes you are using <html> conditional classes as described here:
// http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
.lt-ie7 {
// blockquote small:before{content:'\2014 \00A0';}
blockquote small:before{content:"";}
// [class*="span"]{display:inline;float:left;margin-left:20px;}
.span1{display:inline;float:left;margin-left:20px;}
.span2{display:inline;float:left;margin-left:20px;}
.span3{display:inline;float:left;margin-left:20px;}
.span4{display:inline;float:left;margin-left:20px;}
@josephg
josephg / saver.coffee
Created November 5, 2011 13:56
Script to automatically re-save a sharejs document as its edited.
# This script watches for changes in a document and constantly resaves a file
# with the document's contents.
#
# Usage: coffee saver.coffee -d <DOCNAME> [--url http://somehost:8000/sjs] [-f filename]
client = require('share').client
fs = require('fs')
argv = require('optimist')
.usage('Usage: $0 -d docname [--url URL] [-f filename]')
@stoft
stoft / orient_connector.ex
Last active December 10, 2015 15:48
Basic OrientDB HTTP/REST backend to Phoenix web framework
defmodule Phtest.OrientConnector do
use Jazz
@base_url "http://localhost:2480/"
@database "Phtest"
@user "admin"
@password "admin"
@basic_auth [basic_auth: {@user, @password}]
def get(document_id, type) do
OrientConnector.get_document(document_id)
require 'serverspec'
require 'pathname'
require 'net/ssh'
include Serverspec::Helper::Ssh
include Serverspec::Helper::DetectOS
RSpec.configure do |c|
if ENV['ASK_SUDO_PASSWORD']
require 'highline/import'
describe "GET current" do
before do
@request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}"
get :current, :format => 'js'
end
it { should respond_with(:success) }
it { should set_cookie(:hidden_notices).to("#{notices(:permanent).id}") }
it { should render_template('notices/current') }
end