Skip to content

Instantly share code, notes, and snippets.

View dvdsgl's full-sized avatar
🦋
Gliding

David Siegel dvdsgl

🦋
Gliding
View GitHub Profile
[~/Developer/ScalaMono]% scalac-net ScalaMono.scala
[~/Developer/ScalaMono]% ilasm ScalaMono.msil
Assembling 'ScalaMono.msil' , no listing file, to exe --> 'ScalaMono.exe'
Operation completed successfully
[~/Developer/ScalaMono]% mono ScalaMono.exe
Scala on Mono! fib (0) = 1
Scala on Mono! fib (1) = 1
Scala on Mono! fib (2) = 2
Scala on Mono! fib (3) = 3
import System._
object ScalaMono extends Application {
def fib (i: Int): Int = i match {
case 0 | 1 => 1
case i => fib (i - 2) + fib (i - 1)
}
for (i <- 0 until 10) {
[~/Developer/ScalaMono]% time mono ScalaMono.exe
Scala on Mono! fib (0) = 1
Scala on Mono! fib (1) = 1
Scala on Mono! fib (2) = 2
Scala on Mono! fib (3) = 3
Scala on Mono! fib (4) = 5
Scala on Mono! fib (5) = 8
Scala on Mono! fib (6) = 13
Scala on Mono! fib (7) = 21
Scala on Mono! fib (8) = 34
[~/Developer/ScalaMono]% cat ScalaMono.scala
object ScalaMono extends Application {
def fib (i: Int): Int = i match {
case 0 | 1 => 1
case i => fib (i - 2) + fib (i - 1)
}
println (fib (35))
}
[~/Developer/ScalaMono]% time mono ScalaMono.exe
@dvdsgl
dvdsgl / UserStateObserver.cs
Created January 2, 2011 04:38
This is why MonoMac is hot
using System;
using System.Collections.Generic;
using MonoMac.Foundation;
using MonoMac.AppKit;
using MonoMac.ObjCRuntime;
using Cadenza;
namespace MySecretApp {
private static IEnumerable<TSource> SkipWhileImpl<TSource>(
IEnumerable<TSource> source,
Func<TSource, bool> predicate)
{
return SkipWhileImpl (source, (element, index) => predicate (element));
}
@dvdsgl
dvdsgl / nub_files.hs
Created June 1, 2011 03:54
Delete duplicate files in Haskell
#!/usr/bin/runhaskell
import Data.List
import Control.Monad
import System.Process (readProcess)
import System.Environment (getArgs)
import System.Directory (doesFileExist, removeFile)
@dvdsgl
dvdsgl / nub_files.rb
Created June 1, 2011 03:54
Delete duplicate files in Ruby
#!/usr/bin/ruby
ARGV.group_by {
|file| `md5 #{file}`.split.last
}.values.map {
|dups| dups.drop 1
}.flatten.each {
|dup| File.delete dup
}
@dvdsgl
dvdsgl / NSApplicationExtensions.cs
Created June 29, 2011 17:14
Extensions to NSApplication for hiding Dock icon and relaunching.
using System;
using System.IO;
using System.Diagnostics;
using MonoMac.AppKit;
using MonoMac.Foundation;
namespace Awareness
{
public static class NSApplicationExtensions
@dvdsgl
dvdsgl / .bashrc
Created January 24, 2012 23:17
SSH Agent Config
SSH_ENV="$HOME/.ssh/environment"
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
echo succeeded
chmod 600 "$SSH_ENV"
. "$SSH_ENV" > /dev/null