Skip to content

Instantly share code, notes, and snippets.

View tonyc's full-sized avatar
💭
wondering why github decided to add a user status

Tony Collen tonyc

💭
wondering why github decided to add a user status
View GitHub Profile
export ANSI_NORMAL="\[\e[0;37m\]"
export ANSI_YELLOW="\[\e[1;33m\]"
export ANSI_RESET="\[\e[0m\]"
export ANSI_CYAN="\[\e[0;36m\]"
export ANSI_BLUE="\[\e[0;34m\]"
export PS1="($ANSI_CYAN\u$ANSI_YELLOW@$ANSI_CYAN\h$ANSI_RESET):\w\$ "
@tonyc
tonyc / bates.css
Created June 3, 2011 18:40 — forked from markoa/bates.css
CSS file as seen on Railscasts
body {
background-color: #4B7399;
font-family: Verdana, Helvetica, Arial;
font-size: 14px;
}
a img {
border: none;
}
@tonyc
tonyc / sections_controller.rb
Created June 7, 2011 15:29 — forked from marcelloma/sections_controller.rb
decent_exposure + meta_search + cancan
class SectionsController < ApplicationController
load_and_authorize_resource
expose(:section)
expose(:sections) { search.paginate(:page => params[:page]) }
expose(:search) { Section.search(params[:search]) }
def create
if section.save
@tonyc
tonyc / Japanese style
Created August 25, 2011 16:35 — forked from endolith/Has weird right-to-left characters.txt
Unicode smileys emoticons
⨀_⨀
⨂_⨂
(/◔ ◡ ◔)/
°ﺑ°
(¬_¬)
(´・ω・`)
(ʘ_ʘ)
(ʘ‿ʘ)
(๏̯͡๏ )
(◕_◕)
@tonyc
tonyc / 001_postgresql_adapter_patches.rb
Created September 14, 2011 15:53
Sequence support in PostgreSQL
require 'active_record/base'
require 'active_record/connection_adapters/abstract_adapter'
require 'active_record/connection_adapters/postgresql_adapter'
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter < AbstractAdapter
def next_sequence_value(sequence_name)
Integer(select_value("SELECT NEXTVAL('#{sequence_name}')"))
end
@tonyc
tonyc / gist:1384523
Last active February 6, 2023 04:05
Using strace and lsof

Using strace and lsof to debug blocked processes

You can use strace on a specific pid to figure out what a specific process is doing, e.g.:

strace -fp <pid>

You might see something like:

select(9, [3 5 8], [], [], {0, 999999}) = 0 (Timeout)

@tonyc
tonyc / gist:1405605
Created November 29, 2011 17:23
nginx init.d script for debian
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@tonyc
tonyc / cancan_exposure.rb
Created December 16, 2011 22:05 — forked from mrmemes-eth/cancan_exposure.rb
A default exposure for decent_exposure that assigns instance variables (to make cancan happy)
default_exposure do |name|
collection = name.to_s.pluralize
if respond_to?(collection) && collection != name.to_s && send(collection).respond_to?(:scoped)
proxy = send(collection)
else
proxy = name.to_s.classify.constantize
end
instance_variable_set("@#{name}") = if id = params["#{name}_id"] || params[:id]
proxy.find(id).tap do |r|
require 'active_record/base'
require 'active_record/connection_adapters/abstract_adapter'
require 'active_record/connection_adapters/postgresql_adapter'
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter < AbstractAdapter
def next_sequence_value(sequence_name)
Integer(select_value("SELECT NEXTVAL('#{sequence_name}')"))
end
<form id="addSpeaker">
<fieldset>
<legend>Speaker Info</legend>
Name: <input type="text" id="name" /> <br />
Bio: <textarea id="bio"></textarea> <br />
Twitter Handle: <input type="text" id="twitterHandle" /> <br />
State: <input type="text" id="state" /> <br />
Photo Url: <input type="text" id="photoUrl" />
</fieldset>
<fieldset>