Skip to content

Instantly share code, notes, and snippets.

View marcusmonteiro's full-sized avatar

Marcus Vinicius Monteiro de Souza marcusmonteiro

View GitHub Profile
@marcusmonteiro
marcusmonteiro / local_file.py
Last active April 17, 2018 18:36
Get a file path using the directory where the script is executing as reference.
import os
here = os.path.dirname(os.path.abspath(__file__))
def local_file(file):
return os.path.join(here, file)
@marcusmonteiro
marcusmonteiro / ciphering_utils.py
Last active March 31, 2018 09:42
Useful functions to test ciphering functions
import binascii
import codecs
def to_hex(s: str, pad_until_length: int = 0) -> str:
"""
Args:
s: the string to be converted to it's hex representation.
pad_until_length: if the length of the `s` argument is less than this argument, the string to be converted will be padded
with binary zeros to the right until it's length is equal to this argument.
@marcusmonteiro
marcusmonteiro / download_files_on_safari_instead_of_opening_them.txt
Created December 9, 2017 17:58
Download files on Safari instead of opening them #safari #download
// from https://apple.stackexchange.com/questions/57039/how-make-safari-download-pdf-files-instead-of-opening-them-in-page
You can make Safari on the Mac download ANY files (mp3, mp4, jpg, pdf and more) by doing the following.
Open the file (movie,music,etc) in Safari. That normally comprises of clicking the link to the pdf/movie/music etc.
Click on the url of the browser (in this case it would end in ".../xyz.pdf".
Hold option down and press Return(or Enter).
The file you are viewing downloads to the Downloads folder on the mac.
I've tested this with almost all file types possible. Very very useful little feature that unfortunately too few people know about.
@marcusmonteiro
marcusmonteiro / my-ethereum-address.txt
Created August 2, 2017 23:20
My ethereum address
0x61430646CBA3D2d784C30d5B0C11c12DAb1eb824
@marcusmonteiro
marcusmonteiro / pisano_period.hs
Created March 21, 2017 01:12
Pisano Period in Haskell
-- https://en.wikipedia.org/wiki/Pisano_period
fibs :: [Integer]
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
pisanoPeriod :: Integer -> Int
pisanoPeriod m = length $ 0 : 1 : helper (drop 2 fibs)
where
helper (x:y:xs)=
if a == 0 && b == 1
@marcusmonteiro
marcusmonteiro / log
Created December 28, 2016 21:32
Error trying to compile ejjaberd dependency in Phoenix app with mix
Running dependency resolution...
All dependencies up to date
==> ejabberd
Compiling 114 files (.erl)
src/gen_iq_handler.erl:43: can't find include file "xmpp.hrl"
src/gen_iq_handler.erl:170: undefined macro 'NS_CLIENT'
src/gen_iq_handler.erl:137: function process_iq/5 undefined
src/gen_iq_handler.erl:149: record iq undefined
src/gen_iq_handler.erl:154: record iq undefined
src/gen_iq_handler.erl:157: variable 'El' is unbound