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
import org.apache.ignite.plugin.security.{SecurityCredentials, SecurityCredentialsProvider} | |
class EnvironmentVariableSecurityCredentialsProvider extends SecurityCredentialsProvider { | |
override def credentials(): SecurityCredentials = new SecurityCredentials(sys.env("IGNITE_USERNAME"), sys.env("IGNITE_PASSWORD")) | |
} |
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
import UIKit | |
// Is there a way to "turn off" the Playground on certain lines? Not the same as changing the | |
// compilation to "manual" -- it's not the compilation that takes the time. | |
struct SomeThing : Hashable { | |
let x : Int | |
// This line gets updated 22299 times... which takes forever despite showing nothing interesting! | |
var hashValue: Int { get { return x } } |
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
mdfind "(kMDItemContentType =='com.apple.xcode.project') || (kMDItemContentType == 'com.apple.dt.document.workspace') " -0 | xargs -0 ls -t | head -1 | cut -f1 -d: | xargs open |
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
@implementation NSManagedObjectContext (ParentContextHelper) | |
/* | |
* In sample code I see a lot of stuff like this when dealing with nested (parent) managed object contexts: | |
* | |
* [moc performBlock:^{ | |
* NSError* error = nil; | |
* [moc save:&error]; | |
* | |
* [moc.parentContext performBlock:^{ |
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
-- Haskell version of groupWhen | |
-- http://fssnip.net/6A | |
-- | |
-- Seq.groupWhen isOdd [3;3;2;4;1;2] = seq [[3]; [3; 2; 4]; [1; 2]] | |
testList = [3, 3, 2, 4, 1, 2] | |
groupWhen f [] = [] | |
groupWhen f (x:xs) = ( (x : takeWhile notf xs) : groupWhen f (dropWhile notf xs)) | |
where notf x = not (f x) |
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
import Foundation | |
func genericFizzBuzz<T> (number:T, tests:Array<(T)->String?>) -> String { | |
// Run each of the defined test replacements | |
let out = tests.map { t in t(number) } | |
// convert the nil's to empty strings | |
.map { v in v ?? "" } | |
// Concatenate all the replacements together | |
.reduce("", combine: +) |
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/ksh | |
targetName="$1" | |
# Thanks to http://stackoverflow.com/a/13871762/75245 for help with the parsing. | |
relativeInfoPlistLocation=$(/usr/bin/xcrun xcodebuild -showBuildSettings -target ${targetName} 2>/dev/null | awk -F= '/INFOPLIST_FILE/ { print $2; }') | |
absoluteInfoPlistLocation=${PROJECT_DIR}/$relativeInfoPlistLocation | |
version=$(/usr/libexec/Plistbuddy -c 'Print :CFBundleShortVersionString' $absoluteInfoPlistLocation) |
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
// Pretty literal implementation of the quick sort documented on Wikipedia | |
// http://en.wikipedia.org/wiki/Quicksort | |
// Datatypes can trivially be changed to others | |
int32 quicksort_double (vector(double) data) { | |
quicksort_internal_double (data, 0, size(data) - 1); | |
} | |
int32 quicksort_internal_double (vector(double) data, int32 vleft, int32 vright) { | |
if (vright > vleft) { |
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
int32 bubble_sort_double (vector(double) data) { | |
int32 v_len := size(data); | |
int32 v_outer := 0; | |
while (v_outer < v_len) { | |
int32 v_curr := 1; | |
while (v_curr < v_len - v_outer) { | |
if (data[v_curr - 1] > data[v_curr]) { | |
swap_double (data, v_curr, v_curr - 1); | |
} | |
v_curr++; |
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
// Pretty literal implementation of the heap sort documented on Wikipedia | |
// http://en.wikipedia.org/wiki/Heapsort | |
// Datatypes can trivially be changed to others | |
int32 heap_sort_double (vector(double) data) { | |
heapify_double(data); | |
int32 v_end := size(data) - 1; | |
while (v_end > 0) { | |
swap_double (data,v_end,0); |