Skip to content

Instantly share code, notes, and snippets.


Peter peheje

View GitHub Profile
peheje / automata1.nim
Last active Apr 21, 2021
Simple automata
View automata1.nim
import sequtils
import random
on = 1
off = 0
width = 100
iterations = 100
proc advance(xs: seq[int]): seq[int] =
View Lego Mindstorms PID
from mindstorms import MSHub, Motor, MotorPair, ColorSensor, DistanceSensor, App
from mindstorms.control import wait_for_seconds, wait_until, Timer
from mindstorms.operator import greater_than, greater_than_or_equal_to, less_than, less_than_or_equal_to, equal_to, not_equal_to
import math
hub = MSHub()
motors = MotorPair('E', 'A')
roll_target = 89
kp = 15.0
peheje / jobWrapping.kt
Created Aug 27, 2020
Wrap job multiple times
View jobWrapping.kt
import kotlin.random.Random
import kotlin.system.measureTimeMillis
fun main() {
val basicJob = BasicJob()
val delayedJob = DelayedJob(basicJob, 1000)
val measuredAndDelayedJob = MeasuredJob(delayedJob)
val measuredDelayedAndSynchronizedJob = SynchronizedJob(measuredAndDelayedJob, "lock")
View bloomfilter.kt
import java.lang.Exception
import java.nio.ByteBuffer
import java.util.*
import kotlin.math.abs
fun main() {
val filterSize = 1_000_000
val numberOfEntries = 100_000
View add spotify albums to one playlist
import pyautogui
import time
def record():
while True:
currentMouseX, currentMouseY = pyautogui.position()
print("(" + str(currentMouseX) + "," + str(currentMouseY) + ")")
peheje / main.kt
Created May 22, 2017
kotlin genetic
View main.kt
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.experimental.sync.Mutex
import java.util.*
import kotlin.system.measureTimeMillis
// BY peheje@github
fun stringToIntArray(str: String): IntArray {
View Bootcamp on danish keyboard AHK fixes
; Seems to not work in Chrome browser.
; Tuborg clamps
<+<!8::SendInput {Raw}{
<+<!9::SendInput {Raw}}
; Brackets
<!8::SendInput {Raw}[
<!9::SendInput {Raw}]
peheje / client.js
Created Apr 4, 2017
Node.js client-server timings.
View client.js
const http = require("http");
const NanoTimer = require("nanotimer"); // Documentation:
function getNanoTime() {
const t = process.hrtime(); // Documentation:
return t[0] * 1e9 + t[1]; // [seconds, nanoseconds]
const options = {
hostname: '',
peheje / Heap Swif 3.0
Last active Aug 28, 2018
Generic Heap in Swift with Min/Max implementation and tree printing
View Heap Swif 3.0
//: [Previous](@previous)
// Created by Peter Helstrup Jensen on 06-07-2015
// Copyright (c) 2015 Peter Helstrup Jensen. All rights reserved.
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
// version.
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
peheje / JSONSerializer.swift
Last active Oct 26, 2015
A JSON Serializer without inheritance
View JSONSerializer.swift