Skip to content

Instantly share code, notes, and snippets.

View Gemfile
gem 'omniauth'
gem 'omniauth-facebook'
gem 'clearance'
View rails_switch_branch.py
#!/usr/local/bin/python
"""
To use this script, you must be in the root directory of a Rails project that
is using git. You should also make sure that your directory does not contain any
uncommitted changes. Then run:
$ python rails_switch_branch.py name_of_another_branch
Running the above will do the following:
@bashcoder
bashcoder / vim-ruby-folding-1.1.vim
Created Oct 24, 2013
vim ruby folding for methods
View vim-ruby-folding-1.1.vim
" FoldSearch-based folding.
" Copyright (C) 2005 Mauricio Fernandez <mfp@acm.org>
" Current version: http://eigenclass.org/hiki.rb?Usable+Ruby+folding+for+Vim
"
" Add this to your .vimrc and fold with :R. The default fold expression will
" work with Ruby scripts; you can specify where folds start with
" let b:foldsearchexpr = 'myexpression'
" e.g.
" let b:foldsearchexpr='\(^\s*\(\(private\|public\|protected\|class\)\s\)\)'
" or so for Java.
View es.sh
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.5.deb
sudo dpkg -i elasticsearch-0.90.5.deb
@bashcoder
bashcoder / switch_to_test
Created Sep 23, 2013
From my .vimrc, switch between test and production code with `<leader>.`
View switch_to_test
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" SWITCH BETWEEN TEST AND PRODUCTION CODE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! OpenTestAlternate()
let new_file = AlternateForCurrentFile()
exec ':e ' . new_file
endfunction
function! AlternateForCurrentFile()
let current_file = expand("%")
let new_file = current_file
View iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
@bashcoder
bashcoder / .gemrc
Created Aug 13, 2013
My ~/.gemrc file, which disables documentation during gem updates and installs.
View .gemrc
install: --no-rdoc --no-ri
update: --no-rdoc --no-ri
View s3-file.rb
#
# Author:: Christopher Peplin (<peplin@bueda.com>)
# Copyright:: Copyright (c) 2010 Bueda, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@bashcoder
bashcoder / logstash_apache_json_macro.conf
Created Aug 4, 2013
Logstash JSON logging in Apache, using mod_macro. Debugged and enhanced from the original version found at: http://cookbook.logstash.net/recipes/apache-json-logs/
View logstash_apache_json_macro.conf
# logstash_apache_json_macro.conf
#
# Create a Macro named logstash_log that is used in the VirtualHost
# It defines, on the fly, a macro for the specific vhost $servername
# and anchors its @source, $source_host and @source_path.
#
# In addition, it prevents any non-page resources from getting logged.
#
# It also adds three tags: web, apache, and the servername
#
View adduser
adduser --home-dir /var/lib/logstash --no-create-home --shell /sbin/nologin logstash
mkdir -p /var/lib/logstash /var/log/logstash
chown -R logstash:logstash /var/lib/logstash /var/log/logstash