Skip to content

Instantly share code, notes, and snippets.

View kathgironpe's full-sized avatar

Katherine Giron Pe kathgironpe

  • SEA
  • 15:21 (UTC +08:00)
View GitHub Profile
@maxschulze
maxschulze / html_aware_truncate_helper.rb
Created June 5, 2011 19:55
HTML Aware truncate for Ruby / Rails using nokogiri
# Source:
# http://blog.madebydna.com/all/code/2010/06/04/ruby-helper-to-cleanly-truncate-html.html
require "rubygems"
require "nokogiri"
module TextHelper
def truncate_html(text, max_length, ellipsis = "...")
ellipsis_length = ellipsis.length
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@senko
senko / gist:1112574
Created July 28, 2011 21:14
DOM text search/replace plugin for jQuery.
(function($){
$.fn.textReplace = function(map, patterns) {
map = map || {};
patterns = patterns || [];
$('*', this).contents().filter(function() {
return ((this.nodeType == 3));
}).each(function() {
var old_text = $.trim(this.nodeValue);
var new_text;
@kirs
kirs / gist:1180272
Created August 30, 2011 05:51
NginX config for Rails 3.1 & Unicorn
upstream example_backend {
server unix:/var/www/example.com/shared/unicorn.sock;
}
server {
listen 80;
server_name example.com www.example.com;
access_log off;
error_log off;
client_max_body_size 20M;
@dbrgn
dbrgn / Usage Example
Created September 7, 2011 13:48
A bash script to grep files in a specified directory and to replace values using sed
$ git status
# On branch master
nothing to commit (working directory clean)
$ find_replace.sh "TODO" "s/TODO/REMEMBER/g" apps/
Command: egrep -lrZ --binary-files=without-match "TODO" "/home/user/apps/" | xargs -0 -l sed -i -e "s/TODO/REMEMBER/g"
Really execute (y/n)? y
[danilo@dev5 db]$ git status
# On branch master
@quinn
quinn / elasticsearch-install.sh
Created October 15, 2011 14:53
install elasticsearch on ubuntu
sudo apt-get install openjdk-6-jre-headless
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.17.6.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-0.17.6 elasticsearch
sudo mv elasticsearch /usr/local/share
wget http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master -O - | tar xz
mv elasticsearch-elasticsearch-servicewrapper-3e0b23d/service /usr/local/share/elasticsearch/bin/
rm -rv elasticsearch-elasticsearch-servicewrapper-3e0b23d/
sudo /usr/local/share/elasticsearch/bin/service/elasticsearch install
@tsabat
tsabat / zsh.md
Last active April 21, 2025 07:22
Getting oh-my-zsh to work in Ubuntu
@kagemusha
kagemusha / gist:1569836
Created January 6, 2012 09:20
Dump Heroku Postgres DB and load locally
Get the Heroku db as detailed here:
http://devcenter.heroku.com/articles/pgbackups#exporting_via_a_backup
1. heroku pgbackups:capture
2. heroku pgbackups:url <backup_num> #=>backup_url
- get backup_num with cmd "heroku pgbackups"
3. curl -o latest.dump <backup_url>
Then locally do:
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump
@mislav
mislav / readme.md
Created January 25, 2012 14:42
CLI tool that checks the build status of current branch on Travis CI

Check build status of a project on the command line

Install (copy & paste):

curl -sL raw.github.com/gist/1676577/travis.rb > ~/bin/travis \
  && chmod +x ~/bin/travis

gem install hub | tail -2
ruby -e 'require "json"' 2&gt;/dev/null || gem install json
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.