Skip to content

Instantly share code, notes, and snippets.

View jonasporto's full-sized avatar
⌨️
Working and having fun!

Jonas Porto jonasporto

⌨️
Working and having fun!
  • Rio de Janeiro, Brazil
View GitHub Profile
@jonasporto
jonasporto / install_elixir.md
Created October 30, 2016 16:00 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then kerl and exenv are your best friends.

@jonasporto
jonasporto / ch1.md
Created October 30, 2016 15:01 — forked from dwayne/ch1.md
My notes from the book "Crafting Rails 4 Applications by José Valim"

Chapter 1 - Creating Our Own Renderer

Rails provides an API that we can use to create our own renderers. In this chapter we explore the API as we modify the render() method to accept :pdf as an option and return a PDF created with Prawn.

To create a new plugin just run the following:

$ rails plugin new my_plugin

TODO Complete notes

def solution(x, arr)
  
  k = 0
  n = arr.length
  
  condition = -> (a) { a.eql? x}
 
@jonasporto
jonasporto / bash-history-to-zsh-history.py
Created October 6, 2016 14:06 — forked from op/bash-history-to-zsh-history.py
Bash history to Zsh history
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | bash-history-to-zsh-history >> ~/.zsh_history
import sys
def main():

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@jonasporto
jonasporto / debug_httparty_request.rb
Created October 1, 2016 16:32 — forked from natritmeyer/debug_httparty_request.rb
How to debug HTTParty requests
class MyResource
include HTTParty
debug_output $stdout # <= will spit out all request details to the console
#...
end

Imprima os números de 1 a 100. Troque os números múltiplos de 5 por Peg, os múltiplos de 7 por car, e os múltiplos de 35 por Pegcar.

Em outras palavaras temos um lista de dados, que precisamos processar e gerar uma nova lista de dados, de acordo com a regra de negócio.

Um cenário ideal pra utilização do #map então segue uma primeira solução para o exercício.

result_a =  
	(1..100).map{ |n| 
@jonasporto
jonasporto / stub_with_sinon.js
Created September 22, 2016 17:10
example of stub with sinon
// install sinon via npm
// npm install sinon --save-dev
// require sinon in your test/client_api.js
var sinon = require("sinon");
// add this test expectation
it("cover error", function (done) {
var url = URL_ROOT + "/client";
{
init: function(elevators, floors) {
var upQueue = [], downQueue = [], pressedButtons = [];
elevators.forEach(function(elevator) {
console.log('max', elevator.maxPassengerCount());
elevator.clearDestination = function() {
this.destinationQueue = [];
this.checkDestinationQueue();