Skip to content

Instantly share code, notes, and snippets.

View rogeriopvl's full-sized avatar
🏄‍♂️

Rogério Vicente rogeriopvl

🏄‍♂️
View GitHub Profile

Keybase proof

I hereby claim:

  • I am rogeriopvl on github.
  • I am rogeriopvl (https://keybase.io/rogeriopvl) on keybase.
  • I have a public key whose fingerprint is 11CB F255 BB75 3830 A7CF CF5D 4347 B89A F752 D1C1

To claim this, I am signing this object:

# checks out the pull request with the given ID into a local branch named PR<ID>
# example: You have a pull request with id 13. Just do:
# checkout-pr 13 && git checkout PR13
function checkout-pr() {
git fetch origin refs/pull/$1/head:PR$1
}
@rogeriopvl
rogeriopvl / index.js
Created June 23, 2014 16:42
requirebin sketch
var marked = require('marked');
document.body.innerHTML = marked('# This is markdown!');
@rogeriopvl
rogeriopvl / styled_selects.css
Last active August 29, 2015 14:01
CSS for a simple styled select element
/* this class is to apply to a span that wraps the select element */
.select-style {
border: 1px solid #ddd;
width: auto;
height: 100px;
border-radius: 3px;
overflow: hidden;
background: url("data:image/png;base64,R0lGODlhDwAUAIABAAAAAP///yH5BAEAAAEALAAAAAAPABQAAAIXjI+py+0Po5wH2HsXzmw//lHiSJZmUAAAOw==") no-repeat right #ddd;
}
@rogeriopvl
rogeriopvl / Gulpfile.js
Last active January 2, 2016 02:29
Simple Gulpfile example with livereload
var gulp = require('gulp');
var lrserver = require('tiny-lr');
var livereload = require('gulp-livereload');
var connect = require('connect');
var WEB_PORT = 9000;
var APP_DIR = 'app';
var DIST_DIR = 'dist';
var lrs = lrserver();
@rogeriopvl
rogeriopvl / background-vim.sh
Last active December 27, 2015 17:09
Do you use ":sh" VIM command a lot? Tired of leaving background VIM processes forgotten? This bash/zsh script is for you!
# INSTALL:
# Just add the following code to the end of
# your ~/.bashrc or ~/.zshrc file
# check if VIM is running in the current tty background
function is_vim_bg {
isbg=$(ps | grep `tty | sed -e 's|/dev/||g'` | grep -i vim | wc -l)
if [ $isbg -gt 0 ] ; then
echo "\e[0;31m❐ VIM\e[m "
@rogeriopvl
rogeriopvl / angular_loading.js
Created July 18, 2013 15:27
Angular interceptor that adds a transparent loading layer on top of the page when an ajax request is being done
angular.module('MyApp')
.config(function($httpProvider) {
var numLoadings = 0;
var loadingScreen = $('<div style="position:fixed;top:0;left:0;right:0;bottom:0;z-index:10000;background-color:gray;background-color:rgba(70,70,70,0.2);"><img style="position:absolute;top:50%;left:50%;" alt="loading..." src="/img/loading.gif"></div>')
.appendTo($('body')).hide();
$httpProvider.responseInterceptors.push(function() {
return function(promise) {
numLoadings++;
loadingScreen.show();
var hide = function(r) { if (!(--numLoadings)) loadingScreen.hide(); return r; };
@rogeriopvl
rogeriopvl / toggle_vpn
Created May 6, 2013 09:43
AppleScript to toggle a VPN connection. Great to use as an Alfred workflow.
tell application "System Events"
tell current location of network preferences
set VPNservice to service "INSERT_VPN_NAME_HERE"
if exists VPNservice then set isConnected to connected of current configuration of VPNservice
if isConnected is false then
connect VPNservice
else
disconnect VPNservice
end if
end tell
@rogeriopvl
rogeriopvl / gist:5009416
Last active May 30, 2023 21:24
Shell function to play RTMP streaming on OSX with VLC and rtmpdump (add to your .bashrc or .zshrc)
function rtmp_open() {
rtmpdump -r $1 --quiet | /Applications/VLC.app/Contents/MacOS/VLC fd://0 --playlist-autostart
}
@rogeriopvl
rogeriopvl / cluster.js
Created May 22, 2012 15:08
Node cluster sample
var cluster = require('cluster'),
http = require('http'),
numCPUS = require('os').cpus().length;
if (cluster.isMaster){
for (var i=0; i< numCPUS; i++){
cluster.fork();
}
cluster.on('death', function(worker){