Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

function sedmv
set ls_flags "-1"
set perform_changes yes
# the last arg is the pattern. save it, remove it, process flags
set pattern $argv[-1]
set -e argv[-1]
if test $pattern = ""
@ahti
ahti / gist:bd96477ebd631fecb98d
Created June 4, 2014 13:47
Swift subscript overloading and vargs
class Foo {
subscript(idxs: Int...) -> Int {
get {
return idxs.reduce(1, combine: *)
}
}
subscript(idxs: Array<Int>) -> Int {
get {
return idxs.reduce(1, combine: *)
}
@ahti
ahti / gist:d4d44a2ee2958f522f87
Created June 6, 2014 03:35
Currying in Swift
func curry<A,B>(fun: (A)->B, arg: A) -> (() -> B) {
return { return fun(arg) }
}
func curry<A,B,C>(fun: (A,B)->C, arg: A) -> ((B) -> C) {
return { return fun(arg, $0) }
}
func square(i: Int) -> Int { return i * i }
let sq2 = curry(square, 2)
@ahti
ahti / gist:fe32cca03694699b00ce
Created June 7, 2014 20:54
Swift @auto_closure
func onlyIfFoo(str: String, stmt: @auto_closure () -> Any) {
if (str == "foo") {
stmt()
}
}
onlyIfFoo("bar", println("bar"))
onlyIfFoo("foo", println("foo"))
@ahti
ahti / gist:99149b05697b67065974
Created June 14, 2014 00:18
SKShapeNode array contains
import SpriteKit
let arr: SKShapeNode[] = []
let node: SKShapeNode = SKShapeNode()
contains(arr, node)
- (void)viewDidLoad
{
self.formatter = [NSNumberFormatter new];
self.formatter.numberStyle = NSNumberFormatterCurrencyStyle;
self.formatter.partialStringValidationEnabled = YES;
self.textField.delegate = self;
self.textField.text = [self.formatter editingStringForObjectValue:self.number];
}
@ahti
ahti / linebreaks and indentation.m
Created December 7, 2013 06:12
Gist to compare line breaks and indentation in objc-headers
// AFSerialization.h
//
// Copyright (c) 2013 AFNetworking (http://afnetworking.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
> choco install -debug -verbose -y mpv.portable
Chocolatey is running on Windows v 6.3.9600.0
Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
Command line: "C:\ProgramData\chocolatey\choco.exe" install -debug -verbose -y mpv.portable
Received arguments: install -debug -verbose -y mpv.portable
NOTE: Hiding sensitive configuration data! Please double and triple
check to be sure no sensitive data is shown, especially if copying
@ahti
ahti / flock_osx.c
Created February 15, 2013 19:36
Linux flock(2) 2.22.1 with some minor changes for compiling on OSX. I have not run any test but basic functionality works.
/* Copyright 2003-2005 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following
* conditions:
diff --git a/include/lldb/Utility/TaskPool.h b/include/lldb/Utility/TaskPool.h
index db15b2081..3e6d5df8f 100644
--- a/include/lldb/Utility/TaskPool.h
+++ b/include/lldb/Utility/TaskPool.h
@@ -33,6 +33,7 @@
#include <queue>
#include <thread>
#include <vector>
+#include <functional>