Skip to content

Instantly share code, notes, and snippets.

@loxs
loxs / amortize_over.py
Created September 7, 2017 07:15 — forked from cdjk/amortize_over.py
amortize_over beancount plugin
# Copyright (c) 2017 Cary Kempston
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
def processes_by_type() do
procs = Enum.reduce(:erlang.processes(), %{}, fn(pid, acc) ->
initial_call = case :erlang.process_info(pid, :initial_call) do
{:initial_call, {:proc_lib, :init_p, a}} ->
case :erlang.process_info(pid, :dictionary) do
{:dictionary, d} ->
Keyword.get(d, :"$initial_call")
_ ->
{:proc_lib, :init_p, a}
end
defmodule CodeReloaderWorker do
use GenServer
require Logger
def start_link do
GenServer.start_link __MODULE__, [], name: __MODULE__
end
def init([]) do
Logger.debug "#{__MODULE__} starting"
@loxs
loxs / gist:3793738
Created September 27, 2012 12:29
riakc_action
-spec riakc_action(Action::put|get|delete|get_index|mapred|search, RiakcArgs::list()) -> term().
riakc_action(Action, RiakcArgs) ->
riakc_action(Action, RiakcArgs, 0).
riakc_action(_Action, _RiakcArgs, Tries) when Tries > 16 ->
{error, disconnected};
riakc_action(Action, RiakcArgs, Tries) ->
RiakcPid = poolboy:checkout(wsdb_riakc_pool),
try apply(riakc_pb_socket, Action, [RiakcPid|RiakcArgs]) of
{error, disconnected} ->
-module(pinger).
-behaviour(gen_server).
%% API
-export([start_link/1, pong/0]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
# -*- coding: utf-8 -*-
# Copyright (c) 2010 Metin Akat
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
// Step 1. global definition
function Map(config) {
this._init(config);
}
Map.prototype = {
_container: null,
_init: function (config) {
this._container = document.getElementById(config.container);