Skip to content

Instantly share code, notes, and snippets.

@xecutioner
xecutioner / deploy.rb
Created January 19, 2016 05:13
private_pub capistrano tasks
namespace :private_pub do
desc "Start private_pub server"
task :start do
run "cd #{current_path};RAILS_ENV=production bundle exec rackup private_pub.ru -s thin -E production -D -P tmp/pids/private_pub.pid"
end
desc "Stop private_pub server"
task :stop do
run "cd #{current_path};if [ -f tmp/pids/private_pub.pid ] && [ -e /proc/$(cat tmp/pids/private_pub.pid) ]; then kill -9 `cat tmp/pids/private_pub.pid`; fi"
end
@xecutioner
xecutioner / grok_vi.mdown
Created February 17, 2016 21:05 — forked from nifl/grok_vi.mdown
Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@xecutioner
xecutioner / file sizes
Created March 6, 2016 08:32
commands for checking the file sizes in linux
# Overall file system usages.
df -h
# Specific file or folder
du -sh *
@xecutioner
xecutioner / _share_buttons.html.erb
Created March 9, 2016 09:10
share buttons views
<div class="share_buttons <%='pull-right' if defined?(pull_left) && pull_left!=true%>">
<span class='st_facebook_large' st_url=<%=request.original_url%> displayText='Facebook'></span>
<span class='st_googleplus_large' st_url=<%=request.original_url%> displayText='Google +'></span>
<span class='st_twitter_large' st_url=<%=request.original_url%> displayText='Tweet'></span>
<span class='st_linkedin_large'st_url=<%=request.original_url%> displayText='LinkedIn'></span>
<span class='st_email_large' st_url=<%=request.original_url%> displayText='Email'></span>
<span class='st_reddit_large' st_url=<%=request.original_url%> displayText='Reddit'></span>
<!-- <span class='st_plusone_large' displayText='Google +1'></span> -->
<%if !defined?(pull_left) %>
<span class="share_text">If you like this article, Then perhaps share?</span>
@xecutioner
xecutioner / a.rb
Created March 10, 2016 02:32
STI PROGRAMMING NOTES
While permanently null fields and large unwieldy tables are conceptually ugly, they generally don't actually cause any real inefficiency. The extra space used by null fields is not an important consideration for most systems, and the query speed will not be slower if you set up your indexes well.
And the benefits of STI are often worthwhile (database efficiency by minimizing joins, and shared code simplicity and DRYness). So if you are going to use a traditional SQL system, just learn to ignore the conceptual ugliness and use STI. Your use case is what STI was designed for.
That said, if you are not too deep in your development cycle for this project to be attached to your database system (and it sounds like you're not), and you are willing to invest some time to research/learning, you really might want to consider an alternative to SQL (there are many good ones out there). Currently the most popular alternative (and my personal favorite) is MongoDB.
MongoDB is document-based rather than schema-based. This
@xecutioner
xecutioner / a.rb
Created March 11, 2016 11:52
resetting postgres database
find the file pg_hba.conf - it may be located, for example in /etc/postgresql-9.1/pg_hba.conf.
cd /etc/postgresql-9.1/
Back it up
cp pg_hba.conf pg_hba.conf-backup
place the following line (as either the first uncommented line, or as the only one):
@xecutioner
xecutioner / a.rb
Created April 4, 2016 03:45
git stats
git log --author="nikesh" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -
@xecutioner
xecutioner / change_authorname.sh
Created May 16, 2016 12:15
Change author name
git filter-branch --commit-filter 'if [ "$GIT_AUTHOR_NAME" = "Josh Lee" ];
then export GIT_AUTHOR_NAME="Hobo Bob"; export [email protected];
fi; git commit-tree "$@"'
@xecutioner
xecutioner / ci_install.sh
Created May 18, 2016 11:30 — forked from ryane/ci_install.sh
A script (or just list of commands) to setup a jenkins server on Ubuntu 12.04 hosted at linode. Liberally borrowed from https://gist.github.com/whistler/3179919#file-jenkins_rails_ubuntu-sh
sudo aptitude -y install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev
sudo apt-get -y install libxslt-dev libxml2-dev
sudo apt-get -y install libmysqlclient-dev ruby-dev
sudo apt-get -y install libcurl4-openssl-dev
sudo apt-get -y install imagemagick libmagickcore-dev libmagickwand-dev
sudo apt-get -y install libsqlite3-dev
sudo apt-get -y install libreadline-dev
sudo apt-get -y install git
sudo apt-get -y install libicu48
sudo apt-get -y install nodejs
@xecutioner
xecutioner / fast.rb
Created November 18, 2016 10:43 — forked from vayu-technology/fast.rb
Check network over time with fast.com + ruby
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'capybara/rspec'
require 'capybara/poltergeist'
require 'csv'
require 'pry'
include Capybara::DSL
Capybara.register_driver :poltergeist do |app|