Skip to content

Instantly share code, notes, and snippets.

View lgh06's full-sized avatar

Daniel Liu lgh06

View GitHub Profile
#!/usr/bin/env pwsh
# https://stackoverflow.com/questions/8761888/capturing-standard-out-and-error-with-start-process
function Start-Command ([String]$Path, [String]$Arguments) {
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $Path
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = $Arguments
@lgh06
lgh06 / README.md
Created March 31, 2022 01:39 — forked from mrbar42/README.md
bash scripts to create VOD HLS stream with ffmpeg almighty (tested on Linux and OS X)

running:

bash create-vod-hls.sh beach.mkv

will produce:

    beach/
      |- playlist.m3u8
 |- 360p.m3u8
@lgh06
lgh06 / amqplib-delayed-message.js
Created January 23, 2022 08:53 — forked from materkel/amqplib-delayed-message.js
Scheduling messages with RabbitMQ, using the rabbitmq_delayed_message_exchange plugin and amqplib in NodeJS
/**
* Install and enable the rabbitmq_delayed_message_exchange plugin as described by Alvaro Videla in this blogpost:
* https://www.rabbitmq.com/blog/2015/04/16/scheduling-messages-with-rabbitmq/
*/
const amqp = require('amqplib');
const exchange = 'yourExchangeName';
const queue = 'yourQueueName';
const queueBinding = 'yourQueueBindingName';
// Message consumer
@lgh06
lgh06 / libsodium xchacha20poly1305_ietf.js
Created January 10, 2022 04:13 — forked from 842Mono/libsodium xchacha20poly1305_ietf.js
Encrypting and decrypting a message using secret key aead xchacha20poly1305_ietf (libsodium js)
'use strict'
const sodium = require('libsodium-wrappers');
sodium.ready.then(function()
{
console.log('sodium ready');
//xchacha20ploy1305 ietf
//A key and a nonce are generated by the encrypting party. The decrypting
//party should use them for decryption
const useFetch = (service) => {
const [loading, setLoading] = useState(true);
const [error, setError] = useState();
const [data, setData] = useState();
const fetchAPI = useCallback(async () => {
try {
const res = await fetch(service);
const json = await res.json();
setData(json);
@lgh06
lgh06 / DecryptDbeaver.java
Last active July 17, 2020 13:58 — forked from james-ni/DecryptDbeaver.java
retrieve password stored in DBeaver
import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.*;
@lgh06
lgh06 / ngrxintro.md
Created December 18, 2018 09:11 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

#EXTM3U
#EXTINF:-1,BBC - Radio 1
http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p
#EXTINF:-1,BBC - Radio 2
http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio2_mf_p
#EXTINF:-1,BBC - Radio 3
http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-aac-lc-a/format/pls/vpid/bbc_radio_three.pls
#EXTINF:-1,BBC - Radio 4
http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4fm_mf_p
#EXTINF:-1,BBC - Radio 5 live
@lgh06
lgh06 / better-nodejs-require-paths.md
Created January 12, 2017 08:34 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@lgh06
lgh06 / task.js
Created November 9, 2016 02:30 — forked from zmofei/task.js
cutwords
var fs = require('fs')
var trie = {}
var tempWords = {};
fs.readFile('./text.txt',function(err,callback){
var str = callback.toString();
str = str.replace(/[^\u4e00-\u9fa5]/g,'@');
str = str.replace(/@+/g,' ')
split(str);