Skip to content

Instantly share code, notes, and snippets.

View vortizhe's full-sized avatar

Victor Ortiz vortizhe

View GitHub Profile
#!/bin/bash
# sidekiq Init script for Sidekiq
# chkconfig: 345 100 75
#
# Description: Starts and Stops Sidekiq message processor for Stratus application.
#
# User-specified exit parameters used in this script:
#
# Exit Code 5 - Incorrect User ID
# Exit Code 6 - Directory not found
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
@vortizhe
vortizhe / fix-srt.rb
Last active August 29, 2015 14:09 — forked from brenes/fix-srt.rb
#! /usr/bin/env ruby
# This small script uses the 'srt' gem to parse the srt file
# It solves problems with certain subtitle files with empty lines that make Flex crash
# You can use it with files, folders with files or even folders with subfolders with files (God bless Recursivity)
# USAGE: ruby fix-srt.rb file/to/fix.srt
# USAGE: ruby fix-srt.rb folder/with/files/to/fix
# USAGE: ruby fix-srt.rb folders/with/subfolders/to/fix
require 'rubygems'
require 'srt'
@vortizhe
vortizhe / config.ru
Last active August 29, 2015 13:56
Config.ru for rails 2.x and pow
require File.dirname(__FILE__) + '/config/environment'
run ActionController::Dispatcher.new
config.to_prepare do
::Dragonfly[:images].configure do |c|
c.define_url do |app, job, opts|
thumb = Thumb.find_by_job(job.serialize)
if thumb
app.datastore.url_for(thumb.uid)
app.cache_duration = 3600*24*7
else
app.server.url_for(job)
app.cache_duration = 3600
@vortizhe
vortizhe / extensions.fn.js
Created July 18, 2013 13:45
include array prototype
if ( !Array.prototype.include ) {
Array.prototype.include = function(element) {
for(var i = 0, len = this.length; i < len; ++i) {
if (this[i] == element) { return true; }
}
return false;
};
}
#!/bin/bash
# Change the iterm2 profile programatically
function iterm_profile {
if [[ -z $1 ]]; then
profile="Default"
else
profile=$1
fi
@vortizhe
vortizhe / formify.js
Last active December 18, 2015 12:10
Send form with link
/* Send a form with a link with data-form="#form_id"
/ You can define params="name,value name,value"
/ All params will be append to the form as hidden inputs before send it
*/
$('body').on('click', '[data-form]', function(e) {
e.preventDefault();
var el = $(this),
form = $(el.data('form')),
params;
@vortizhe
vortizhe / varnishban.sh
Created May 23, 2013 11:21
Script to purge varnish specific url
#!/bin/bash
cmd="sudo varnishadm -T localhost:6082 -S /etc/varnish/secret"
page=$(echo $1 | awk -F'/' -v OFS='/' '{sub(/https?:\/\//, ""); $1=""; print $0}')
if [ -z "$1" ]; then
echo "ERROR: please provide a URL to ban.."
exit 1
fi
@vortizhe
vortizhe / datify.js
Created May 19, 2013 09:35
Simple localización de fecha
String.prototype.datify = function() {
var months = "enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),
// Date string to parse: 2012-02-16 22:02:30 GMT
date_string = this.split(' ')[0],
date_reverse = date_string.split('-').reverse();
date_reverse[1] = months[date_reverse[1] -1];
return date_reverse.join(' ');
};