Skip to content

Instantly share code, notes, and snippets.

View harley's full-sized avatar

Harley Trung harley

View GitHub Profile
@harley
harley / install-redis.sh
Last active September 11, 2021 21:18 — forked from phamk/install-redis.sh
Use latest stable
#!/bin/bash
###############################################
# To use:
# chmod +x install-redis.sh
# ./install-redis.sh
###############################################
version=stable
port=6379
@harley
harley / manual.rb
Last active September 26, 2017 19:26
compile js manually to detect unsupported syntax in asset js
# source https://stackoverflow.com/a/38605526
JS_PATH = "app/assets/javascripts/**/*.js";
Dir[JS_PATH].each do |file_name|
puts "\n#{file_name}"
puts Uglifier.compile(File.read(file_name))
end

Heading 1 – Normally A Document Titlte

Heading 2 – Section A

Heading 3 – Subsection A.1

This is a .docx document.

Bold Text

@harley
harley / README.md
Last active February 20, 2017 09:17
Homework 2 README.md

Homework 2 - Name of App

Name of your app is a Ruby on Rails blog application that allows users to send messages to each other that can only be read once.

Submitted by: Your Name Here

Time spent: X hours

URL: Insert your Heroku URL here

// sample code in the Swift class I'm teaching, on making network request to Instagram to get photos
var clientId = "Put your client id here"
// if you like to use Swift's Dictionary data type, you can use: `let photos = [Dictionary<String, AnyObject>]()`
let photos = [NSDictionary]()
var url = NSURL(string: "https://api.instagram.com/v1/media/popular?client_id=\(clientId)")!
let session = NSURLSession.sharedSession()
let task = session.dataTaskWithURL(url) { (data: NSData?, response: NSURLResponse?, error: NSError?) -> Void in
guard error == nil else {
@harley
harley / vagrant.rb
Last active October 15, 2015 17:27
capistrano 3: deploy to local vagrant
# file: config/deploy/vagrant.rb
# this allows for `cap vagrant deploy`
set :rails_env, :production
set :server_hostname, "192.168.33.10"
server 'vagrant', user: 'vagrant', roles: %w{app web db}, primary: true
set :ssh_options, {
forward_agent: true,
host_name: "127.0.0.1",
port: "2222",
keys: ['.vagrant/machines/default/virtualbox/private_key']
@harley
harley / gist:b3d55b8b622b8fd7ba1c
Created July 29, 2015 07:18
remove merged branches on remote origin, handling feature/blah branches
git branch -r --merged | grep -vw "master" | grep -vw "HEAD" | grep -vw "develop" | cut -d "/" -f2 -f3| xargs -p -I {} git push origin :{}
@harley
harley / vim sort ip addresses
Last active January 2, 2016 13:59
Sort by IP addresses in vim
# source: http://stackoverflow.com/questions/9067559/sorting-ip-addresses-in-vim
:%s/\<\d\d\?\>/0&/g|%&&|sor r/\(\d\{3}\)\%(\.\d\{3}\)\{3}/|%s/\<00\?\ze\d//g
.0.0-p247 :074 > class Q
2.0.0-p247 :075?> def test
2.0.0-p247 :076?> puts "no block. but you can pass a block to me"
2.0.0-p247 :077?> end
2.0.0-p247 :078?> def btest(&block)
2.0.0-p247 :079?> puts "with block"
2.0.0-p247 :080?> block.call
2.0.0-p247 :081?> end
2.0.0-p247 :082?> def ctest
2.0.0-p247 :083?> if block_given?
@harley
harley / .vimrc
Created September 28, 2012 09:04
Rnavcommand for backbone files in vim
" Shortcuts for backbone.js via the asset pipeline
" using backbone-on-rails gem and generate with backbone namespace
autocmd User Rails Rnavcommand bmodel app/assets/javascripts/backbone/models -suffix=.js.coffee -glob=*
autocmd User Rails Rnavcommand bcollection app/assets/javascripts/backbone/collection -suffix=.js.coffee -glob=*
autocmd User Rails Rnavcommand brouter app/assets/javascripts/backbone/routers -suffix=.js.coffee -glob=*
autocmd User Rails Rnavcommand btemplate app/assets/backbone/templates -suffix=.jst.hbs -glob=**/*
autocmd User Rails Rnavcommand bview app/assets/javascripts/backbone/views -suffix=.js.coffee -glob=**/*