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 dict_map (dict : System.Collections.IDictionary) = | |
let values = ref (Map<'a,'b> []) | |
for obj in dict do | |
let de = obj :?> System.Collections.DictionaryEntry | |
values := Map.add (de.Key :?> 'a) (de.Value :?> 'b) !values | |
!values | |
System.Environment.GetEnvironmentVariables() |> dict_map<string,string> |
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/env ruby | |
# Some of the first ruby I wrote, in 2005. So it's not very idiomatic :-| | |
# GDK_POINTER_MOTION_HINT_MASK | |
require 'gtk2' | |
require 'pango' | |
require 'mathn' | |
require 'getoptlong' |
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
$ ./stap -p2 --vp 04 -e 'probe process("/bin/ls").function("main") { }' | |
Extracting build ID. | |
blacklist regexps: | |
blfn: ^(.^)$ | |
blfn_ret: ^(_start)$ | |
blfile: ^(.^)$ | |
blsection: ^(.^) | |
dwarf_builder::build for /bin/ls | |
parse 'main', func 'main' | |
pattern '/bin/ls' matches module '/bin/ls' |
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
== id == | |
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) | |
== stap -V == | |
Systemtap translator/driver (version 2.9/0.163, non-git sources) | |
Copyright (C) 2005-2015 Red Hat, Inc. and others | |
This is free software; see the source for copying conditions. | |
enabled features: AVAHI BOOST_SHARED_PTR BOOST_STRING_REF LIBXML2 NLS NSS TR1_UNORDERED_MAP | |
== which stap == | |
/usr/bin/stap | |
== cat /root/.systemtap/rc == |
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 MatchIt | |
class Any | |
def ===( other ) true end | |
end | |
I = Any.new | |
module PatternMatch | |
refine Array do | |
def ===( other ) |
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
require_relative 'waitron' # Waitron is a simple future | |
module Enumerable | |
# Return the first item for which bloc returns truthy. | |
# Obviously there's indeterminacy if there are several such items in the collection. | |
# This works best when bloc is waiting for something. Because GVL. | |
# Obviously bloc should be careful about mutable shared state | |
def pfind( threads: 4, &bloc ) | |
q = SizedQueue.new threads |
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
RD = React.DOM | |
class @ThingSearchResults extends React.Component | |
@defaultProps = | |
things: [] | |
@propTypes: | |
select_handler: React.PropTypes.func | |
deselect_handler: React.PropTypes.func |
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
require 'thwait' | |
# Synchronous hand-off between two threads. | |
# Both threads will block until a transfer is successful. | |
class Rendevous | |
def initialize | |
@mutex = Mutex.new | |
@send_flag = ConditionVariable.new | |
@recv_flag = ConditionVariable.new | |
@container = [] |
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
# One-shot thread-safe value store with blocking explicit semantics, aka | |
# Future/Promise/IVar https://en.wikipedia.org/wiki/Futures_and_promises. | |
# | |
# In a sense, it's a state machine pattern for 3 states (fresh/unset, | |
# valued/set and exception). Apparently this is the same set of states as the | |
# PromiseA+ specification. Who knew? | |
# | |
# It can be initialised with a value, or the value can be assigned later on. | |
# | |
# You use it like this: |