Skip to content

Instantly share code, notes, and snippets.

View suspectpart's full-sized avatar
🐍
Python for Dummies - Out now!

Horst Schneider suspectpart

🐍
Python for Dummies - Out now!
  • Universität Heidelberg, Germany
  • Mannheim
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Malen!</title>
<style>
body {
margin: 0;
@suspectpart
suspectpart / fefe.py
Last active February 6, 2021 21:00
Decipher Fefe Timestamps
"""
https://blog.fefe.de/?ts=bcb518f6
Timestamp: bcb518f6
Date: Thu Mar 31 2005
"""
from datetime import datetime
def defefe(ts):
"""
Decrypt hex-encoded POSIX timestamps.
@suspectpart
suspectpart / secgrid.es6
Last active February 6, 2020 12:51
SectionGrid Spike
/**
* Group a list of item by key.
* @param list
* @param keyGetter
* @returns {Map<any, any>}
*/
function groupBy(list, keyGetter) {
const map = new Map();
for (const item of list) {
@suspectpart
suspectpart / crystal_ball.py
Last active September 29, 2019 13:48
Crystal Ball
from cmd import Cmd
import random
import string
import uuid
# noinspection PyMethodMayBeStatic,PyUnusedLocal
class CrystalBall(Cmd):
intro = 'Ask the crystal ball for some truly random things. \n\n' \
'Type "help" to get some help.'
@suspectpart
suspectpart / beer.lisp
Last active September 20, 2019 19:18
A beer name generator, written in LISP.
;; Helpers
(defun last-letter (str)
(char str (- (length str) 1))
)
(defun ends-with (str letter)
(char= (last-letter str) letter)
)
(defun random-choice (coll)
@suspectpart
suspectpart / istream.js
Last active February 6, 2019 23:29
ES6 Generators
class Stream {
constructor(iterable, chain) {
this._iterable = iterable;
this._chain = chain || "";
}
static from(iterable) {
return new Stream(iterable);
}
@suspectpart
suspectpart / gen.js
Created February 6, 2019 14:21
python-like generators in javascript
function* imap(iterable, func) {
for (item of iterable) {
yield func(item);
}
}
function* ifilter(iterable, predicate) {
for (item of iterable) {
if(predicate(item)) {
yield item;
@suspectpart
suspectpart / parse.js
Last active February 18, 2019 16:38
Parse numbers in JS
const assert = require('assert');
describe('Parse', () => {
it('strict', function () {
// these are fine
assert.strictEqual(parseStrict(0), 0);
assert.strictEqual(parseStrict(-0), -0);
assert.strictEqual(parseStrict(1), 1);
assert.strictEqual(parseStrict(3.14159), 3.14159);
assert.strictEqual(parseStrict(-3.14159), -3.14159);
const { performance } = require('perf_hooks');
// LIZENZ: Gehört Horst Schneider
function Statistics(X) {
function Percentile(X, percent) {
this.value = function () {
const k = (X.length - 1) * percent;
const lower = Math.floor(k);
@suspectpart
suspectpart / bst.py
Last active December 13, 2018 22:51
Binary Search Tree
import unittest
from abc import ABC, abstractmethod
class DuplicateKeyException(Exception):
def __init__(self, key):
msg = f"Key {key} is already taken"
super(DuplicateKeyException, self).__init__(msg)