Skip to content

Instantly share code, notes, and snippets.

View julesjans's full-sized avatar

Jules Jans julesjans

View GitHub Profile
@julesjans
julesjans / color.sh
Created September 5, 2017 06:17
Shell script to change the tag/colour of item in Finder with AppleScript
#!/bin/bash
osascript -e "tell application \"Finder\" to set label index of alias POSIX file \"$1\" to 2"
@julesjans
julesjans / compress.sh
Last active August 18, 2017 10:50
Compress a file/directory using hdiutil and tar
#!/bin/bash
hdiutil create -fs HFS+ -srcfolder "$1" -volname "$(basename $1)" "$1.dmg"
tar -cjf "$1.tar.bz2" -C "$(dirname $1)" "$(basename $1)"
@julesjans
julesjans / remove-from-git.sh
Created August 18, 2017 10:40
Remove a file from GIT history
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch FILE_TO_DELETE' --prune-empty --tag-name-filter cat -- --all
@julesjans
julesjans / regex.swift
Created August 17, 2017 10:39
Simplified regex handler in swift
import Foundation
extension String {
func regex(_ pattern: String) -> Bool {
return self.range(of: pattern, options: .regularExpression) != nil
}
}
let pattern = "http[s]?://[w]*.?booking.com.*aid=[0-9]+"
@julesjans
julesjans / time-conversions.swift
Created August 17, 2017 10:32
Handle time conversions from .NET APIs
import Foundation
// Further Reading:
// https://technet.microsoft.com/en-us/library/aa258277(v=sql.80).aspx
// http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns
// http://www.w3.org/TR/NOTE-datetime
@julesjans
julesjans / time-ago.swift
Created August 17, 2017 10:29
Human "time ago" for swift
import Foundation
extension Date {
func timeAgo() -> String {
let calendar = Calendar.current
let seconds = calendar.dateComponents([.second], from: self, to: Date()).second!
let minutes = calendar.dateComponents([.minute], from: self, to: Date()).minute!
@julesjans
julesjans / auction_prices.rb
Last active August 17, 2017 10:31
Calculating hammer price to limit on auction with variable commission rates
BEFORE = 0.25 # Percent commission before the limit
LIMIT = 50000 # The commission boundary
AFTER = 0.20 # Percent after the boundary
# The only number to change is this one! No spaces, dots or commas...!
total_price_including_commssion = 10000000
# Warning - Do not use for bids over a £1,000,000 Hammer
@julesjans
julesjans / vat_calc.rb
Created August 17, 2017 08:05
Calculating VAT
module VatCalc
def VatCalc.vat_rate
@vat_rate ||= BigDecimal.new('20')
end
def VatCalc.vat_rate=(value)
@vat_rate = BigDecimal.new(value.to_s)
end
@julesjans
julesjans / screen-gif.sh
Last active May 8, 2021 16:40
Capture iOS Simulator to animated gif
# Turn on the simulator screen capture
xcrun simctl io booted recordVideo ~/simulator.mov
# Convert the iPhone 6s screen shot into a gif:
ffmpeg -i ~/simulator.mov -vf scale=320:-1 -r 6 -f gif -y simulator.gif
@julesjans
julesjans / ioslocaleidentifiers.csv
Created February 17, 2017 15:37 — forked from jacobbubu/ioslocaleidentifiers.csv
iOS Locale Identifiers
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)