This file contains hidden or 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
#!/usr/bin/csharp | |
LoadAssembly ("/Library/Frameworks/Xamarin.Mac.framework/Versions/1.4.22/lib/mono/XamMac.dll"); | |
using MonoMac.ScriptingBridge; | |
var app = SBApplication.FromBundleIdentifier ("com.apple.finder"); | |
Console.WriteLine (app == null); |
This file contains hidden or 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
Task Animate (double duration, Action animation) | |
{ | |
var complete = new TaskCompletionSource<object> (); | |
UIView.Animate (duration, () => animation (), () => { | |
complete.TrySetResult (null); | |
}); | |
return complete.Task; | |
} | |
async void Dismiss () |
This file contains hidden or 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 System.Exit | |
import Control.Monad | |
import Control.Concurrent | |
import Control.Concurrent.MVar | |
main = do | |
currentPos <- newMVar (1, 2) | |
forkIO $ forever $ do | |
(x, y) <- readMVar currentPos |
This file contains hidden or 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
// Beautifully maximizing a view | |
let status = 20.0F | |
this.Frame <- UIScreen.MainScreen.Bounds.With (Y = just status, Height = subtract status) | |
// FYI... | |
let just s _ = s | |
let subtract y x = x - y | |
// I previously had the more cryptic: | |
this.Frame <- UIScreen.MainScreen.Bounds.With (Y = (+) status, Height = (+) -status) |
This file contains hidden or 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
class Enum | |
constructor: (@names...) -> | |
@values = [0 .. @names.length - 1] | |
@[name] = i for name, i in @names | |
getName: (i) => @names[i] | |
getTitle: (i) => _.str.titleize @getName i | |
# The next few definitions (e.g. Trial, Tiles) are for the interpretation of valid tile state |
This file contains hidden or 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
scrollPoints = [ | |
{ selector: "#window", fire: showAccountTile } | |
] | |
processScrollPoints = -> | |
scrollPoints = _.reject scrollPoints, ({selector, fire}) -> | |
if isScrolledIntoView $(selector) | |
fire() | |
true | |
else |
This file contains hidden or 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
let (|File|Directory|Missing|) path = | |
if Directory.Exists path then Directory | |
elif File.Exists path then File | |
else Missing | |
let cp_r source dest = | |
match source, dest with | |
| Missing, _ -> failwithf "missing file" | |
| File, File -> cp source dest | |
| File, Directory -> ... |
This file contains hidden or 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
// Quickly create Funcs that memoize expensive computations. | |
// | |
// In this example, ExpensiveMethod is only called once! | |
// | |
// var cached = CachedFunc.Create ((int x, string y) => x + ExpensiveMethod (y)); | |
// for (int i = 0; i < 1000; i++) | |
// cached (123, "hello"); | |
public static class CachedFunc | |
{ |
This file contains hidden or 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
#!env ruby | |
# | |
# Recursively replace a string in a directory by renaming files, directories, and rewriting file contents: | |
# | |
# $ rename.rb . GAIM Pidgin | |
# | |
# No changes are made unless -f is specified | |
DRY = !(ARGV.include? "-f") |
This file contains hidden or 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
#r "Volare.dll" | |
open Volare | |
get "/" <| fun req res -> | |
"Hello, world!" | |
get "/:name" <| fun req res -> | |
html <| fun _ -> | |
body <| fun _ -> |