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
package sets | |
import "testing" | |
func BenchmarkUnitSet(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
values := make(map[int]struct{}) | |
for j := 0; j < 1000; j++ { | |
values[j] = struct{}{} | |
} |
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
# According to the go src (https://github.com/golang/go/blob/master/src/crypto/x509/sec1_test.go) | |
# this is how to use openssl to generate an EC private key. Go can't read it | |
# however. | |
# openssl ecparam -name secp521r1 -genkey -param_enc explicit -outform PEM -out $@ | |
# e.g: | |
got asn1: structure error: tags don't match (6 vs {class:0 tag:16 length:450 isCompound:true}) {optional:false ex | |
plicit:false application:false defaultValue:<nil> tag:<nil> stringType:0 set:false omitEmpty:false} ObjectIdentifier @4 | |
# For debugging the private key |
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
use std::default::Default; | |
struct Q<T> { | |
items : [T, ..10], | |
count : uint | |
} | |
impl<T : Default + Copy> Q<T> { | |
pub fn new() -> Box<Q<T>> { | |
box Q {items: [Default::default(), ..10], |
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
struct Queue<T, size> { | |
items : [T] | |
} | |
impl<T, size> Queue<T, size> { | |
pub fn new() -> Queue<T, size> { | |
Queue { items : [T, ..size] } | |
} | |
} |
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
setTimeout(function(){ | |
$scope.$apply(function(){ | |
deferred.resolve(message); | |
}); | |
}, 5) |
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
use std::util::swap; | |
#[deriving(Eq)] | |
pub enum Tree { | |
Text(~str), | |
Cons(~Tree, ~Tree), | |
Nil | |
} | |
pub fn first<'r>(tree: &'r Tree) -> &'r Tree { |
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
config.around(:each) do |example| | |
if timeout = example.metadata[:timeout] | |
Benchmark.realtime do | |
example.call | |
end.should <= timeout | |
else | |
example.call | |
end | |
end |
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
{-# LANGUAGE ExistentialQuantification #-} | |
module Main where | |
import qualified Data.List as L | |
import qualified Data.Map as Map | |
{- How to make a heteregenous list of showable items, taken from | |
- http://www.haskell.org/haskellwiki/Heterogenous_collections-} | |
data Showable = forall a . Show a => MkShowable a |
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
Time.utc(1997, 8, 4, 7, 14) |
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
def diff(a, b, file = "current.diff") | |
require 'rspec/expectations/differ' | |
differ = RSpec::Expectations::Differ.new | |
diff = differ.diff_as_object(a, b) | |
File.open(file, "w+") { |f| f.write diff } | |
system "mate", file | |
end |