This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse | |
import hashlib | |
BUFFER_SIZE = 2 ** 19 # 512k | |
def read_args(): | |
parser = argparse.ArgumentParser( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from decimal import Decimal as D | |
values = [ | |
'7.18', '7.13', '10.11', '7.67', '7.8', '6.77', '6.45', '6.57', | |
'6.61', '7.86', '6.79', '6.76', '6.7', '7.72', '6.71', '7.45', '6.54', | |
'6.75', '7.18', '6.77', '9.09', '26', '5.61', '7.41', '5.9', '9.35', '7.29', | |
'6.25', '11.62', '7.34', '8.29', '6.95', '7.54', '8.36', '7.51', '6.2', '6.09', | |
'7.3', '6.86', '6.67', '6.85', '6.17', '7.26', '5', '6.11', '6.07', '7.42', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import string | |
from itertools import product | |
password_length = 3 | |
def match(password1, password2): | |
right_place = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CommonCrypto | |
func otp() -> String { | |
let secret = Data() // change this | |
let now = Date().timeIntervalSince1970 | |
let count = Int(now) / 30 | |
var fixedCounter = NSSwapHostLongLongToBig(UInt64(count)) | |
let hash = malloc(1000)! | |
defer {free(hash)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use cases of ValidatedString (https://gist.github.com/gonzula/dbc7194fd9afde7b7b59fb772a543e91) | |
// With very little code you create very safe data types with a lot of cool features | |
// Let's create a username validator | |
typealias Username = ValidatedString<UsernameValidator> | |
enum UsernameValidator: StringValidator { | |
/// Accepts any username with length between 3 and 10 inclusive | |
static func validate(_ string: String) -> String? { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Examples, how to use and more @ https://gist.github.com/gonzula/3bdfb73957d4aae776cb656ee738c897 | |
public protocol StringValidator { | |
/// Returns a sanitized string if the input is valid or nil otherwise | |
static func validate(_ string: String) -> String? | |
} | |
public protocol StringNormalizer { | |
/// Returns a normalized version of `rawValue` | |
static func normalize(_ rawValue: String) -> String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func send(_ message: String, to email: String) { | |
guard email.isValidEmailAddress else {return} | |
// code that sends email | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! ITerm2ProxyIconTitle(wait) abort | |
if a:wait | |
sleep 10m // when resuming to foreground it only works if waits some time (don't ask me why) | |
endif | |
let arg = "\e]1337;SetProxyIcon=" . expand('%:p') . "\<c-G>" | |
if has('nvim') | |
call chansend(2, arg) | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import numpy as np | |
from matplotlib import pyplot as plt | |
from numpy.polynomial import polynomial as poly | |
x = np.array([1,2, 3]) | |
y = np.array([-1, 12, 39]) | |
L = [] |