Skip to content

Instantly share code, notes, and snippets.

@westc
westc / getVideoImage.js
Last active October 2, 2019 21:48
A function to grab the frame at a specific point within a video.
function getVideoImage(path, secs, callback) {
var me = this, video = document.createElement('video');
video.onloadedmetadata = function() {
if ('function' === typeof secs) {
secs = secs(this.duration);
}
this.currentTime = Math.min(Math.max(0, (secs < 0 ? this.duration : 0) + secs), this.duration);
};
video.onseeked = function(e) {
var canvas = document.createElement('canvas');
@caimaoy
caimaoy / openssl_tool.txt
Created April 19, 2017 06:03 — forked from jorben/openssl_tool.txt
RSA加解密,签名、验签文件
1) Generate RSA key:
$ openssl genrsa -out key.pem 1024
$ openssl rsa -in key.pem -text -noout
2) Save public key in pub.pem file:
$ openssl rsa -in key.pem -pubout -out pub.pem
$ openssl rsa -in pub.pem -pubin -text -noout
3) Encrypt some data:
@andrewn
andrewn / instructions.md
Last active June 1, 2024 12:41
Testing SSL (LetsEncrypt certificate and loopback domain)

Testing SSL (LetsEncrypt certificate and loopback domain)

General approach

This sets up a publically-available domain that loops back to localhost IP address 127.0.0.1. For example, this address could be localhost.example.com if we controlled the example.com domain. This relies on having a public domain name whose DNS records you can control. We can then generate LetsEncrypt certificates for this domain.

Our HTTP server runs on localhost:80 (default HTTP port). This lets us visit http://localhost.example.com in a web browser and see the server running on localhost:80.

We then run an HTTPS proxy server on localhost:443 (default HTTPS port) that uses the LetsEncrypt certificates we generated for localhost.example.com. Visiting https://localhost.example.com hits the proxy, which returns the correct certificates meaning the browser displays the "Secure" message. The proxy then passes the request through to the HTTP server.

@Adron
Adron / uuid_generation.go
Created March 13, 2017 22:45
UUID v1, v2, v3, v4 and v5
package main
import (
"fmt"
"github.com/satori/go.uuid"
)
func main() {
// Creating UUID Version 1
uuid1 := uuid.NewV1()
@umidjons
umidjons / aes-256-cbc-nodejs-crypto.md
Last active March 13, 2022 07:12
AES-256-CBC example in Node.js using crypto module

AES-256-CBC example in Node.js using crypto module

'use strict';
const crypto = require('crypto');

// get password's md5 hash
let password = 'test';
let password_hash = crypto.createHash('md5').update(password, 'utf-8').digest('hex').toUpperCase();
console.log('key=', password_hash); // 098F6BCD4621D373CADE4E832627B4F6
@aallan
aallan / mac-vendor.txt
Last active April 11, 2025 08:31
List of MAC addresses with vendors identities
000000 Officially Xerox
000001 SuperLAN-2U
000002 BBN (was internal usage only, no longer used)
000003 XEROX CORPORATION
000004 XEROX CORPORATION
000005 XEROX CORPORATION
000006 XEROX CORPORATION
000007 XEROX CORPORATION
000008 XEROX CORPORATION
000009 powerpipes?
@lzl
lzl / automatic-nightly-backups-for-mongodb.md
Last active July 1, 2021 19:41
服务器每日自动备份 MongoDB 数据库的配置方法

第一步,创建一个存放备份的文件夹:

比如 mkdir /alidata/backup

第二步,新建一个自动备份的脚本:

#!/bin/sh
NAME='mxlzb' # 手动修改为待备份项目的数据库名
DATE=`date +%Y%m%d%H%M%S`
@ichadhr
ichadhr / Disable_Enable.md
Last active March 25, 2025 21:32
Disable/Enable Hyper-V and VT-X

If you run bcdedit with no arguments, you should see a property called hypervisorlaunchtype. This will be set to off or auto.

To disable Hyper-V in order to use VirtualBox, open a command prompt as administrator and run the command:

bcdedit /set hypervisorlaunchtype off

You’ll need to reboot, but then you’ll be all set to run VirtualBox. To turn Hyper-V back on, run:

bcdedit /set hypervisorlaunchtype auto
@kenng
kenng / gin-secure-https.go
Last active December 13, 2023 09:30
redirect gin http to https using unrolled/secure
// gin will throw following for the first time due to secure initiate a http.Redirect but gin is unaware of it
// [GIN-debug] [WARNING] Headers were already written. Wanted to override status code 301 with 200
package main
import (
"github.com/gin-gonic/gin"
"github.com/unrolled/secure"
)
@hidva
hidva / http_get.go
Created October 24, 2016 02:58
golang wget
package main
import (
"context"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"time"