This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example nginx + git HTTP Smart mode (git-http-backend) + HTTP Authentication + HTTPS redirect | |
# jeroen@massar.ch - http://jeroen.massar.ch | |
server { | |
listen 192.0.1.1:80; | |
listen [2001:db8::1]:80; | |
# Redirect all non-HTTPS traffic to the HTTPS variant | |
return 301 https://$host$request_uri; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
navigator.serviceWorker.getRegistrations().then(function (registrations) { | |
if (!registrations.length) { | |
console.log('No serviceWorker registrations found.') | |
return | |
} | |
for(let registration of registrations) { | |
registration.unregister().then(function (boolean) { | |
console.log( | |
(boolean ? 'Successfully unregistered' : 'Failed to unregister'), 'ServiceWorkerRegistration\n' + | |
(registration.installing ? ' .installing.scriptURL = ' + registration.installing.scriptURL + '\n' : '') + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USERNAME=$1 | |
EMAIL=$2 | |
if [[ "$USERNAME" == "" || "$EMAIL" == "" ]]; then | |
echo 'Usage: create-user USERNAME EMAIL' | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Convert a .p12 format file to a .pem format | |
openssl pkcs12 -in $1 -out $2 -nodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Print the SSH MD5 fingerprint (works on OSX El Capitan which defaults to a SHA256 fingerprint) | |
ssh-keygen -E md5 -lf ~/.ssh/id_rsa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func Log<T>(item: T, fileName: String = __FILE__, line: Int = __LINE__, funcName:String = __FUNCTION__) { | |
let dateFormatter = NSDateFormatter() | |
dateFormatter.dateFormat = "MM/dd/yyyy HH:mm:ss:SSS" | |
let process = NSProcessInfo.processInfo() | |
let threadId = "?" | |
var shortFileName = (NSURL(string: fileName)?.lastPathComponent?.componentsSeparatedByString(".").first) | |
if shortFileName == nil { | |
shortFileName = "unknown" | |
} |