Skip to content

Instantly share code, notes, and snippets.

@fguillen
fguillen / beer_time.rb
Last active January 19, 2018 16:42
Announce the beer time
# Simple but necessary script (for Mac) to announce when the beer time is comming
# You can configure your crontab like this
# 0 17 * * 5 ruby $HOME/scripts/beer_time.rb >> /var/log/beer_time.log 2>&1
beer_hour = ARGV[0] || 18
def say(message)
`afplay /System/Library/Sounds/Hero.aiff`
`afplay /System/Library/Sounds/Hero.aiff`
`say "#{message}"`
@fguillen
fguillen / rails_log_query_select_scraper.rb
Created September 8, 2016 21:16
Script to extract, from a Rails log, all the SELECT queries and the duration of each one in a csv format
require "csv"
module Script
def self.run(input_path, output_path)
log = File.read(input_path)
lines_count = log.lines.count
index = 0
File.open(output_path, "w") do |output_file|
@fguillen
fguillen / components.translate-component.js
Last active June 14, 2016 14:02
Helper with ComputeProperty - Component version
import Ember from 'ember';
export default Ember.Component.extend({
});
@fguillen
fguillen / controllers.application.js
Last active June 14, 2016 13:09 — forked from igorstajic/controllers.application.js
Ember Helper and ComputerProperty
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
robotName: '',
robots: Ember.ArrayProxy.create({ content: Ember.A([
{ name: "Mazinger Z" },
{ name: "Lady Electric" }
])}),
actions: {
import Ember from 'ember';
function trackPropertyChanges(defaultValue) {
var value = defaultValue;
function updateChangedProperty(model, name, property, value) {
var changedProperties = model.get('changedProperties');
if (!changedProperties) {
changedProperties = Ember.Object.create();
model.set('changedProperties', changedProperties);
@fguillen
fguillen / .aliasesrc
Last active October 7, 2016 09:28
dotfiles
alias dr="cd ~/Develop/Rails/Current"
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
alias gitfast="git add . && git add -u && git commit -m 'WIP'"
alias gitci="git push -f fguillen HEAD:ci"
alias rgrep="find . \( ! -name .svn -o -prune \) -type f -print0 | xargs -0 grep"
alias raca="rake"
alias rt="ruby -Itest"
alias to="touch tmp/restart.txt"
alias deployeverywhere=" git push origin HEAD:staging && git push origin HEAD:production && cap staging deploy && cap production deploy"
@fguillen
fguillen / truncate_rails_log_files.sh
Last active August 29, 2015 14:25
Empty all Rails logs
find /var/www/*/shared/log -name "*.log" -exec truncate {} --size 0 \;
require "benchmark"
require "logger"
require "resolv"
module Script
def self.run(process_name, resolv_kind, dns_server_ip, nameserver_to_resolv)
file = File.open("/tmp/dns_resolution_stress.log", File::WRONLY | File::APPEND)
logger = Logger.new(file)
logger.level = Logger::DEBUG
@fguillen
fguillen / .aliasesrc
Last active September 7, 2016 15:11
Shell helpers
# ~/.aliasesrc
# tree visualization of your actual folder
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
# Making a fast (temporal) commit of all your changes
alias gitfast="git add . && git add -u && git commit -m 'WIP'"
# Pushing to the CI branch
alias gitci="git push -f fguillen HEAD:ci"
tail -f /var/log/nginx.log | awk '
/status:"2.."/ {print "\033[32m" $0 "\033[39m"}
/status:"5.."/ {print "\033[31m" $0 "\033[39m"}
/status:"[^25].."/ {print $0}
'