Skip to content

Instantly share code, notes, and snippets.

View vip3r011's full-sized avatar
🏠
Working from home

vip3r011

🏠
Working from home
  • ZA
View GitHub Profile
@vip3r011
vip3r011 / CMWCRand.js
Created January 15, 2024 12:12 — forked from toji/CMWCRand.js
Simple Javascript implementation of CMWC Psuedorandom algorithm
// This was basically ripped straight from http://en.wikipedia.org/wiki/Multiply-with-carry, just javscriptified.
var CMWCRand = function(seed) {
var i, PHI = 0x9e3779b9;
if(!seed) { seed = Date.now(); }
var Q = this.Q = new Uint32Array(4096);
this.c = 362436;
this.i = 4095;
Q[0] = seed;
@vip3r011
vip3r011 / a-mongodb-replica-set-docker-compose-readme.md
Created August 24, 2023 20:09 — forked from harveyconnor/a-mongodb-replica-set-docker-compose-readme.md
MongoDB Replica Set / docker-compose / mongoose transaction with persistent volume

This will guide you through setting up a replica set in a docker environment using.

  • Docker Compose
  • MongoDB Replica Sets
  • Mongoose
  • Mongoose Transactions

Thanks to https://gist.github.com/asoorm for helping with their docker-compose file!

Using PGBouncer with CockroachDB


PGBouncer is a lightweight connection pooler for PostgreSQL. CockroachDB is a cloud-native SQL database for building global, scalable cloud services that survive disasters.

CockroachDB is PostgreSQL wire compatible database, which means it aims to have tight compatibility with the PG ecosystem. Today, we're going to wire PGBouncer to work with CockroachDB. This article is meant to scratch the surface of possibilities unblocked by PGBouncer with CockroachDB and not meant to be an in-depth overview. We're currently researching this topic and will follow up with official docs on proper architecture and sizing of PGBouncer and CockroachDB.


@vip3r011
vip3r011 / prng.js
Created January 23, 2023 22:19 — forked from lpinca/prng.js
Pseudorandom number generator based on crypto.randomBytes
var crypto = require('crypto')
, rrange = 4294967296;
/**
* Return an integer, pseudo-random number in the range [0, 2^32).
*/
var nextInt = function() {
return crypto.randomBytes(4).readUInt32BE(0);
};
@vip3r011
vip3r011 / hex_to_string.php
Created March 20, 2021 07:50
hex to string in PHP
<?php
function hex_to_string ($hex) {
if (strlen($hex) % 2 != 0) {
throw new Exception('String length must be an even number.', 1);
}
$string = '';
for ($i = 0; $i < strlen($hex) - 1; $i += 2) {
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
}
@vip3r011
vip3r011 / detectWebGL.js
Created September 25, 2018 21:05 — forked from SeanZoR/detectWebGL.js
Detect WebGL with JS in browser
/**
* Detects if WebGL is enabled.
* Inspired from http://www.browserleaks.com/webgl#howto-detect-webgl
*
* @return { number } -1 for not Supported,
* 0 for disabled
* 1 for enabled
*/
function detectWebGL()
{
@vip3r011
vip3r011 / SecureRandomGenerator.java
Created June 1, 2018 11:21 — forked from kaworu/SecureRandomGenerator.java
dieharder on java's SecureRandom and OpenBSD arc4random(3)
/*
* SecureRandomGenerator.java
*
* Output a lot of (random) stuff on stdout.
*/
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
@vip3r011
vip3r011 / block-tor-exit-nodes-iptables.md
Created May 24, 2018 10:39 — forked from jkullick/block-tor-exit-nodes-iptables.md
Block Tor Exit Nodes with IPTables
  1. Install ipset:
apt-get install ipset
  1. Create new ipset:
ipset create tor iphash
@vip3r011
vip3r011 / verify-uuid.php
Created May 23, 2018 10:13 — forked from Joel-James/verify-uuid.php
Check if UUID is in valid format
<?php
/**
* Check if a given string is a valid UUID
*
* @param string $uuid The string to check
* @return boolean
*/
function isValidUuid( $uuid ) {
if (!is_string($uuid) || (preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/', $uuid) !== 1)) {
@vip3r011
vip3r011 / uuid.js
Created May 22, 2018 22:47 — forked from jcxplorer/uuid.js
UUID v4 generator in JavaScript (RFC4122 compliant)
function uuid() {
var uuid = "", i, random;
for (i = 0; i < 32; i++) {
random = Math.random() * 16 | 0;
if (i == 8 || i == 12 || i == 16 || i == 20) {
uuid += "-"
}
uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16);
}