Skip to content

Instantly share code, notes, and snippets.

result on client:
> free -m
total used free shared buffers cached
Mem: 7680 5190 2489 629 40 939
-/+ buffers/cache: 4211 3469
Swap: 0 0 0
> erl
Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:4:4] [async-threads:10]
2> redbug:start("lists:nth -> return").
{30,1}
3> lists:nth(5, [a, b, c, d]).
13:29:13 <0.33.0>(dead) {lists,nth,[5,[a,b,c,d]]}
13:29:13 <0.33.0>(dead) {lists,nth,[4,[b,c,d]]}
13:29:13 <0.33.0>(dead) {lists,nth,[3,[c,d]]}
var MyApp = angular.module('MyApp');
MyApp.factory('msgBus', ['$rootScope', function($rootScope) {
var msgBus = {};
msgBus.emitMsg = function(msg, data) {
data = data || {};
$rootScope.$emit(msg, data);
};
msgBus.onMsg = function(msg, func, scope) {
var unbind = $rootScope.$on(msg, func);
if (scope) {
start_deps(X) when not is_list(X) ->
start_deps([X]);
start_deps([]) ->
ok;
start_deps([A|T]) ->
case application:ensure_started(A) of
ok ->
start_deps(T);
@maximvl
maximvl / gist:27fcbd8c5f82c9925342
Created August 21, 2014 20:25
julia repl crash
julia> type(Union)
()
end
Warning: imported binding for Union overwritten in module Main
julia> Union()
ERROR: `Union` has no method matching Union()
@maximvl
maximvl / gist:812144897361179bfc24
Last active August 29, 2015 14:05
typing problems with consonants array
const vovels = ['a', 'o', 'e', 'u', 'y', 'i']
const consonants = filter(x -> x != nothing,
[i in vovels ? nothing : i
for i in 'a':'z'])
const vrx = Regex("[$(convert(String, vovels))]{3}\$")
const crx = Regex("[$(convert(String, consonants))]{3}\$")
@maximvl
maximvl / t.jl
Last active August 29, 2015 14:05
temperature converter
module Tconverter
export convert
import Base.convert
abstract Temperature
type Celsius <: Temperature
value :: Real
end
MemTotal: 5801372 kB
MemFree: 2391956 kB
Buffers: 774192 kB
Cached: 1015376 kB
SwapCached: 0 kB
Active: 1327312 kB
Inactive: 753192 kB
Active(anon): 493284 kB
Inactive(anon): 77992 kB
Active(file): 834028 kB
@maximvl
maximvl / key.ml
Last active August 29, 2015 14:07
let lwt_call f =
let t1,w1 = Lwt.wait () in
Lwt.ignore_result
(let res = f () in
Lwt.wakeup w1 res;
Lwt.return_unit);
t1
;;
let read_direction dir =
keyOrder = ['first_name', 'last_name', 'email', 'password1',
'password2', 'post', 'birthday', 'phone', 'city']
res = OrderedDict()
for key in keyOrder:
res[key] = self.fields.get(key)
self.fields = res