Skip to content

Instantly share code, notes, and snippets.

View qxjit's full-sized avatar

David Vollbracht qxjit

  • Flipstone Technology Partners, Inc
View GitHub Profile
@qxjit
qxjit / scone_creep.idr
Created May 1, 2014 15:33
Scone Creep Delicious when Scope Creep is not?
data Creep = SomeCreep
data Scope a = SomeScope a
data Scone a = AScone a
data Taste a =
Disgusting
| Yucky
| Edible
| Yummy
| Delicious
type A =
| A of int
| B of string
> List.choose (|A|_|) [ A 3; B "foo"];;
List.choose (|A|_|) [ A 3; B "foo"];;
-------------^^^^^
/vagrant/stdin(6,14): error FS0039: The value or constructor '|A|_|' is not defined
Excepting deserializing game: System.ArgumentNullException: Argument cannot be null.
Parameter name: array
at Microsoft.FSharp.Collections.ArrayModule.Fold[EntityId,SetTree`1] (Microsoft.FSharp.Core.FSharpFunc`2 folder, Microsoft.FSharp.Collections.SetTree`1 state, CoinDB.EntityId[] array) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Collections.SetTreeModule.ofArray[EntityId] (IComparer`1 comparer, CoinDB.EntityId[] l) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Collections.FSharpSet`1[CoinDB.EntityId].OnDeserialized (StreamingContext context) [0x00000] in <filename unknown>:0
at System.Runtime.Serialization.SerializationCallbacks.Invoke (System.Collections.ArrayList list, System.Object target, StreamingContext context) [0x00000] in <filename unknown>:0
at System.Runtime.Serialization.SerializationCallbacks.RaiseOnDeserialized (System.Object target, StreamingContext contex) [0x00000] in <filename unknown>:0
at System.Runtime.Serialization.ObjectManager.RaiseOnDeserializedE
class Array
alias_method :>>, :delete
end
a = []
a << 1
a << 2
a << 3
@qxjit
qxjit / foo.rb
Created March 6, 2012 16:22 — forked from jbrechtel/foo.rb
foo
def foo(nums)
h = Hash.new([])
nums.each { |n| h[n] << n }
puts h.inspect
puts h['foo']
end
#YETANOTHERREASONMUTABLESTATEISTERRIBLE
@qxjit
qxjit / class_variable_hijack.rb
Created February 7, 2012 18:19
Please tell me this is a bug
# ruby -v
# ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.8.0]
#
# note that you shouldn't use class variables anyhow...
class Foo
@@in_foo = 2
def self.in_foo; @@in_foo; end
end
@qxjit
qxjit / Boca Golf 2011-01-19
Created January 20, 2011 01:43
qxjit's Golfed solution for sanitize
def sanitize(w,s)s.tr('/*-._\\','').sub(/#{w}/i,'*'*w.size)end
@qxjit
qxjit / gist:760707
Created December 31, 2010 04:16
Test Gist for Boca Golf
def reverse(a) a.reverse; end
@qxjit
qxjit / new_line_message_send.rb
Created November 20, 2010 13:03
Sending messages in ruby on new line without a trailing '.'
# This program prints out:
#
# Reversed: god
# God
#
# I originally found it in the documentation
# of BasicObject#tap in "Programming Ruby 1.9" by Dave Thomas
#
puts "dog"