Skip to content

Instantly share code, notes, and snippets.

@vnoder
vnoder / 常用变量缩写
Created February 25, 2021 08:16
常用变量缩写
We couldn’t find that file to show.
/**
* securesocks encryptor
* Name Alias KeySize Salt Size Nonce Size Tag Size
* AEAD_AES_256_GCM aes-256-gcm 32 32 12 16
* AEAD_AES_192_GCM aes-192-gcm 24 24 12 16
* AEAD_AES_128_GCM aes-128-gcm 16 16 12 16
*/
import * as crypto from 'crypto';
export const EncryptMethod = {
@vnoder
vnoder / fibonacci.go
Created January 18, 2018 08:33
fibonacci
package main
import (
"fmt"
"time"
"runtime"
)
func fibonacci(num int) int {
if num < 2 {
@vnoder
vnoder / sshRsyncFile.js
Created January 10, 2018 05:28
rsync file with node.js
/**
* Created by vd on 10/01/18.
*/
'use strict';
const shell = require('shelljs');
/**
* rsync file (must config public key, passport is not supported)
*
@vnoder
vnoder / awaitToBluebirdPromise.js
Last active January 10, 2018 03:50
convert default await promise to bluebird promise
/**
* Created by vd on 10/01/18.
*/
'use strict';
const Promise = require('bluebird');
async function demoAsyncFun() {
return Promise.resolve([1,2,3]);
}
@vnoder
vnoder / fail2ban-reset-log-db.sh
Created November 9, 2017 14:31 — forked from mitchellkrogza/fail2ban-reset-log-db.sh
Bash script to reset Fail2Ban - clears / truncates log file and deletes the sqlite database - stops and restarts service during this process.
#!/bin/bash
# Bash Script by https://gist.github.com/mitchellkrogza
# ************************************************************
# This script clears the log file and database of Fail2Ban
# This resets Fail2Ban to a completely clean state
# Useful to use after you have finished testing all your jails
# and completed your initial setup of Fail2Ban and are now
# putting the server into LIVE mode
# ************************************************************
@vnoder
vnoder / gist:97b1f0c812e2d1ddd25b
Created December 18, 2015 13:07 — forked from deandob/gist:8943268
Streaming MP4 to HTML5 clients
--------------- FFMPEG command line
ffmpeg = child_process.spawn("ffmpeg", [
"-i", rtsp , "-vcodec", "copy", "-f", "mp4", "-f", "segment", "-segment_time", recSeg, "-segment_wrap", 2, "-map", "0", "-segment_format", "mp4", "-reset_timestamps", "1", "-y", "plugins/security/videos/" + camName + "/rec-%01d.mp4"
], {detached: false});
---------------- Node.JS streamer
// Stream mp4 video file based on URL request from client player. Accept request for partial streams
// Code attribution: https://github.com/meloncholy/vid-streamer/blob/master/index.js (MIT license)
var recStream = function (req, resp) {
var stream;