Skip to content

Instantly share code, notes, and snippets.

View zampino's full-sized avatar

Andrea Amantini zampino

View GitHub Profile
@zampino
zampino / xmonad.hs
Created October 27, 2014 10:19
~/.xmonad/xmonad.hs
-- === MODULE SECTION ===
import XMonad
-- import XMonad.Config.Gnome
import qualified XMonad.StackSet as W
import XMonad.Util.EZConfig (additionalKeys)
import qualified Data.Map as M
import XMonad.Hooks.DynamicLog
import XMonad.Prompt
import XMonad.Prompt.Shell
@zampino
zampino / base_collection.rb
Last active September 13, 2018 13:27
Mongo DB hierarchical aggregation
class BaseCollection
include Mongoid::Document
aggregate(:daily,
map: %Q(function() {
var key = {
year_day: this.year_day,
year_week: this.year_week,
year_month: this.year_month
};
@zampino
zampino / struct_extension.ex
Last active July 20, 2022 00:32
Elixir Extending a Struct
defmodule DSL do
defmacro extend_struct struct_mod, keyword do
quote do
defstruct Keyword.merge(Map.to_list(Map.from_struct(unquote(struct_mod).__struct__)), unquote(keyword))
end
end
end
@zampino
zampino / deps.coffee
Last active August 29, 2015 14:16
dependencies
class Manager
@injects 'Task', 'Store', '...'
constructor: ->
$http.get('/tasks').success (data)->
# works for nested resources too
Store.tasks.push new Task(item) for item in data
class Store
constructor: ->
def enqueued_resources_for(klass, resource_type: nil)
jobs = enqueued_jobs.find_all { |_job| _job[:job] == klass }
resources = jobs.map {|job|
gid = job[:args].first['_aj_globalid']
gid && GlobalID::Locator.locate(gid)
}
if resource_type
resources = resources.find_all { |resource| resource.is_a?(resource_type) }
end
@zampino
zampino / genstage_subs.ex
Last active November 4, 2016 17:57
meetup presentation code
GenStage.async_subscribe(node, to: other)
@zampino
zampino / h5py.py
Created December 4, 2016 21:32
julia context eval + hfs5
pip install h5py
Collecting h5py
Downloading h5py-2.6.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.5MB)
100% |████████████████████████████████| 4.5MB 152kB/s
Collecting numpy>=1.6.1 (from h5py)
Downloading numpy-1.11.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.9MB)
100% |████████████████████████████████| 3.9MB 176kB/s
Collecting six (from h5py)
Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: numpy, six, h5py
@zampino
zampino / genstage_playground.ex
Created May 11, 2017 09:57
emitter / compressor example
defmodule GenstagePlayground do
defmodule Emitter do
use GenStage
require Logger
defstruct [counter: 0, demand: 0, buffer: []]
def add(), do: GenStage.call(__MODULE__, :in)
def start_link(), do: GenStage.start_link(__MODULE__, :ok, name: __MODULE__)
def init(:ok) do
@zampino
zampino / jupyter.sh
Created April 20, 2018 08:56
Jupyter Guide
jupyer kernelspec list
@zampino
zampino / deps.edn
Created October 11, 2019 08:57
Global deps edn (~/.clojure/deps.edn)
;; The deps.edn file describes the information needed to build a classpath.
;;
;; When using the `clojure` or `clj` script, there are several deps.edn files
;; that are combined:
;; - install-level
;; - user level (this file)
;; - project level (current directory when invoked)
;;
;; For all attributes other than :paths, these config files are merged left to right.
;; Only the last :paths is kept and others are dropped.