Skip to content

Instantly share code, notes, and snippets.

View kreeger's full-sized avatar

Ben Kreeger kreeger

View GitHub Profile
@kreeger
kreeger / !BDKCoreDataStore.markdown
Last active August 29, 2015 13:56
Core Data context management.

BDKCoreDataStore & BDKCoreDataOperation

These two classes are designed to work together to provide access to a common Core Data store, along with the contexts that go with it. The main NSManagedObjectContext is designed to be accessed on the main thread only. Safe background operations happen in a background NSOperationQueue to ensure that multiple reads and writes don't step on each others' toes.

It could use a tad of cleanup, but it's served me well for a few apps.

@kreeger
kreeger / Swift-Libs.markdown
Created July 9, 2014 12:03
Swift libraries I'm excited about.

Swift libraries I'm excited about

Even though I star these on GitHub, it's so easy to lose track of 'em, so I'm compiling a list here.

CocoaPods support

The CocoaPods team is looking into what it'll take to get Swift code to work more cleanly with iOS 8 and Xcode 6.

Keybase proof

I hereby claim:

  • I am kreeger on github.
  • I am kreeger (https://keybase.io/kreeger) on keybase.
  • I have a public key whose fingerprint is B22D 3423 BD76 F174 5E42 E7DE 489E A7C5 BF21 1B40

To claim this, I am signing this object:

Disable-UAC
Disable-InternetExplorerESC
Enable-MicrosoftUpdate
Install-WindowsUpdate
Set-StartScreenOptions -EnableBootToDesktop -EnableDesktopBackgroundOnStart -EnableShowStartOnActiveScreen -EnableShowAppsViewOnStartScreen -EnableSearchEverywhereInAppsView -EnableListDesktopAppsFirst
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions -EnableShowFullPathInTitleBar
cinst chocolatey
cinst git
@kreeger
kreeger / trade.rb
Created February 28, 2015 18:02
A wrapper script for tradedangerous.
#!/usr/bin/env ruby
# A wrapper around Trade Dangerous that persists settings in a local JSON file.
require 'json'
class Trader
attr_reader :data
def initialize(data:)
@kreeger
kreeger / EAVersionChecker.swift
Last active August 29, 2015 14:23
Checks for a new version from a server and prompts the user to install it. Great for enterprise builds.
//
// EAVersionChecker.swift
// Copyright (c) 2015 Oven Bits. All rights reserved.
//
import Foundation
class EAVersionChecker {
var versionManifestURL: String = ""
var currentLocalVersion: String { return "\(localSVS).\(localBuild)" }
@kreeger
kreeger / xcode-and-el-capitan.md
Last active August 29, 2015 14:24
Re-enables launching of older versions of Xcode on El Capitan. Do so at your own risk!

Xcode 6 & El Capitan

Re-enables launching of older versions of Xcode on El Capitan. Xcode 6 supposedly has issues creating corrupt archives on El Capitan, which is why it's been disabled. Do so at your own risk!

  • Disable rootless (temporarily) with sudo nvram boot-args="kext-dev-mode=1 rootless=0"
  • Then reboot
  • open /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Exceptions.plist
  • change com.apple.dt.Xcode -> Item 0 -> HardDisabled from YES to NO
  • Reboot again, for good measure
  • Remove and reinstall Xcode, launch it, make sure it's good
@kreeger
kreeger / three-dimensional.rb
Last active August 29, 2015 14:25
Distance between two points.
points = [
{ name: "POINT A", coords: [46.71875, -87.6875, -68.8125] },
{ name: "POINT B", coords: [51.78125,-94.625,-53.21875] }
]
# (17.8ly)
x_comp = (points[1][:coords][0] - points[0][:coords][0]) ** 2
y_comp = (points[1][:coords][1] - points[0][:coords][1]) ** 2
z_comp = (points[1][:coords][2] - points[0][:coords][2]) ** 2
@kreeger
kreeger / benlight.vim
Created December 15, 2011 16:58
Benlight: My Twilight-based vim color scheme
" Vim color file
" Converted from Textmate theme Twilight using Coloration v0.3.2 (http://github.com/sickill/coloration)
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
@kreeger
kreeger / mc_server.rb
Created January 7, 2012 18:44
Ruby: Minecraft process launcher
#!/usr/bin/env ruby
# Minecraft server launcher, by Benjamin Kreeger <ben@kree.gr>.
# Feel free to shamelessly steal this script. I don't care.
# I renamed mine to `mc_server` and did a `chmod +x` on it so I
# wouldn't have to type `ruby mc_server.rb` on it every time I
# wanted to launch my server in the background.
#
# Make sure this is in the same directory as your
# `minecraft_server.jar` file. I haven't tested it otherwise, and