Skip to content

Instantly share code, notes, and snippets.

View barberj's full-sized avatar

Justin Barber barberj

  • Atlanta, Ga
  • 00:26 (UTC -04:00)
View GitHub Profile

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@tsoporan
tsoporan / gist:2764350
Created May 21, 2012 20:08
Twitter Access Token /w Flask & Rauth
from flask import Flask, request, redirect, url_for
from rauth.service import OAuth1Service
twitter = OAuth1Service(
name='twitter',
consumer_key='TWITTER KEY',
consumer_secret='TWITTER SECRET',
request_token_url = 'https://api.twitter.com/oauth/request_token',
access_token_url = 'https://api.twitter.com/oauth/access_token',
authorize_url = 'https://api.twitter.com/oauth/authorize',
@devnoo
devnoo / doctor.erl
Created July 19, 2012 18:52
seven languages in seven weeks erlang day 3
-module(doctor).
-behaviour(supervisor).
-export([start/0]).
-export([init/1]).
start() ->
supervisor:start_link({local, doctor}, doctor, []).
init(_Args) ->
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 25, 2024 08:07
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@kennethreitz
kennethreitz / pr.md
Created September 12, 2012 20:56 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@pgeraghty
pgeraghty / rails_admin.rb
Last active December 7, 2023 15:22
Add Delayed Job to Rails Admin (make it visible as a model)
RailsAdmin.config do |config|
config.included_models = RailsAdmin::Config.models_pool << 'Delayed::Job'
config.model Delayed::Job do
label 'Task'
navigation_label 'Background Processing'
end
end
@elkelk
elkelk / DeleteSimpleDBDomains
Created October 30, 2013 18:41
Delete AWS simpleDB development domains (assuming you use "Dev" in the name).
AWS::SimpleDB.new.domains.select{|d| d.name.include? "Dev"}.map{|d| d.delete! }
@dhoelzgen
dhoelzgen / base_controller.rb
Last active October 7, 2021 16:19
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
@mlanett
mlanett / rails http status codes
Last active July 22, 2024 09:14
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@synth
synth / add_signature_fields_to_delayed_jobs.rb
Last active November 21, 2023 10:03
Prevent Duplicates with Delayed Jobs
class AddFieldsToDelayedJobs < ActiveRecord::Migration
def change
add_column :delayed_jobs, :signature, :string
add_column :delayed_jobs, :args, :text
end
end