Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter peheje

View GitHub Profile
@peheje
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")
measuredDelayedAndSynchronizedJob.run()
}
View bloomfilter.kt
import java.lang.Exception
import java.nio.ByteBuffer
import java.security.MessageDigest
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
time.sleep(2)
def record():
while True:
currentMouseX, currentMouseY = pyautogui.position()
print("(" + str(currentMouseX) + "," + str(currentMouseY) + ")")
time.sleep(3)
@peheje
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
peheje / client.js
Created Apr 4, 2017
Node.js client-server timings.
View client.js
const http = require("http");
const NanoTimer = require("nanotimer"); // Documentation: https://github.com/Krb686/nanotimer
function getNanoTime() {
const t = process.hrtime(); // Documentation: https://nodejs.org/api/process.html#process_process_hrtime_time
return t[0] * 1e9 + t[1]; // [seconds, nanoseconds]
}
const options = {
hostname: '127.0.0.1',
@peheje
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
peheje / JSONSerializer.swift
Last active Oct 26, 2015
A JSON Serializer without inheritance
View JSONSerializer.swift
MOVED TO GITHUB PAGE https://github.com/peheje/JsonSerializerSwift
You can’t perform that action at this time.