Skip to content

Instantly share code, notes, and snippets.

View mauriciozaffari's full-sized avatar

Mauricio Zaffari mauriciozaffari

View GitHub Profile
@mauriciozaffari
mauriciozaffari / circleci-dokku-deploy.md
Last active October 10, 2017 01:54
Failing from CI
remote: + declare 'desc=core app.json scripts execution'        
remote: + local 'trigger=post-deploy app_json_scripts'        
remote: + local APP=app.git        
remote: + local IMAGE_TAG=        
remote: + local PHASE_SCRIPT_KEY=postdeploy        
remote: + dokku_log_info1 'Attempting to run scripts.dokku.postdeploy from app.json (if defined)'        
remote: + declare 'desc=log info1 formatter'        
remote: + echo '-----> Attempting to run scripts.dokku.postdeploy from app.json (if defined)'        
remote: -----> Attempting to run scripts.dokku.postdeploy from app.json (if defined)        

remote: + execute_script app.git '' postdeploy

remote: + declare 'desc=core app.json scripts execution'
remote: + local 'trigger=post-deploy app_json_scripts'
remote: + local APP=app
remote: + local IMAGE_TAG=
remote: + local PHASE_SCRIPT_KEY=postdeploy
remote: + dokku_log_info1 'Attempting to run scripts.dokku.postdeploy from app.json (if defined)'
remote: + declare 'desc=log info1 formatter'
remote: + echo '-----> Attempting to run scripts.dokku.postdeploy from app.json (if defined)'
-----> Attempting to run scripts.dokku.postdeploy from app.json (if defined)

remote: + execute_script app '' postdeploy

@mauriciozaffari
mauriciozaffari / gist:4671619
Created January 30, 2013 08:22
Optimize all images in the current directory
find . -iname "*.png" | xargs -n 1 -P 2 optipng -o7
find . -iname "*.jpg" | xargs -n 1 -P 2 jpegoptim --strip-all
find . -iname "*.gif" | xargs -n 1 -P 2 gifsicle -O2 -b
@mauriciozaffari
mauriciozaffari / gist:1150156
Created August 16, 2011 20:56
Keep track of classes including the module
ruby-1.9.2-p180-patched :001 > module Test
ruby-1.9.2-p180-patched :002?> def self.included(base)
ruby-1.9.2-p180-patched :003?> @classes ||= []
ruby-1.9.2-p180-patched :004?> @classes << base
ruby-1.9.2-p180-patched :005?> end
ruby-1.9.2-p180-patched :006?> def self.classes
ruby-1.9.2-p180-patched :007?> @classes
ruby-1.9.2-p180-patched :008?> end
ruby-1.9.2-p180-patched :009?> end
=> nil
require "json"
require "open-uri"
require "googlemaps_polyline"
start = "Chicago"
stop = "Texas"
request_str = "http://maps.googleapis.com/maps/api/directions/json?sensor=false&alternatives=true&"
request_str += "origin=#{URI.encode start}&"
request_str += "destination=#{URI.encode stop}"
require 'shellwords'
class Widget
def self.parse_widgets(content)
regex = /\[widget (.+)\]/
content =~ regex
params = Hash[*Shellwords.shellwords($1).map{ |s| s.split('=', 2) }.flatten]
widget = Kernel.const_get(params.delete("type")).render(params)
widget ? content.gsub(regex, widget) : content