Skip to content

Instantly share code, notes, and snippets.

View fabioyamate's full-sized avatar

Fabio Yamate fabioyamate

View GitHub Profile
@fabioyamate
fabioyamate / extract.sh
Created May 14, 2012 03:26
One line script to extract multiples rar files, with historic of ones already extracted
# Extract multiple rar files in subdirs from torrent files
#
# it doesn't extract files that have been previously. Always run the script file in
# the same dir as extrected.list, since it store path
#
# 1. ls **/*.rar - look up to any rar files in sub dirs
# 2. ignores all files that matches ones in the extracted.lst file
# 3. appends the non-extracted files to the lst file
# 4. for each rar file, extract them in the current directory
#
@fabioyamate
fabioyamate / redis_clean.rb
Created June 1, 2012 20:44
cleanup resque retry
Redis.new.tap { |redis|
["resque:delayed*", "resque:resque-retry*", "resque:failure_resque-retry*"].map { |rk|
redis.keys(rk).map { |k| redis.del(k) }
}
}
@fabioyamate
fabioyamate / yui.html
Last active October 5, 2015 18:58
YUI snippet to start working
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>YUI Snippet</title>
<link rel="stylesheet" href="http://rawgithub.com/necolas/normalize.css/master/normalize.css">
<script src="http://rawgithub.com/LeaVerou/prefixfree/gh-pages/prefixfree.min.js"></script>
</head>
<body>
<div id="container"></div>
@fabioyamate
fabioyamate / hundred.rb
Created June 20, 2012 02:42
Finding expression that evaluate to 100
require 'pp'
require 'benchmark'
# compute all possible expressions to the given string of digits to a given set of operations.
# the digits are kept in order
#
# ex. 1234
# generates: 1234, 1+234, 1-234, 12+34, 123-4...
#
# but selects only expressions that evaluate to a given value
@fabioyamate
fabioyamate / datomic-queries.clj
Created April 30, 2015 16:32
Datomic Queries cheat-sheet
;;; Replace entity with the schema
{:find [...]
:in [...]
:where [...]}
;;; eav
[?e ?a ?v ?tx]
;;; txInstant
@fabioyamate
fabioyamate / Gemfile
Created February 26, 2013 18:35
Export MongoDB system.profile collection to csv format with some friendly visualization
source "https://rubygems.org"
gem "mongo", "~> 1.8.2"
gem "bson_ext", "~> 1.8.2"
gem "actionpack", "~> 3.2.12"
@fabioyamate
fabioyamate / model.rb
Created February 26, 2013 20:36
MongoDB Moped rename collection
# Since Mongoid switched to its own driver, many of the mongo API
# (available in mongo-ruby-drive) are missing. This is allows you
# to rename a collection thru command message.
#
# Be aware that the API constantly changes in mongoid
#
# Mongoid (3.1.0), Moped (1.4.2)
class MyModel
include Mongoid::Document
@fabioyamate
fabioyamate / calendar.html
Created March 16, 2013 05:00
YUI Calendar Picker
<style>
.yui3-overlay-hidden {
visibility: hidden;
}
</style>
<input type="text" id="input-date" />
<div id="calendar-overlay">
<div class="yui3-widget-bd" id="calendar"></div>
@fabioyamate
fabioyamate / monads.clj
Last active December 15, 2015 06:49
Some notes to use repl with clojure libraries
; might not be the proper way to do it, but it is how I was able to run repl with some libraries
; in this case I created a lein project, add the monad dependency to the project, and then started
; a repl session, and run:
;
; need to include pomegranate
;
; it seems to be the best way to deal with it
;
(use '[cemerick.pomegranate :only (add-dependencies)])
(add-dependencies :coordinates '[[org.clojure/algo.monads "0.1.4"]])
@fabioyamate
fabioyamate / answer.clj
Last active December 15, 2015 11:18
Given a list of list of integers, return the first item in each sublist, in a way that no duplication is occurred
(defn add-first-uniq [target coll]
(cond (not (contains? target (first coll)))
(conj target (first coll))
:else
(add-first-uniq target (rest coll))))
(reduce add-first-uniq
#{}
'((1 2 3) (1 2) (4 5)))