Skip to content

Instantly share code, notes, and snippets.

View CiQL's full-sized avatar

CiQL

View GitHub Profile
@CiQL
CiQL / proof.md
Created September 28, 2024 15:57

$2a$11$oBJsoS9ki4IFxI/nm5D2Ve2IZhUIjtP97/VRqcd.DDDcSAmtEduEC

@CiQL
CiQL / parallel.py
Created March 22, 2019 22:43
Create a generator of 4-digit number hashes in parallel, and see if a known hash exists within it
from concurrent.futures import ProcessPoolExecutor
from hashlib import md5
#import sys
def calc_hash(line: str) -> str:
return md5(line.encode('utf-8')).hexdigest()
if __name__ == "__main__":
hash = calc_hash(str(1300)) # this is the string I want to test!!
# hash = sys.argv[-1] # an alternative way
@CiQL
CiQL / sqlite_cm.py
Created September 26, 2018 22:09
SQLite3 helper class for use in a context manager
#!/usr/bin/env python3
"""This module, called sqlite_cm, has a single class, also called sqlite_cm.
It's recommended to import this module using the "from import" method:
``from sqlite_cm import sqlite_cm``.
"""
import sqlite3
class sqlite_cm:
@CiQL
CiQL / terrible_fizzbuzz.py
Created July 7, 2018 05:13
The worst implementation of fizzbuzz
print('\n'.join(list(map(lambda z:str(z[0]) if all(type(x) is int for x in z) else ''.join(z) if all(type(x) is str for x in z) else ''.join([x for x in z if type(x) is str]),[tuple(s if i%n==0 else i for n,s in [(3,'Fizz'),(5,'Buzz')]) for i in range(1,1001)]))))
@CiQL
CiQL / main.cs
Last active September 28, 2018 18:40
Sudoku checker
using System;
namespace Classes
{
class Classes
{
private static void Main(string[] args)
{
int[,] grid1 =
{ { 1, 2, 3, 4, 5, 6, 7, 8, 9 }
@CiQL
CiQL / pghash.py
Last active February 15, 2018 04:20
Quick and dirty manual pgina password hashing, with hex & b64 output
import hashlib, secrets, argparse, base64
def hashish(algo: str, inputstr: str, salt: bytes = b'') -> str:
h = hashlib.new(algo)
h.update(bytes(inputstr, 'utf-8') + salt)
return h.hexdigest() + salt.hex()
def hashish64(algo: str, inputstr: str, salt: bytes = b'') -> str:
h = hashlib.new(algo)
h.update(bytes(inputstr, 'utf-8') + salt)
@CiQL
CiQL / omxplayer.py
Created December 17, 2017 07:25
Raspberry Pi omxplayer script (requires streamlink, youtube-dl on host pi)
#!/usr/bin/env python3
# -*- config: utf-8 -*-
import subprocess
import argparse
if __name__ == "__main__":
omx = "omxplayer --aspect-mode fill -o hdmi".split(" ")
p = argparse.ArgumentParser(description="Play a video on the Pi.")
p.add_argument('url', type=str, help="the URL of the stream/video")
p.add_argument('-fr', type=str, help="requested frame rate (default: best)")
@CiQL
CiQL / rational.py
Last active May 17, 2017 03:04
Stern-Brocot sequence generator
#!/usr/bin/env python3
from sys import argv
def rational(j:int)->tuple:
'''Stern-Brocot sequence'''
r = [1, 1]
for i in range(j):
yield (r[i], r[i+1], r[i] / r[i+1])
r += [r[i] + r[i+1], r[i+1]]
if __name__ == "__main__":

Keybase proof

I hereby claim:

  • I am CiQL on github.
  • I am ciql (https://keybase.io/ciql) on keybase.
  • I have a public key whose fingerprint is 5AC3 CEC2 D0A9 4E91 123B DD87 FDC7 E194 815C 98CE

To claim this, I am signing this object:

@CiQL
CiQL / ackermann.py
Last active April 19, 2017 03:54
Ackermann function in Python3
#!/usr/bin/env python3
# -*- config: utf-8 -*-
import functools, sys
sys.setrecursionlimit(100000)
@functools.lru_cache(maxsize=None)
def ackermann(m, n):
'''Runs Ackermann–Péter (two-argument) function'''
m, n = abs(m), abs(n)
if (m == 0):