Skip to content

Instantly share code, notes, and snippets.

View PabiGamito's full-sized avatar
🦄
hacking

Pablo Gamito PabiGamito

🦄
hacking
View GitHub Profile

Keybase proof

I hereby claim:

  • I am pabigamito on github.
  • I am pabi (https://keybase.io/pabi) on keybase.
  • I have a public key ASDh38i3ZfipoIAj3yf2A-ADRX8eBCTMOoNu2hh31h-tjgo

To claim this, I am signing this object:

@PabiGamito
PabiGamito / ContractA.sol
Created September 5, 2018 21:22
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
pragma solidity ^0.4.22;
import "./IContractB.sol";
contract ContractA {
IContractB internal CONTRACTB;
constructor (address _address) public {
CONTRACTB = IContractB(_address);
}
@PabiGamito
PabiGamito / .tum.conf
Last active November 18, 2017 00:07
Terminal App settings
set-option -g mouse on
@PabiGamito
PabiGamito / haskell-fibonacci-1.hs
Last active October 20, 2017 17:41
Different solutions for generating Fibonacci sequence in Haskell
-- Exponential complexity
-- NOTE: This should never be used it is extraordinarily slow
fib :: Int -> Integer
fib 0 = 0
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)
-- > fib 8
-- > [0, 1, 1, 2, 3, 5, 8, 13]
@PabiGamito
PabiGamito / The Stolen Breakfast Drone Problem.rb
Created October 12, 2016 16:44
The Stolen Breakfast Drone Problem created by PabiGamito - https://repl.it/DuXd/14
# PROBLEM #
# ####### #
# Your company delivers breakfast via autonomous quadcopter drones. And something mysterious has happened.
# Each breakfast delivery is assigned a unique ID, a positive integer. When one of the company's 100 drones takes off with a delivery, the delivery's ID is added to a list, delivery_id_confirmations. When the drone comes back and lands, the ID is again added to the same list.
# After breakfast this morning there were only 99 drones on the tarmac. One of the drones never made it back from a delivery. We suspect a secret agent from Amazon placed an order and stole one of our patented drones. To track them down, we need to find their delivery ID.
# Given the list of IDs, which contains many duplicate integers and one unique integer, find the unique integer.
@PabiGamito
PabiGamito / The Cake Thief Problem.rb
Created October 12, 2016 16:25
The Cake Thief Problem created by PabiGamito - https://repl.it/Dtcs/15
# ####### #
# PROBLEM #
# ####### #
# You are a renowned thief who has recently switched from stealing precious metals to stealing cakes because of the insane profit margins. You end up hitting the jackpot, breaking into the world's largest privately owned stock of cakes—the vault of the Queen of England. While Queen Elizabeth has a limited number of types of cake, she has an unlimited supply of each type.
# Each type of cake has a weight and a value, stored in a tuple with two indices:
# An integer representing the weight of the cake in kilograms
# An integer representing the monetary value of the cake in British pounds
# For example:
@PabiGamito
PabiGamito / Dividers Finder.rb
Created October 5, 2016 17:09
Dividers Finder created by PabiGamito - https://repl.it/DpD7/13
def find_divider(n, i=1, dividers=[])
if i < n/2
if n/i == (n/i).to_i
if !dividers.include? i
dividers << i
end
if !dividers.include? (n/i).to_i
dividers << (n/i).to_i
end
end
@PabiGamito
PabiGamito / longest-palindrome.rb
Last active September 21, 2016 15:56
Algorithm that Finds the Longest Palindrome in an Array - Ruby
arr = ["madam", "nurses","Racecar", "not a palindrome", "a random string", "Dennis, And Edna Sinned"]
# Find the Palindromes in the array
palindromes = []
arr.each do |str|
parsed_str = str.downcase.gsub(/[^a-z^A-Z]/, "");
is_palindrome = true
i = 0
(parsed_str.length/2).times do
@PabiGamito
PabiGamito / okcoin_websocket.rb
Last active January 15, 2016 18:07 — forked from aortenzi/gist:03788f7175dcbf5ec2e3
Subscribes to btcusd ticker from okcoin via websocket.
require 'websocket-client-simple'
require 'zlib'
WSURL = 'wss://real.okcoin.com:10440/websocket/okcoinapi'
def inflate(deflated_string)
zstream = Zlib::Inflate.new(-Zlib::MAX_WBITS)
buf = zstream.inflate(deflated_string)
zstream.finish
zstream.close