Skip to content

Instantly share code, notes, and snippets.

View rodolfobandeira's full-sized avatar

Rodolfo rodolfobandeira

View GitHub Profile
@rodolfobandeira
rodolfobandeira / puma_rc.d.sh
Created April 13, 2018 01:00 — forked from katafrakt/puma_rc.d.sh
simple and stupid Arch Linux rc.d script for starting and stopping puma (http://puma.io) with certain rails app
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/profile
DAEMON=prozatorium
PIDFILE=/path/to/pidfile
app_path=/path/to/rails_app
config=config/puma.rb
class Hash
def nested_each_pair
self.each_pair do |k,v|
if v.is_a?(Hash)
v.nested_each_pair {|k,v| yield k,v}
else
yield(k,v)
end
end
@rodolfobandeira
rodolfobandeira / hash_to_breadcrumb.rb
Created March 5, 2018 20:01 — forked from dbrady/hash_to_breadcrumb.rb
hash_to_breadcrumb - turn a hash containing items, arrays, or nested hashes into a flattened list of "breadcrumbs" -- e.g. the path through the hash to get to the last value in the list.
# hash_to_breadcrumbs
#
# hash_to_breadcrumb - turn a hash containing items, arrays, or nested hashes
# into a flattened list of "breadcrumbs" -- e.g. the path through the hash to
# get to the last value in the list.
hash = {
a: 1,
b: [2, 3, 4],
c: {
@rodolfobandeira
rodolfobandeira / rxjs-firebase-demo.js
Created November 3, 2017 16:30 — forked from deltaepsilon/rxjs-firebase-demo.js
Demo RxJs integration with Firebase
var Rx = require('rxjs');
var firebase = require('firebase');
firebase.initializeApp({
"databaseURL": "https://quiver-two.firebaseio.com",
"serviceAccount": "./service-account.json"
});
var ref = firebase.database().ref('rxjs-demo');
Rx.Observable.fromPromise(ref.remove())
.map(function () {
@rodolfobandeira
rodolfobandeira / SMBDIS.ASM
Created October 17, 2017 02:18 — forked from 1wErt3r/SMBDIS.ASM
A Comprehensive Super Mario Bros. Disassembly
;SMBDIS.ASM - A COMPREHENSIVE SUPER MARIO BROS. DISASSEMBLY
;by doppelganger ([email protected])
;This file is provided for your own use as-is. It will require the character rom data
;and an iNES file header to get it to work.
;There are so many people I have to thank for this, that taking all the credit for
;myself would be an unforgivable act of arrogance. Without their help this would
;probably not be possible. So I thank all the peeps in the nesdev scene whose insight into
;the 6502 and the NES helped me learn how it works (you guys know who you are, there's no
@rodolfobandeira
rodolfobandeira / README.md
Created April 25, 2017 18:32 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
public class DistanceRootToNode {
public int Pathlength(Node root, int n1) {
if (root != null) {
int x = 0;
if ((root.data == n1) || (x = Pathlength(root.left, n1)) > 0
|| (x = Pathlength(root.right, n1)) > 0) {
return x + 1;
}
# https://zvkemp.github.io/blog/2014/04/25/binary-search-trees-in-ruby/
module BinaryTree
class EmptyNode
def to_a
[]
end
def include?(*)
false
@rodolfobandeira
rodolfobandeira / README.md
Created November 9, 2016 21:23 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :

#!/usr/bin/env ruby
require 'aws-sdk'
sts = Aws::STS::Client.new(
region: 'us-east-1',
access_key_id: "<insert access key id>",
secret_access_key: "<secret>"
)