Skip to content

Instantly share code, notes, and snippets.

@hinst
hinst / appDoubleMapper.ts
Created October 5, 2021 10:08
Reproduce bug in InfluxDB: duplicated legacy mappings
import fs from 'fs';
import fetch from 'node-fetch';
class Mapping {
id: string;
}
class AppDoubleMapper {
influxUrl = 'http://192.168.0.4:8086'
accessToken = fs.readFileSync('./influx access token.txt').toString();
@hinst
hinst / agent.ts
Last active February 24, 2021 11:11
agent for node-fetch
import http from 'http';
import https from 'https';
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
const agent = (_parsedURL: URL) => _parsedURL.protocol == 'https:' ? httpsAgent : httpAgent;
@hinst
hinst / script.js
Created June 6, 2019 21:46
fast-torrent tool
// ==UserScript==
// @name fast-torrent tool
// @version 1
// @grant none
// ==/UserScript==
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
@hinst
hinst / Caddyfile
Created September 21, 2017 17:44
Caddyfile
https://hinst.ru
proxy /FogBugzBackup localhost:9000
proxy /FogBugzBackupApi localhost:9000
proxy /massd2d localhost:9001
redir {
if {path} is /
/ /xyz
@hinst
hinst / ffmpeg.bat
Created July 20, 2017 17:59
ffmpeg extract audio
ffmpeg -i input.mp4 -c:a copy -vn -sn output.m4a
@hinst
hinst / assuming-control.sh
Last active July 2, 2017 13:07
Linux: start, stop executable file as service
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
target="caddy"
path=$(realpath $target)
echo "$target control: $1"
if [ "$1" = "start" ]
then
nohup $path 2>>error-log.txt 1>>output-log.txt &
package ho
import (
"os"
"os/signal"
"syscall"
)
func InstallShutdownReceiver(receiver func()) {
c := make(chan os.Signal)
@hinst
hinst / letters.txt
Created September 26, 2016 14:53
Latin alphabet letters
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
@hinst
hinst / GetCallerName.go
Last active May 31, 2016 10:12
Get caller function name for Go
func GetCallerName() string {
callers := make([]uintptr, 16)
runtime.Callers(3, callers)
f := runtime.FuncForPC(callers[0])
return f.Name()
}
@hinst
hinst / engineer menu code
Created December 25, 2015 12:35
Android
*#*#3646633#*#*