Skip to content

Instantly share code, notes, and snippets.

View paulodiovani's full-sized avatar

Paulo Diovani Gonçalves paulodiovani

View GitHub Profile
@paulodiovani
paulodiovani / deploy.rake
Created April 29, 2016 21:03
Deploy rake task for Heroku Pipelines
namespace :deploy do
DEVELOPMENT_APPS = ['example-development']
STAGING_APPS = ['example-staging']
PRODUCTION_APPS = ['example', 'example2', 'example-demo']
REMOTE = ENV['REMOTE_HOST'] || 'git@heroku.com'
def shell_cmd(cmd)
begin
sh "#{cmd}"
rescue
@paulodiovani
paulodiovani / video-to-gif.sh
Created April 28, 2016 20:24
Convert latest video on a directory to gif
#!/bin/sh
# Convert the latest *.webm video (works with other formats)
# in directory to *.gif
# At the end, ask for deletion of origina video
ffmpeg -i "$(ls -dt *.webm | head -1)" \
-filter_complex "fps=10,scale=1024:-1:flags=lanczos" screencast.gif &&
rm -i "$(ls -dt *.webm | head -1)"
@paulodiovani
paulodiovani / api models Locations.js
Created January 6, 2016 23:17 — forked from juanpasolano/api models Locations.js
seed database on sails js
/**
* Locations.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
seedData:[
@paulodiovani
paulodiovani / index.coffee
Created October 9, 2015 20:38
Write request headers and data to stdout
http = require('http')
###
Usage:
coffee index.coffee 3000
###
server = http.createServer (req, res) ->
console.log "\n\nHEADERS:\n", req.headers
req.on 'data', (data) ->
@paulodiovani
paulodiovani / merge-pr.sh
Last active September 1, 2015 19:08
Merges branchs or commits from pull-requests as GitHub does
#!/bin/bash
###
# Merge commits or branches as GitHub Pull Requests
#
# Usage: ./merge-pr.sh COMMIT PRNUMBER BRANCHNAME
#
# COMMIT: Commit or branch name to merge
# PRNUMBER: Number of the pull request being merged (used in commit message)
# BRANCHNAME: Branch name being merged (used in commit message)
@paulodiovani
paulodiovani / meme-create.sh
Created July 16, 2015 19:00
Create an internet meme from an image
#!/bin/bash
convert image-original.jpg -weight 900 -pointsize 400 -strokewidth 8 \
-draw "gravity north stroke black fill white text 0,200 'DO NOT' " \
-draw "gravity south stroke black fill white text 0,200 'PANIC' " \
image-meme.jpg
@paulodiovani
paulodiovani / singleton.coffee
Last active August 29, 2015 14:13
Singleton example using Require.js + BackBone.js + CoffeeScript
define 'components/singleton', [], ->
###
Singleton class
###
class Singleton extends Backbone.View
# @static
@getInstance = ->
@_instance ?= new @
@paulodiovani
paulodiovani / bdd_spec_test.php
Created November 19, 2014 12:26
Proposal for a new PHP Spec Test framework
<?php
/**
* This is a proposal for a new PHP test framework,
* based on the Mocha (http://mochajs.org/) dsl
*
* ## Features
*
* * Simple, easy to read
* * Non object oriented tests
* * Extensible
http = require 'http'
through = require 'through'
XmlStream = require 'xml-stream'
http.get 'http://example.com/file.xml', (res) ->
res.setEncoding 'utf-8'
res.on 'error', console.error
# create a stream to clean non-ascii characters, because
# XmlStream fails to parse XMLs with some chars (pasted from MS Word, mostly)
@paulodiovani
paulodiovani / TelaExemplo.java
Created June 25, 2014 04:30
Uma tela padrão para posicionamento relativo de campos, apenas para teste de exibição de componentes.
package exemplo;
import javax.swing.*;
import java.awt.*;
/**
* Created by diovani on 25/06/14.
*/
public class TelaExemplo extends JFrame {
// padrões, para controlar posição dos campos