Skip to content

Instantly share code, notes, and snippets.

View zampino's full-sized avatar

Andrea Amantini zampino

View GitHub Profile
@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 / 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 / refinements_spec.rb
Last active January 2, 2016 17:39
Minimal example about ruby 2.1.0 refinements
module MyRefinements
refine Object do
def nice_name
"wow I am a #{self.class}"
end
end
refine Hash do
def foo
"foo"
# Node A:
# iex --sname "nodea"
Process.register self, :iex
# Blocking
receive do
{ :hello, pid } ->
IO.puts "Hello from #{inspect(pid)}"
end
@zampino
zampino / exposures.rb
Created March 28, 2013 19:07
Grape with Exposures
require 'ostruct'
require 'grape-entity'
require 'active_support/concern'
module Exposable
extend ActiveSupport::Concern
# included do
# base = self
# end
# from https://github.com/tomz/liblinear-ruby-swig/blob/master/ext/extconf.rb
require 'mkmf'
CONFIG["LDSHARED"] = case RUBY_PLATFORM
when /darwin/
"g++ -dynamic -bundle -undefined suppress -flat_namespace"
else
"g++ -shared"
end
$CFLAGS = "#{ENV['CFLAGS']} -Wall -O3 "
@zampino
zampino / struct_draft.rb
Created December 17, 2012 10:12
struct draft
require 'active_support/core_ext'
require 'ostruct'
# require 'debugger'
module Factory
PRIMARY_KEY_NAME = "name"
def self.build(node, content, options={})
Factory.for(node, content, options).produce
node
@zampino
zampino / .bash_profile
Last active December 9, 2015 18:18
bash profile ml
source ~/.bash_colors
######### GIT #######################
source /usr/local/git/contrib/completion/git-prompt.sh
source /usr/local/git/contrib/completion/git-completion.bash
GIT_PS1_SHOWDIRTYSTATE=true
# GIT_PS1_SHOWUPSTREAM=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWSTASHSTATE=true
export PS1='\[$COLOR_YELLOW\]\u@\h:\[$COLOR_MAGENTA\]\w\[$COLOR_LIGHTCYAN\]$(__git_ps1) \[$COLOR_RESET\]'
@zampino
zampino / .emacs@mneme
Last active October 13, 2015 01:27
emcs main config @mneme
(global-auto-revert-mode 1)
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(global-linum-mode t)
;; KEY BINDINGS
(global-set-key [s-right] 'next-multiframe-window)
(global-set-key [s-left] 'previous-multiframe-window)
(global-set-key (kbd "s-o") 'find-file)
(global-set-key (kbd "s-n") 'new-frame)
@zampino
zampino / git-config@mneme
Last active October 13, 2015 01:27
git config --global @mneme
# git config --global --list
user.name=Andrea Amantini
user.email=andrea@devolute.org
color.ui=true
github.user=zampino
core.editor=emacs
core.excludesfile=/home/andrea/.gitignore
alias.co=checkout
alias.a=add
alias.s=status