Skip to content

Instantly share code, notes, and snippets.

t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time
@jlyonsmith
jlyonsmith / create-icons
Last active December 8, 2016 21:13 — forked from richellis/Iconizer.sh
Ruby script to create iOS application icon sets from PDF files. Requires ImageMagick and GhostScript.
#!/usr/bin/env ruby
# Requires ImageMagick: http://www.imagemagick.org/
# Requires GhostScript: http://www.ghostscript.com/
require 'fileutils'
if ARGV.count < 2 then
puts "Usage: #{File.basename(__FILE__)} <pdf-file> [<pdf-file> ...] <project-folder>"
exit 1
end
@jlyonsmith
jlyonsmith / UIAlertController.swift
Last active November 27, 2016 19:09 — forked from pietrorea/UIAlertController.swift
UIAlertController example
let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Save", style: .default, handler: { (action: UIAlertAction!) in
debugPrint("Saved")
}))
alert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: { (action: UIAlertAction!) in
debugPrint("Cancel")
}))
present(alert, animated: true, completion: nil)
@jlyonsmith
jlyonsmith / delete-github-merged.sh
Last active April 21, 2016 22:24 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
git branch -r --merged | grep origin | grep -v '>' | grep -v master | xargs -L1 | ruby -e 'ARGF.each { |line| a = line.match(/(?:[^\/]*)\/(.*)/).captures; puts a }' | xargs git push origin --delete
# http://www.mono-project.com/Compiling_Mono_on_OSX
require 'formula'
class Mono < Formula
url 'http://download.mono-project.com/sources/mono/mono-3.2.3.tar.bz2'
homepage 'http://www.mono-project.com/'
sha1 'e356280ae45beaac6476824d551b094cd12e03b9'
def install