This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::Base.logger = Logger.new(STDOUT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Micro-optimized, with extra-function (so it's not redefined at each call) | |
delegate = (delegatorConstructor, delegeeProp, method) -> | |
delegatorConstructor.prototype[ method ] = -> | |
this[ delegeeProp ][ method ].apply( this[ delegeeProp ], arguments ) | |
Function.prototype.delegate = ( methodNames..., toProp ) -> | |
delegeeProp = toProp.to | |
for method in methodNames | |
delegate(this, delegeeProp, method) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In New Relic > Monitoring > Database > Show SQL Trace, | |
# we get a table of slow queries sortable by time spent or by number of occurrences | |
# This allows us to multiply these 2 values to get an actual amount of pain (qty * unit_cost) | |
# Copy/Paste this in Sublime's Shell Turtlestein: | |
| awk -F\t '{ gsub(/[^0-9]/, "", $2); print $2*$3 "\t" $1 }' | sort -nr | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List cron jobs for all users | |
for user in $(cut -f1 -d: /etc/passwd); do sudo crontab -u $user -l; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find duplicates in a textual list | |
# | |
# Just: | |
# * paste the list into Sublime | |
# * paste this line in Shell Turtlestein (plugin) invite | |
# * replace $1 by $<element_column_index> if there are more than 1 column | |
# * add flag -F if columns separator is not default (spaces and tabs) | |
# | |
# Can be easily adapted for VIM, it's just awk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Parse category migrations by ID from Excel files | |
# | |
# Just: | |
# * paste from the spreadsheet into Sublime | |
# * paste this line in Shell Turtlestein (plugin) invite | |
# * replace $4 and $1 by $<category_column_index> and $<id_column_index> (1-based index) | |
# | |
# Can be easily adapted for VIM, it's just awk | |
NewerOlder