Skip to content

Instantly share code, notes, and snippets.

View volonbolon's full-sized avatar

Ariel Rodriguez volonbolon

View GitHub Profile
@volonbolon
volonbolon / eip55.py
Created December 19, 2020 14:04
EIP-55 implementation
#!/usr/bin/env python
import unittest
from sha3 import keccak_256
def checksum_encoded(addr):
checksumed = ''
hashed = keccak_256(addr.encode('utf-8')).digest().hex()[:40]
for idx, character in enumerate(addr):
if character in "0123456789": # Decimal digits should be passed as they are
checksumed += character
@volonbolon
volonbolon / Builder.swift
Created March 26, 2020 21:49
Builder design pattern exploration
import UIKit
struct PackingList {
let heavyCoat: Int
let rainJacket: Int
let pullover: Int
let activewearCoat: Int
let thermalUnderwear: Int
let leggins: Int
let darkJean: Int
import os
from random import SystemRandom
import ecdsa
p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
order = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
# Remember the equiation we are using is `y^2 % p == x^3 + 7
a = 0x0000000000000000000000000000000000000000000000000000000000000000
b = 0x0000000000000000000000000000000000000000000000000000000000000007
# This is the generator point defined in the standard
//: Playground - noun: a place where people can play
import Cocoa
class Node<T: Comparable> {
var next: Node<T>?
let value: T
init(value: T) {
self.value = value
//: Playground - noun: a place where people can play
import Cocoa
struct State {
var state: [Int]
init(state: [Int]) {
self.state = state
}
import bisect
class NFA(object):
EPSILON = object()
ANY = object()
def __init__(self, start_state):
self.transitions = {}
self.final_states = set()
self._start_state = start_state
@volonbolon
volonbolon / testing_mocks.swift
Created January 16, 2018 13:42
Testing using mocks
import XCTest
@testable import WeatherApp
extension XCTestCase { // JSON support
func jsonData(payload: Any) throws -> Data {
let options: JSONSerialization.WritingOptions = [.prettyPrinted, .sortedKeys]
let data = try JSONSerialization.data(withJSONObject: payload, options: options)
return data
}
}
@volonbolon
volonbolon / string_int_conversions.swift
Created January 10, 2018 18:39
String / Int Conversions
//: Playground - noun: a place where people can play
import UIKit
extension Character {
var asciiValue: Int {
get {
let s = String(self).unicodeScalars
return Int(s[s.startIndex].value)
}
@volonbolon
volonbolon / delete_elements.swift
Created January 7, 2018 14:01
Delete elements from an array
//: Playground - noun: a place where people can play
import UIKit
// General Case for an Array
extension Array where Element:Hashable {
mutating func deleteElements(_ elements:[Element]) -> ArraySlice<Element> {
var toDelete: [Element: Bool] = [:]
for e in elements {
toDelete[e] = true
@volonbolon
volonbolon / reversed.swift
Created January 3, 2018 14:25
Reverse words in Swift
//: Playground - noun: a place where people can play
import UIKit
extension String {
private func reverseChars(chars: inout [String.Element], range: Range<Int>) {
guard chars.count > 1 else {
return
}