Skip to content

Instantly share code, notes, and snippets.

View DAddYE's full-sized avatar

Davide D'Agostino DAddYE

  • Uber
  • San Francisco
View GitHub Profile
@DAddYE
DAddYE / freaking_npm.sh
Created January 30, 2014 21:36
Fix the freaking npm update -g
#!/bin/bash
for man in 1 3 5 7; do
ln -sf /usr/local/lib/node_modules/npm/man/man${man}/* /usr/local/share/man/man${man}
done
ln -sf /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
npm update npm -g
###
# Execute tests in parallel using multiple processes. Uses DRb to communicate
# between processes over a unix socket.
gem 'minitest', '~> 5.1.0'
require 'minitest'
require 'minitest/spec'
require 'minitest/mock'
require 'drb'
require 'drb/unix'
@DAddYE
DAddYE / BetterVim.md
Last active December 23, 2015 20:29
Better Vim
require 'fiddle'
require 'fiddle/import'
module GVL
include Fiddle
extend Importer
dlload Handle::DEFAULT
T = import_function 'rb_thread_call_without_gvl', TYPE_VOIDP,
@DAddYE
DAddYE / kafka.simple.clj
Created May 25, 2013 00:39
Kafka lazy horse
(defn messages* [& {:keys [host port topic part offset max-size]
:or {port 9092 part 0 offset 0 max-size 1000000}
:as options}]
(let [c (kafka/consumer host port)
f (kafka/fetch topic part offset max-size)
m (kafka/messages c f)
o (:offset (last m))]
(concat
(lazy-seq (messages* :host host
:port port
@DAddYE
DAddYE / guide.md
Last active December 17, 2015 09:18
Remote VisualVM

Launch on the remote host your jar with:

java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmemote.port=1098 -server -jar target/name-of-jar

Then open a ssh socket connection with:

ssh -ND 9696 remote.host
(let [log-agent (agent nil)]
(defn log
[& messages]
(send log-agent (fn [_] (apply println messages)))
(await log-agent)))
For each Ruby module/class, we have Ruby methods on the left and the equivalent
Clojure functions and/or relevant notes are on the right.
For clojure functions, symbols indicate existing method definitions, in the
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master,
ruby-to-clojure.*/* functions can be obtained from the source files in this
gist.
If no method symbol is given, we use the following notation:
desc "Generates .yml files for I18n translations"
task :translate => :environment do
models = Dir["#{Padrino.root}/{app,}/models/**/*.rb"].map { |m| File.basename(m, ".rb") }
models.each do |m|
# Get the model class
klass = m.camelize.constantize
# Avoid non ActiveRecord models
next unless klass.ancestors.include?(ActiveRecord::Base)
# config/initializers/source_maps.rb
if Rails.env.development?
module CoffeeScript
class SourceMapError < StandardError; end;
class << self
def compile script, options
script = script.read if script.respond_to?(:read)