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 / geolocation.js
Last active April 24, 2023 09:30
geolocation
var GEOLOCATION_ALLOW = true;
(() => {
try {
//geolocate: enable - true, disable - false
//get this setting from db
const geolocate = localStorage.getItem('geolocate');
if (geolocate !== null) {
GEOLOCATION_ALLOW = Boolean(geolocate);
}
@dbist
dbist / Using PGBouncer with CockroachDB.md
Last active November 17, 2023 15:13
Using PGBouncer with CockroachDB

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.


@harveyconnor
harveyconnor / a-mongodb-replica-set-docker-compose-readme.md
Last active June 24, 2024 15:07
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!

@Jervelund
Jervelund / work_queue.php
Created March 1, 2016 04:03
PHP semaphore worker queue
<?PHP
/*
Simple implementation of process queue in PHP using MySQL database.
This method does not use simple semaphores, as it is impotant for the application to run input in sequential order for each thread (order of data received).
CREATE TABLE IF NOT EXISTS `sessions` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`thread` int(11) NOT NULL,
`time_initiated` decimal(14,4) unsigned NOT NULL,
`time_heartbeat` decimal(14,4) unsigned NOT NULL,
@lpinca
lpinca / prng.js
Last active January 23, 2023 22:19
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);
};
@umutakturk
umutakturk / php_mongodb_simple_pagination.php
Created September 29, 2012 19:01
PHP MongoDB Simple Pagination
<?php
$mongodb = new Mongo("mongodb://username:password@localhost/database_name");
$database = $mongodb->database_name;
$collection = $database->collection;
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
$limit = 12;
$skip = ($page - 1) * $limit;
$next = ($page + 1);
$prev = ($page - 1);