Skip to content

Instantly share code, notes, and snippets.

'''
based on the work of:
- nwert https://gist.github.com/nwert/9430a454c64248dd1186868c00b682c6
- hexkyz https://gist.github.com/hexkyz/d5b3f5b1700b507b41e7fc1dc12e8dfd
'''
from Crypto.Cipher import AES
from Crypto.Util import Counter
import struct
@57op
57op / main.c
Created August 23, 2018 15:01
nx-listapps
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <switch.h>
Result initializeServices() {
gfxInitDefault();
consoleInit(NULL);
Result res;
@57op
57op / neo4j-importer.py
Created February 14, 2019 15:17
neo4j importer
import os
import json
def dict_to_str(props, keys, DELIMITER, QUOTE):
s = []
for key in keys:
value = props.get(key)
if value:
(async () => {
const keyPair = await crypto.subtle.generateKey(
{
name:'ECDH',
namedCurve:'P-256'
},
true,
['deriveKey', 'deriveBits']
)
@57op
57op / monty_hall.py
Created January 21, 2020 17:00
Clear once and for all Monty Hall problem (though I might forget again)
from random import choice, randrange, sample
class MontyHall:
def __init__(self) -> None:
self.doors = sample(['car', 'goat', 'goat'], 3) # without replacement
def play(self, switch: bool) -> bool:
# find car door index
car_door = self.doors.index('car')
/*
* morse code [w/o spaces] isn't a prefix code.
* O(n * 2^n)
*/
const MORSE_CODE = {
'.-': 'A',
'-...': 'B',
'-.-.': 'C',
'-..': 'D',
'.': 'E',
# https://edabit.com/challenge/Fz92j7nQEkoRXhRE7
from typing import Union, List
def _jumping_frog(n: int, stones: List[int], path: List[int]=None, visited: List[int]=None, paths: List[List[int]]=None) -> None:
current_position = path[-1]
# reched final state
if current_position == n:
paths.append(path)