Skip to content

Instantly share code, notes, and snippets.

View fabioyamate's full-sized avatar

Fabio Yamate fabioyamate

View GitHub Profile
From d6baaf8ed0f0cddbd311210042f3b91fa800b737 Mon Sep 17 00:00:00 2001
From: Fabio Yamate <fabio.yamate@plataformatec.com.br>
Date: Mon, 3 Oct 2011 01:18:07 -0300
Subject: [PATCH] Add checkboxes collection bootstrap.
---
lib/simple_form/action_view_extensions/builder.rb | 7 ++++---
lib/simple_form/components/labels.rb | 4 ++--
lib/simple_form/inputs/boolean_input.rb | 8 ++++++--
3 files changed, 12 insertions(+), 7 deletions(-)
@fabioyamate
fabioyamate / mode.rb
Created November 23, 2011 12:37
Paperclip - remove attachment
class Model < ActiveRecord::Base
has_attached_file :icon
has_removable_file :icon
end
@fabioyamate
fabioyamate / sr.bash
Created April 26, 2012 21:26
Replacing string in with sed
# replaces all string matches in files
#
# USAGE:
# sr $from $to
# sr $from $to $type
#
# Arguments:
# $from - from value
# $to - to value
# $type - file type. DEFAULT: *.rb
@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 / alias.bash
Last active February 20, 2016 03:41
jQuery, AngularJS snippet to start working
# Add an alias to your .bash_profile
#
# alias sjquery='curl https://raw.github.com/gist/2884873/jquery.html -L -o'
# alias sangular='curl https://raw.github.com/gist/2884873/angular.html -L -o'
#
# Updates:
# * using http://rawgithub.com service to include files directly from server
#
# Usage
#
@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 / mover
Last active May 16, 2024 17:17
unRAID mover script
#!/bin/bash
# This is the 'mover' script used for moving files from the cache disk to the
# main array. It is typically invoked via cron.
# After checking if it's valid for this script to run, we check each of the top-level
# directories (shares) on the cache disk. If, and only if, the 'Use Cache' setting for the
# share is set to "yes", we use 'find' to process the objects (files and directories) of
# that directory, moving them to the array.
@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"