Skip to content

Instantly share code, notes, and snippets.

View feulf's full-sized avatar
🐢
slow and steady wins the race

Federico feulf

🐢
slow and steady wins the race
View GitHub Profile
@feulf
feulf / random_nft.py
Created May 15, 2022 13:45
This code generates random patterns with ' ', +, and -
import random
symbols = ['-', '+', ' ', ' ', ' ', ' ']
def get_symbol(seed: int = 1):
# random.seed(seed)
r = int(random.random() * 1000)
return symbols[r % len(symbols)]
matrix = [[get_symbol(i + j) for i in range(40)] for j in range(20)]
from queue import Queue
class BinaryTree:
def __init__(self, value):
self.value = value
self.left_child = None
self.right_child = None
def insert_left(self, value):
import hashlib
hashed_list = [None] * 10 # create an array of None
def key_position(key):
string = key.encode() # convert to bytes
hashed_key = hashlib.sha256(string) # hash the string
hex_digest = hashed_key.hexdigest() # get the hex value
int_digest = int(hex_digest, 16) # convert to int
num = 0b000000001
#print(bin(num))
num = 0b000000001 << 1 # 0b10
#print(bin(num))
num = 0b000000001 << 2 # 0b100
#print(bin(num))
num = 0b000000001 >> 1 # 0b0
@feulf
feulf / data-types.py
Created October 29, 2019 20:42
Data Types in Python
# Boolean
# ------------------
print(True)
print(False)
print(type(True))
# Integers
# ------------------
# Python 3 has no limit for the data size. Aside the memory of course.
@feulf
feulf / bitcoin_attacker_success_probability.c
Created October 3, 2019 19:46
C code that shows the Poisson distribution of the probability to attack Bitcoin.
#include <math.h>
#include <stdio.h>
double AttackerSuccessProbability(double q, int z) {
double p = 1.0 - q;
double lambda = z * (q / p);
double sum = 1.0;
int i, k;
for (k = 0; k <= z; k++)
{
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp()
const db = admin.firestore()
const settings = {timestampsInSnapshots: true};
db.settings(settings);
@feulf
feulf / lightning_network_workshop_1_commands.md
Last active April 10, 2018 05:10
Workshop Series 1: Lightning Network

Lightning Network Workshop Series 1

  1. Run btcd
./btcd --simnet --rpcuser=kek --rpcpass=kek --txindex --connect=YOUR_IP
  1. Run lnd
./lnd --bitcoin.active --bitcoin.simnet --bitcoin.node=btcd --btcd.rpcuser=kek --btcd.rpcpass=kek --debuglevel=trace --noencryptwallet
const OpenTimestamps = require('javascript-opentimestamps');
var fs = require('fs');
fs.readFile('bitcoin.pdf.ots', 'utf8', (err, contents) => {
const fileOts = Buffer.from(contents.toString('utf8'));
const detached = OpenTimestamps.DetachedTimestampFile.deserialize(fileOts);
const infoResult = OpenTimestamps.info(detached);
console.log(infoResult)
});
@feulf
feulf / gist:8408501
Created January 13, 2014 21:27
tmux configuration
# Mouse support
setw -g mode-mouse on
set-option -g mouse-select-pane on
set-option -g mouse-select-window on
set -g mouse-resize-pane on
set -g mouse-select-window on
# tmux vi mode
setw -g mode-keys vi