Skip to content

Instantly share code, notes, and snippets.

@L2Eme
L2Eme / asyncQueue.ts
Created May 20, 2022 02:46
In memory async queue in typescript
type Callback<T> = () => Promise<T>
export type AsyncQueue<T = void> = {
push: (task: Callback<T>) => Promise<T>
flush: () => Promise<void>
size: number
}
/**
* Ensures that each callback pushed onto the queue is executed in series.
@L2Eme
L2Eme / index.js
Created December 10, 2020 08:29 — forked from marekyggdrasil/index.js
node.js example on how to connect to the grin-wallet owner API based on: it is a modified official example from here: https://github.com/mimblewimble/grin-wallet/tree/1ced8990b9e21fa17c788d93a151ec1164ebbce5/doc/samples/v3_api_node
/* Sample Code for connecting to the V3 Secure API via Node
*
* With thanks to xiaojay of Niffler Wallet:
* https://github.com/grinfans/Niffler/blob/gw3/src/shared/walletv3.js
*
*/
const http = require('http');
const crypto = require('crypto');
@L2Eme
L2Eme / application.ex
Last active March 24, 2019 15:58
elixir :poolboy example
defmodule PoolboyApp.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
defp poolboy_config do
[
{:name, {:local, :worker}},
@L2Eme
L2Eme / Dockerfile
Last active January 21, 2019 06:33
grin cpu miner
FROM rust:1.31
RUN apt-get install -y git cmake make zlib1g-dev pkgconf ncurses-dev \
libncursesw5-dev linux-headers-generic g++ libssl-dev
WORKDIR /usr/src
RUN git clone https://github.com/mimblewimble/grin-miner.git
WORKDIR /usr/src/grin-miner
function promisify(f: any) {
return function () {
let args = Array.prototype.slice.call(arguments)
return new Promise(function (resolve, reject) {
args.push(function (err: any, result: any) {
if (err) reject(err)
else resolve(result)
})
f.apply(null, args)
})
@L2Eme
L2Eme / npm-user-change.sh
Created December 7, 2018 01:05
change npm user
if [ $1 = "user1" ]
then
echo "user : $1";
echo -e "registry=http://registry.npmjs.org/\n//registry.npmjs.org/:_authToken=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" > ~/.npmrc;
elif [ $1 = "user2" ]
then
echo "user : $1";
echo -e "registry=http://registry.npmjs.org/\n//registry.npmjs.org/:_authToken=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" > ~/.npmrc;
fi
@L2Eme
L2Eme / ipc-pipe.go
Created December 1, 2018 08:48
go env | grep GOROOT
package main
import "fmt"
import "os/exec"
import "bufio"
import "bytes"
func main() {
//create cmd
@L2Eme
L2Eme / shell.ex
Created November 28, 2018 01:52
elixir call executable programe
defmodule Shell do
def exec(exe, args) when is_list(args) do
port = Port.open({:spawn_executable, exe}, [{:args, args}, :stream, :binary, :exit_status, :hide, :use_stdio, :stderr_to_stdout])
handle_output(port)
end
def handle_output(port) do
receive do
{^port, {:data, data}} ->
IO.puts(data)
@L2Eme
L2Eme / ECC.md
Last active November 24, 2018 03:58

1. ECC info

(k+j)*H = k*H + j*H

in node js

@L2Eme
L2Eme / rpc-client.js
Last active November 23, 2018 08:17
node js rpc client
const http = require('http')
class RPCClient {
/**
* * Creates an instance of RPCClient.
* *
* * @param {any} options {hostname:string, port:number, user:string, pass:string, timeout: number}
* * @memberof RPCClient
* */