Skip to content

Instantly share code, notes, and snippets.

@leonardteo
leonardteo / rails_on_windows_10.md
Last active March 14, 2018 23:14
How to get Rails dev environment working on Windows 10
@leonardteo
leonardteo / maxmind_geoip2_macos_sierra.md
Created December 27, 2016 22:08
For anyone trying to install maxmind_geoip2 on MacOS Sierra

You may run into probelms like this:

Building native extensions.  This could take a while...
ERROR:  Error installing maxmind_geoip2:
	ERROR: Failed to build gem native extension.

    current directory: /Users/leonardteo/.rvm/gems/ruby-2.1.6@artstation/gems/maxmind_geoip2-0.0.8/ext/maxmind_geoip2
/Users/leonardteo/.rvm/rubies/ruby-2.1.6/bin/ruby -r ./siteconf20161227-1647-1c4uejw.rb extconf.rb
checking for maxminddb.h... no
@leonardteo
leonardteo / put-in-header-customization-on-discourse.html
Created February 13, 2014 15:06
Discourse FitVids to maximize size of video embeds
<script src="//cdnjs.cloudflare.com/ajax/libs/fitvids/1.0.1/jquery.fitvids.min.js"></script>
<script>
Discourse.PostView.reopen({
didInsertElement : function(){
this._super();
var $post = this.$();
$post.fitVids();
}
});
</script>
@leonardteo
leonardteo / sidekiq
Last active August 29, 2015 13:56 — forked from dyerc/sidekiq
#!/bin/bash
# sidekiq Init script for Sidekiq
# chkconfig: 345 100 75
#
# Description: Starts and Stops Sidekiq message processor for Stratus application.
#
# User-specified exit parameters used in this script:
#
# Exit Code 5 - Incorrect User ID
# Exit Code 6 - Directory not found
@leonardteo
leonardteo / index.slim
Created January 22, 2014 19:48
Including another slim file in Codekit.
== Slim::Template.new("#{File.dirname(__FILE__)}/header.slim").render
@leonardteo
leonardteo / endless-app-template.rb
Last active January 2, 2016 06:29
Rails Application Template with Endless Gem
# Endless Rails application template
# For use with v1.0.3
#
# This should be copied to https://gist.github.com/leonardteo/8263273
#
# Usage:
# rails new [app name] -m https://gist.github.com/leonardteo/8263273/raw/endless-app-template.rb
# Front-end gems
gem 'slim'
@leonardteo
leonardteo / assets.rb
Created April 4, 2013 23:27
Capistrano assets recipe for precompiling assets if there are changes. Precompilation happens locally and rsync to server automatically. I can't take credit for this. @gvalmon gave me this in a project. :)
def assets_changed?
from = source.next_revision(current_revision)
asset_dirs = "app/assets/"
capture("cd #{latest_release} && #{source.local.log(from)} #{asset_dirs} | wc -l").to_i > 0
end
namespace :deploy do
namespace :assets do
task :precompile, roles: :web do
is_first_deploy = !remote_file_exists?(File.join(current_path, "REVISION"))
@leonardteo
leonardteo / install_ruby_passenger_nginx.sh
Created November 4, 2012 21:08
Install Ruby 1.9.3, Phusion Passenger and Nginx on Ubuntu 12.04 LTS with one command
#!/bin/bash
# PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Store the base dir
BASEDIR=$( cd $(dirname $0); pwd)
# Get all dependencies
sudo apt-get update
@leonardteo
leonardteo / install_ruby.sh
Created August 24, 2012 18:44
Install Script for Ruby 1.9.3 on Ubuntu 12.04 LTS
#!/bin/bash
curl -L https://get.rvm.io | sudo bash -s stable
usermod -a -G rvm ubuntu # 'ubuntu' is the default admin user
sudo apt-get -y install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
source /usr/local/rvm/scripts/rvm
rvmsudo rvm install 1.9.3
rvm --default use 1.9.3
@leonardteo
leonardteo / ruby_on_rack.rb
Created August 11, 2012 14:10
Ruby on Rack
# Sets up and runs a simple Rack server using WEBrick
require 'rack'
class HelloWorld
def call(env)
[200, {"Content-Type" => "text/html"}, ["Hello Rack!"]]
end
end
Rack::Server.start(:app => HelloWorld.new, :Port => 9292, :server => 'WEBrick')