Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am receptor on github.
* I am sebp (https://keybase.io/sebp) on keybase.
* I have a public key ASBlTt0ie4yELLDigD6AcIH-B-AqIIlEONlZEZ2MnwRp4Qo
To claim this, I am signing this object:
@receptor
receptor / http2redis.ts
Created March 20, 2019 02:03
Publish HTTP request to Redis channel
process.on("SIGINT", () => process.exit());
import * as bodyParser from "body-parser";
import express from "express";
import redis from "redis";
// logger
const now = () => new Date().toISOString();
const loggerFacility = console;
const logger = {
brew install ffmpeg
cd /path/to/flac
for i in *.flac; do ffmpeg -i "$i" -vn -c:a alac "$(basename "$i" .flac).m4a"; done;
@receptor
receptor / gist:c9e53d255877758ce510c4899a986a33
Created November 23, 2018 15:39
OpenSSL encrypt & decrypt one-liners
ENCRYPT
$ echo "my secret message" | openssl aes-256-cbc -a -salt
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
U2FsdGVkX19T5h74/9HOtWBX4WoIggVKksYf7L1WBso=
DECRYPT
$ echo "U2FsdGVkX19T5h74/9HOtWBX4WoIggVKksYf7L1WBso=" | openssl aes-256-cbc -a -d -salt
enter aes-256-cbc decryption password:
my secret message
### Keybase proof
I hereby claim:
* I am receptor on github.
* I am sebp (https://keybase.io/sebp) on keybase.
* I have a public key ASBlTt0ie4yELLDigD6AcIH-B-AqIIlEONlZEZ2MnwRp4Qo
To claim this, I am signing this object:
@receptor
receptor / learn-git-the-hard-way.txt
Created March 14, 2018 21:36
Learn Git the hard way
1) Reference
Many will know this already, but I need to make sure you know it because it’s so fundamental.
A ‘reference’ is a string that points to a commit.
There are four main types of reference: HEAD, Tag, Branch, and Remote Reference.
HEAD
HEAD is a special reference that always points to where the git repository is.
If you checked out a branch, it’s pointed to the last commit in that branch.
@receptor
receptor / jsclone.js
Last active February 2, 2018 15:57
javascript clone
// usage
// const obj = /* ... */;
// const sc = await jsclone.structuralClone(obj);
// const c = jsclone.clone(obj);
moudule.exports = {
structuralClone(obj) => {
return new Promise(resolve => {
const {port1, port2} = new MessageChannel();
@receptor
receptor / nopetyavac.bat
Last active June 29, 2017 08:56
Vaccination for Petya ransomware
@echo off
REM Administrative check from here: https://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights
REM Vaccination discovered by twitter.com/0xAmit
REM Batch file created by Lawrence Abrams of BleepingComputer.com. @bleepincomputer @lawrenceabrams
echo Administrative permissions required. Detecting permissions...
echo.
net session >nul 2>&1
@receptor
receptor / ConsoleLog.js
Created January 27, 2017 16:34
console.log wrapper
// Full version of `log` that:
// * Prevents errors on console methods when no console present.
// * Exposes a global 'log' function that preserves line numbering and formatting.
(function () {
var method;
var noop = function () { };
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
@receptor
receptor / EscapeHtml.js
Created January 27, 2017 16:30
Cross-browser safe and fast HTML sanitizer
// Use the browser's built-in functionality to quickly and safely escape the string
function escapeHtml(str)
{
var div = document.createElement('div')
div.appendChild(document.createTextNode(str))
return div.innerHTML
}
// UNSAFE with unsafe strings; only use on previously-escaped ones!
function unescapeHtml(escapedStr)