This is a .docx document.
Bold Text
#!/bin/bash | |
############################################### | |
# To use: | |
# chmod +x install-redis.sh | |
# ./install-redis.sh | |
############################################### | |
version=stable | |
port=6379 |
# Put this in Rakefile (doesn't matter where) | |
require 'benchmark' | |
class Rake::Task | |
def execute_with_benchmark(*args) | |
bm = Benchmark.measure { execute_without_benchmark(*args) } | |
puts " #{name} --> #{bm}" | |
end | |
alias_method :execute_without_benchmark, :execute |
# blog post: | |
module ActiveAdmin | |
module ViewHelpers | |
# lib/active_admin/view_helpers/auto_link_helper.rb | |
def auto_link(resource, link_content = nil) | |
content = link_content || display_name(resource) | |
if can?(:read, resource) && registration = active_admin_resource_for(resource.class) | |
begin |
git branch -r --merged | grep -vw "master" | grep -vw "HEAD" | grep -vw "develop" | cut -d "/" -f2 -f3| xargs -p -I {} git push origin :{} |
# 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 |
// 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 { |
# adapted from http://devblog.springest.com/a-script-to-remove-old-git-branches | |
# This has to be run from master | |
git checkout master | |
# Update our list of remotes | |
git fetch | |
git remote prune origin | |
# Remove local fully merged branches |
# 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 |