Skip to content

Instantly share code, notes, and snippets.

View victusfate's full-sized avatar
🚀

Mark Essel victusfate

🚀
View GitHub Profile
@victusfate
victusfate / redis-inventory-install.sh
Last active February 16, 2024 16:11
install redis-inventory and go
trying https://github.com/obukhov/redis-inventory first
install go 1.15
https://www.5gfundamental.com/2021/04/install-go-lang-latest-version-1155-in.html
git clone https://github.com/obukhov/redis-inventory
sudo wget https://golang.org/dl/go1.15.5.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.15.5.linux-amd64.tar.gz
export default function AppWs() {
const [isPaused, setPause] = useState(false);
const ws = useRef(null);
useEffect(() => {
ws.current = new WebSocket("wss://ws.kraken.com/");
ws.current.onopen = () => console.log("ws opened");
ws.current.onclose = () => console.log("ws closed");
const wsCurrent = ws.current;
anonymous
anonymous / Loot
Created May 31, 2017 16:28
D&D 5E Minor and Medium Loot from Creatures in roll20
on("ready", function() {
on("chat:message", function (msg) {
if (msg.type === "api" && msg.content === "!MediumLoot") {
Loot('medium');
}
if (msg.type === "api" && msg.content === "!MinorLoot") {
Loot('minor');
}
});
@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
defmodule MyApp.CLI do
def main(_args) do
IO.puts("Hello from MyApp!")
end
end
@orottier
orottier / RetryTest.php
Last active July 21, 2023 10:10
Retry function for PHP with exponential backoff
<?php
class RetryTest extends TestCase
{
public function setUp()
{
parent::setUp();
// abuse superglobal to keep track of state
$_GET['a'] = 0;
}

Some quick notes about PRNGs

If the docs don't specify the cycle length, IMHO better not use it in situations where it matters.

65**5 is about 30 bits. if the PRNG-state is 32 bits, and the PRNG algorithm doesn't cycle through the full state, that may already be too little.

In many languages the default PRNG is implemented as a LCG, which are just 2-3 lines of code, and just not very good on their own. Computational science has found much, much better algorithms that are (almost) just as tiny to implement. Maybe 4-5 lines, see PCG-random.org.

I recently used a Java port of CMWC4096 from StackOverflow, for a numerical simulation in Java (where the default Math.random() has a stupid-bad cycle length, and the Java crypto-PRNG might have been too slow). It worked great. Not quite as tiny as PCG-random, but still short and it was ready-to-use Java-code that fit my needs.

import Foundation
/// NSURLSession synchronous behavior
/// Particularly for playground sessions that need to run sequentially
public extension NSURLSession {
/// Return data from synchronous URL request
public static func requestSynchronousData(request: NSURLRequest) -> NSData? {
var data: NSData? = nil
let semaphore: dispatch_semaphore_t = dispatch_semaphore_create(0)
@harlow
harlow / golang_job_queue.md
Last active April 24, 2024 10:21
Job queues in Golang
@ranacseruet
ranacseruet / pushNotifier
Last active September 30, 2016 15:16
A simple NodeJS script, to implement apple push notification service
var apn = require("apn")
var apnError = function(err){
console.log("APN Error:", err);
}
var options = {
"cert": "cert.pem",
"key": "key.pem",
"passphrase": null,