Skip to content

Instantly share code, notes, and snippets.

pmap(Mapper,XS,_) when length(XS) =< 2-> %async not really useful here
[Mapper(X) || X <-XS];
pmap(Mapper,XS,Timeout)->
Myself = self(),
[spawn(fun()-> Myself ! Mapper(X) end) || X <- XS],
map_receive(length(XS),[],Timeout).
map_receive(0,Acc,_) -> Acc;
map_receive(N,Acc,Timeout)->
receive
@abolibibelot
abolibibelot / gist:5859432
Created June 25, 2013 15:31
naive scikitlearn benchmark
fname = '/Users/yann/temp/products.txt'
#vec = CountVectorizer(input='content',analyzer=str.split,tokenizer=None)
features = []
y = []
for line in open(fname,'r'):
c,f = line.split(',',1)
features.append(f)
y.append(c)
print datetime.now(),"splitting data sets"
//Works
public async void Write(byte[] buffer)
{
var len = buffer.Length;
Size += len;
await _stream.WriteAsync(buffer, 0, len);
}
var bytes = Encoding.UTF8.GetBytes(item);
blob.Write(bytes);
Catastrophic failure: System.InvalidOperationException: Hashtable.Enumerator: snapshot out of sync.
at System.Collections.Hashtable+Enumerator.FailFast () [0x00000] in <filename unknown>:0
at System.Collections.Hashtable+Enumerator.MoveNext () [0x00000] in <filename unknown>:0
at System.Net.EndPointListener.Close () [0x00000] in <filename unknown>:0
at System.Net.EndPointManager.RemoveEndPoint (System.Net.EndPointListener epl, System.Net.IPEndPoint ep) [0x00000] in <filename unknown>:0
at System.Net.EndPointListener.CheckIfRemove () [0x00000] in <filename unknown>:0
at System.Net.EndPointListener.RemovePrefix (System.Net.ListenerPrefix prefix, System.Net.HttpListener listener) [0x00000] in <filename unknown>:0
at System.Net.EndPointManager.RemovePrefixInternal (System.String prefix, System.Net.HttpListener listener) [0x00000] in <filename unknown>:0
at System.Net.EndPointManager.RemoveListener (System.Net.HttpListener listener) [0x00000] in <filename unknown>:0
at System.Net.HttpListener.Clo
@abolibibelot
abolibibelot / gist:6359206
Last active December 21, 2015 20:09
This snippet traps double clicks in a Sublime Text plugin. I kid you not.
trapping_views = {VIEW_BREAKPOINT: dbg.callbacks.on_breakpoints_dblclick,VIEW_STACK: dbg.callbacks.on_stack_dblclick}
class UnityTrapDoubleclickCommand(TextCommand):
def run_(self, args):
print 'on dbl click'
special_handler = trapping_views.get(self.view.name(),None)
print args
if not special_handler is None:
line = self.view.line(self.view.sel()[0])
try unsafe(PVS) of
Res -> Res
catch
A:B -> lager:error("Problem:~p stacktrace:~p",[[A,B], erlang:get_stacktrace()]),
case {A,B} of
{exit,_} -> exit(B);
{error,_} -> error(B);
{exception,_} -> throw(B)
end
end.
@abolibibelot
abolibibelot / ohai
Last active January 3, 2016 12:28
Criteo programming ad in lolcode
HAI
BTW this kinda follows the lolcode 1.2 spec http://lolcode.org/1.2_spec.html
I HAZ A ANSWER
I HAZ A INDEX
BTW defining a function
HOW IZ ASK YR QUESTION
VISIBLE QUESTION
GIMME RESPONZ