Skip to content

Instantly share code, notes, and snippets.

View karstengresch's full-sized avatar
:octocat:
.

Karsten Gresch karstengresch

:octocat:
.
View GitHub Profile
@karstengresch
karstengresch / iterm.scpt
Created March 26, 2018 09:27 — forked from gnachman/iterm.scpt
Replace /Applications/Docker/Docker Quickstart Terminal.app/Contents/Resources/Scripts/iterm.scpt with this.
set itermRunning to (application "iTerm" is running)
set scriptPath to quoted form of POSIX path of ((path to me as text) & "::" & "start.sh")
set user_shell to do shell script "dscl /Search -read /Users/$USER UserShell | awk '{print $2}'"
tell application "iTerm"
activate
if not (exists window 1) or (itermRunning = false) then
reopen
end if
@karstengresch
karstengresch / DictionaryKeyPath.swift
Created January 31, 2018 23:22 — forked from dfrib/DictionaryKeyPath.swift
Swift: Reading and writing to (possible) nested dictionaries for a given key path, using a recursive approach
// For details, see
// http://stackoverflow.com/questions/40261857/remove-nested-key-from-dictionary
import Foundation
extension Dictionary {
subscript(keyPath keyPath: String) -> Any? {
get {
guard let keyPath = Dictionary.keyPathKeys(forKeyPath: keyPath)
else { return nil }
return getValue(forKeyPath: keyPath)
@karstengresch
karstengresch / resetAllSimulators.sh
Created January 25, 2018 16:25 — forked from ZevEisenberg/resetAllSimulators.sh
Reset all iOS simulators with this one weird trick
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all
@karstengresch
karstengresch / gist:2a81245a5caeb6b963d035a9ae452c16
Created January 12, 2018 20:24
Swift 4: UIColor(hex: String) extension
// Inspired by https://stackoverflow.com/questions/24263007/how-to-use-hex-colour-values, merging Swift 4 + extension examples
extension UIColor {
convenience init (hex:String) {
var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()
if (cString.hasPrefix("#")) {
cString.remove(at: cString.startIndex)
}
@karstengresch
karstengresch / cocoaconv.rb
Created December 30, 2017 20:49 — forked from DivineDominion/cocoaconv.rb
Convert libMultiMarkdown enums to Swift-bridgeable NS_ENUMs. Pass the path to libMultiMarkdown.h to the script when running.
#!/usr/bin/env ruby
require 'optparse'
CURRENT_PATH = File.expand_path(File.dirname(__FILE__))
FALLBACK_PATH = File.join(CURRENT_PATH, "..", "build-xcode", "Debug", "include", "libMultiMarkdown", "libMultiMarkdown.h")
options = {:mode => :nsenum}
OptionParser.new do |parser|
parser.banner = "Usage: #{$0} [options] path/to/libMultiMarkdown.h"
@karstengresch
karstengresch / plistGitDiff
Created November 16, 2017 14:07 — forked from scottrigby/plistGitDiff
Shows git diff of tracked plist files
#!/bin/bash
## @file
## Shows git diff of tracked plist files.
##
## Normally, Mac plist files are binary, so git diffs do not display. However,
## there are cases where seeing diffs is important. For example, when tracking
## changes via Mackup's git storage option.
##
## @see http://confusatory.org/post/133141617492/git-diff-for-binary-apple-property-list-files
@karstengresch
karstengresch / Minimal eclipse install
Created November 14, 2017 14:09 — forked from mjwall/Minimal eclipse install
Minimal eclipse install
Tired of extra plugins and cruft in eclipse, I tried the following
1. Download platform binary runtime from
http://archive.eclipse.org/eclipse/downloads/drops4/R-4.6.1-201609071200/
2. Modify eclipse.ini, set -vm JAVA_HOME/bin/java for java 8 and -Xmx2048m
3. Open and run check for updates
Verifying that "gresch.id" is my Blockstack ID. https://onename.com/gresch
@karstengresch
karstengresch / Country.swift
Created August 30, 2017 15:54 — forked from kharrison/Country.swift
Swift Hash Functions
import Foundation
struct Country {
let name: String
let capital: String
var visited: Bool
}
extension Country: Equatable {
static func == (lhs: Country, rhs: Country) -> Bool {
@karstengresch
karstengresch / red_hat_3scale.sh
Last active July 7, 2017 14:22
3scale setup on openshift
# as per the documentation at https://support.3scale.net/guides/infrastructure/onpremises20-installation
THREESCALE_PROJECTNAME="3scale-amp"
THREESCALE_AMP_TEMPLATE="https://raw.githubusercontent.com/3scale/3scale-amp-openshift-templates/2.0.0.GA-redhat-2/amp/amp.yml"
WILDCARD_DOMAIN="192.168.42.249.nip.io"
oc login -u system:admin
oc new-project $THREESCALE_PROJECTNAME
oc new-app --file $THREESCALE_AMP_TEMPLATE --param WILDCARD_DOMAIN=$WILDCARD_DOMAIN