Skip to content

Instantly share code, notes, and snippets.

View lucasdavila's full-sized avatar
🌈

Lucas D'Avila lucasdavila

🌈
  • SC, Brasil
View GitHub Profile
@lucasdavila
lucasdavila / ffmpeg.sh
Last active August 29, 2015 14:12
Export video thumbnail with ffmpeg
ffmpeg -itsoffset -7 -i video.mov -vcodec mjpeg -f rawvideo -s 624x416 image.jpg
@lucasdavila
lucasdavila / routes-group_user.js
Last active August 29, 2015 14:21
Backbone.js router testing
/*global define*/
define([
'routes/base',
'jquery',
'views/group_users'
], function (BaseRouter, $, GroupUsersView) {
'use strict';
var GroupUserRouter = BaseRouter.extend({
@lucasdavila
lucasdavila / menu.js
Created October 8, 2011 04:05
Menu JavaScript
function Element(childs, options, tag) {
this.initialize(childs, options, tag);
}
Element.prototype.initialize = function(childs, options, tag) {
this.childs = childs || [];
if (this.childs.constructor != Array)
this.childs = [this.childs];
this.options = options || {};
@lucasdavila
lucasdavila / passenger_status.rb
Created December 21, 2011 15:18 — forked from dan-manges/passenger_status.rb
munin plugin for passenger (adapted for rvm)
#!/usr/bin/env ruby
def output_config
puts <<-END
graph_category App
graph_title passenger status
graph_vlabel count
sessions.label sessions
max.label max processes
@lucasdavila
lucasdavila / Munin Passenger Phusion Memory Stats.rb
Created December 21, 2011 15:18 — forked from jamiew/Munin Passenger Phusion Memory Stats.rb
munin plugin to monitor Passenger Phusion memory stats (adapted for rvm)
#!/usr/bin/env ruby
# put in /etc/munin/plugins and restart munin-node
# by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
# NOTE: you might need to add munin to allow passwordless sudo for passenger-memory-stats
def output_config
puts <<-END
graph_category App
graph_title Passenger memory stats
graph_vlabel count
@lucasdavila
lucasdavila / install_munin_and_passenger_plugins.sh
Created December 21, 2011 16:36
Install Munin and Passenger Plugins
# to use this gist execute: $ rm -f 1506695 && wget https://raw.github.com/gist/1506695 && sh 1506695
# refs to http://www.alfajango.com/blog/how-to-monitor-your-railspassenger-app-with-munin/
echo "Installing munin..."
sudo apt-get install munin munin-node -y
echo ;
echo "Removing previous links for passenger_status and passenger_memory_stats..."
sudo rm /etc/munin/plugins/passenger_memory_stats
sudo rm /etc/munin/plugins/passenger_status
@lucasdavila
lucasdavila / codigo.py
Created February 10, 2012 02:32
Código limpo para ler
# sem linhas em branco, código não tão junto
if current_user.has_role('admin')
cases = cases.of_product(product)
elif current_user.has_role('employee')
cases = cases.of_product_accessible_by_employee(product, current_user)
elif current_user.has_role('customer')
cases = cases.of_product_accessible_by_customer(product, current_user)
@lucasdavila
lucasdavila / uncheck_all_checkboxes_except_this_one.js
Created April 5, 2012 14:06
Uncheck all checkboxes except this one
// jquery
var $checkboxes = $("input[type='checkbox']");
$checkboxes.change(function(){
$checkboxes.not(this).removeAttr('checked');
});
@lucasdavila
lucasdavila / delete_gedit_temp_file_in_nested_dirs.sh
Created August 8, 2012 13:11
Delete Gedit temp file in nested dirs
find -type f -iname "*~" -exec rm -f {} \;
@lucasdavila
lucasdavila / sort_array_by_key.php
Created August 15, 2012 00:40
Sort array by key in php
<?php
// util function to be used by sortArrayByKey function
function _arraySorterByKey($key, $array, $otherArray) {
$a = $array[$key];
$b = $otherArray[$key];
if ($a == $b)
return 0;