Skip to content

Instantly share code, notes, and snippets.

@jcowhigjr
jcowhigjr / ask.sh
Last active August 29, 2015 14:27
Bash: General-purpose Yes/No prompt function ("ask")
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# http://djm.me/ask
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
$(document).ready(function(){
// Apparently I am not smart enough to figure out how to
// set the selected value on the new date_select form helper in Rails 4
// So, I had to create a client side solution
var url = document.location.href.split("?")[1];
// If the url does not have a query string
// Nothing else matters
if(url) {
var params = url.split("&");
@jcowhigjr
jcowhigjr / README.md
Last active August 29, 2015 13:56 — forked from terenceponce/README.md

Setting up Ruby, Rails, Nginx,and PostgreSQL 9 on Ubuntu 14.04 LTS

Last updated: 12 Feb 2014 Work in progress sources: "https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-with-rbenv--2" "http://10kb.nl/blog/setup-and-keep-up-with-the-latest-versions-of-a-complete-rails-dev-stack" "http://gorails.com/setup/ubuntu/13.10"

Fix the locale issue

  • Edit /etc/default/locale as sudo.
  • Append LC_ALL="en_US.UTF-8" at the end of the file, save and quit.
  • sudo locale-gen en_US en_US.UTF-8
@jcowhigjr
jcowhigjr / kick.sh
Created January 23, 2014 19:11 — forked from sosiouxme/kick.sh
#!/bin/sh
# This is a sample script for kickstarting a VM according to the openshift.ks script under virt-manager, qemu+KVM, and Linux.
# You certainly need to modify at least the CMDLINE and --location below for it to be useful (unless you work at Red Hat).
set -e
if [ $# -lt 1 ]
then
printf 'Usage: %s vm_name [arg1 [arg2 [...]]]\n' "$0"

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev

@jcowhigjr
jcowhigjr / ubuntu_steps.sh
Last active January 2, 2016 13:19 — forked from july-12/ubuntu_steps.sh
RAILS Stack build steps
# from ubuntu trusty 13.10
# As root user
sudo su
# Update the OS
apt-get update -y
# Add this to ~/.bashrc to remove timezone warnings
export LC_ALL="en_US.UTF-8"
@jcowhigjr
jcowhigjr / Gemfile
Created December 18, 2013 20:27 — forked from SammyLin/Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'jquery-rails'
# A Scope & Engine based, clean, powerful, customizable and sophisticated paginator
gem "kaminari"
# Compass is a Stylesheet Authoring Environment that makes your website design simpler to implement and easier to maintain.
require 'factory_girl_rails'
require 'rspec'
require 'rspec-rails'
require 'rspec/mocks/standalone' # => if factories need stubs (for remote services for example)
include FactoryGirl::Syntax::Methods # make FG methods available at top level, so you can do `> create :user`
def reload_factories!
FactoryGirl.instance_variable_set(:@factories, nil) # => clear loaded factories/sequences
# FactoryGirl.instance_variable_set(:@sequences, nil)
class config::sublime {
define addpkg {
$packagedir = "/Library/Application Support/Sublime Text 2/Packages/"
$pkgarray = split($name, '[/]')
$pkgname = $pkgarray[1]
exec { "git clone https://github.com/${name}.git":
cwd => "/Users/${::luser}${packagedir}",
provider => 'shell',
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e