Skip to content

Instantly share code, notes, and snippets.

@lukakostic
lukakostic / async sleep.js
Last active October 1, 2018 15:20
await sleep(2000); //2 sec
async function sleep(x) {
return new Promise(resolve => {
setTimeout(() =>{resolve(x);},x);
});
}
This file has been truncated, but you can view the full file.
Benjamin Rennells,/benjamin.rennells,Jessica Hayward,/haywardcal
Benjamin Rennells,/benjamin.rennells,James Martin,/profile.php?id=100011349840834
Benjamin Rennells,/benjamin.rennells,Leslie Darnell,/leslie.darnell.9
Benjamin Rennells,/benjamin.rennells,Kathy Frasca,/intergalactickathy.1
Benjamin Rennells,/benjamin.rennells,Sean Brady,/sean.brady.94
Benjamin Rennells,/benjamin.rennells,Kate Mattes,/kate.mattes.3
Benjamin Rennells,/benjamin.rennells,Deborah Cronin,/profile.php?id=100018394773973
Benjamin Rennells,/benjamin.rennells,Mike Bird,/mike.bird.92351
Benjamin Rennells,/benjamin.rennells,Mike Bird,/mike.bird.12177
Benjamin Rennells,/benjamin.rennells,Denise Sharpe,/MIBESCH
/*
Use these commands to render img.ppm:
w & h: 4000 4000
2 -.5 0 .3
1
*/
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<cstdio>
#define D fputc(i*8,f) //colors (max = 248=31*8) with 31 iterations
main(){
int h=4000,w=4000,a=w*h,i; //resolution
FILE*f=fopen("img.ppm","wb");
fprintf(f,"P6\n%d %d\n255\n",w,h); //ppm header: P6 w h colorMax
for(;a--;i=31){ //iterations (31) per each pixel (x)
for(double t,x=.0,y=.0;x*x+y*y<4.&&i-->1;) //limit (4=2^2)
t=x*x-y*y+(a%w-w/2.)*.0006-.5, //x zoom (*.0006) & view (-.5)
y=2.*x*y+(a/w-h/2.)*.0006+.0, //y zoom (*.0006) & view (+.0)
@lukakostic
lukakostic / Screencap.py
Last active May 17, 2024 06:30
Python screencap and screenshot gui tool
#!/usr/bin/env python3
"""
uses following cli tools:
slop - let user area select on screen
maim - cli screenshot tool , uses slop
recordMyDesktop - cli tool to screencap videos
zenity - cli tool for dialogs (save as dialog)
@lukakostic
lukakostic / CircularDeepCopy.js
Last active May 22, 2024 18:45
JS Circular reference DeepCopy and LinearizedDeepCopy (can be jsoned and back)
/*
DeepCopy and LinearizedDeepCopy which can handle circular references.
LinearizedDeepCopy can be jsonified and back yet keep circular references.
(For use see comments below the functions)
// these dont clone functions or keep class(constructor) info!!!
// so its like JSON.parse(JSON.stringify(obj)) but faster(?) and can do circular references.
*/