Skip to content

Instantly share code, notes, and snippets.

View legraphista's full-sized avatar
😱
¯\_(ツ)_/¯

Ștefan-Gabriel Muscalu legraphista

😱
¯\_(ツ)_/¯
View GitHub Profile
@legraphista
legraphista / clone.js
Last active October 12, 2017 12:44
test for fast cloning of objects
var fastDeepclone = require("fast-deepclone");
var FastClone = require("fastest-clone");
const arr = 'x'.repeat(10000).split('').map(_ => ({
a: 2,
b: { c: 1, d: { e: { f: { g: 5 } } } }
}));
for (let i = 0; i < 10; i++) {
console.time('fastest-clone SINGLE x10000');
@legraphista
legraphista / index.js
Created November 8, 2017 12:57
Erratic async/await behaviour
const Nightmare = require('nightmare'); // 2.10.0
let thatSpecialPlaceInMemory;
const makeNightmare = async () => {
const n = new Nightmare({ show: true });
await n.useragent('custom ua');
await n.goto('about:blank');
@legraphista
legraphista / readme.md
Last active July 30, 2018 11:48
Prank you MacOs friends with this simple script

Setup

The Whisper Voice

System Preferences -> Accesibility -> Speech -> System Voice:Customize -> Check Whisper-> Ok -> Close SP

Q: Why manually enable it? can't you just make a script?
A: If you want to enable it via AppleScript you can't use "System Events" to tell "System Properties" what to do unless it's allowed by "Assistive app control" which is guarded by the user's password. The other alternative is to download the voice package to /System/Library/Speech/Voices/ but the folder is owned by root with no write permissions and can't do anything without the password.

The Cron Script

@legraphista
legraphista / node_hang_debug.js
Last active May 22, 2018 12:10
debug a node that's not terminating
const async_hooks = require('async_hooks');
let indent = 0;
const fs = require('fs');
const map = new Map();
async_hooks.createHook({
init(asyncId, type, triggerAsyncId, resource) {
const eid = async_hooks.executionAsyncId();
const indentStr = ' '.repeat(indent);
fs.writeSync(
@legraphista
legraphista / package.json
Last active November 18, 2018 11:58
v8 napi deconstruct failure
{
"name": "example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"author": "Stefan-Gabriel Muscalu <stefan.gabriel.muscalu@gmail.com> (http://my.corneroftheinternet.rocks/)",
"dependencies": {
"darknet-bindings": "git+ssh://git@github.com/legraphista/darknet-bindings.git#9d61036a1f8282ff870481a0079e31c1dc6f45d4",
"expose-gc": "^1.0.0"
@legraphista
legraphista / binding.gyp
Created November 26, 2018 15:22
Minimal Napi Tensorflow C++ example
{
"targets": [
{
"target_name": "napi-testing",
'include_dirs': [
"<!@(node -p \"require('node-addon-api').include\")",
"src",
"/usr/local/include",
"/usr/local/tensorflow/include/"
],
@legraphista
legraphista / set-image.ps1
Last active May 2, 2022 19:47
powershell set folder ison from any image
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[Reflection.Assembly]::LoadWithPartialName("System.Drawing.Bitmap")
[Reflection.Assembly]::LoadWithPartialName("System.Drawing.Graphics")
[Reflection.Assembly]::LoadWithPartialName("System.Drawing.Imaging")
[Reflection.Assembly]::LoadWithPartialName("System.Drawing.Icon")
[Reflection.Assembly]::LoadWithPartialName("System.IO")
function Img2Icon{
param ($image)
@legraphista
legraphista / Minecraft Dungeons Backuper.js
Last active June 3, 2020 14:38
Backup files when they change! (I'm looking at you, Minecraft Dungeons....)
// C:\Users\Stefan\AppData\Local\Packages\Microsoft.Lovika_8wekyb3d8bbwe\LocalCache\Local\Dungeons
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const [toWatch, toBackup] = process.argv.slice(2);
assert(fs.existsSync(toWatch), `cannot find dir ${toWatch}`);
assert(fs.existsSync(toBackup), `cannot find backup dir ${toBackup}`);
@legraphista
legraphista / test.js
Last active September 27, 2021 16:51
Electron 14 failing to open save dialog
const { app, BrowserWindow, dialog} = require('electron');
app.on('ready', async () => {
const mainWindow = new BrowserWindow({
center: true,
autoHideMenuBar: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
@legraphista
legraphista / test.js
Created October 12, 2021 17:40
simple beamcoder usage
const bc = require('beamcoder');
bc.demuxer('rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov').then(dm => console.log(dm.duration))