This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const crypto = require('crypto'); | |
class RNG { | |
// Define a static method for generating a random float value in the range of 0 to 1 | |
static random() { | |
try { | |
// Use the crypto module's randomBytes method to generate 4 random bytes | |
const randomBytes = crypto.randomBytes(4); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 3 reel slot, no wilds, no scatter*/ | |
function occur(array){ | |
const occurrences = array.reduce(function (acc, curr) { | |
return acc[curr] ? ++acc[curr] : acc[curr] = 1, acc | |
}, {}); | |
return occurrences; | |
} | |
const reels = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT l.metric, l.nr AS bytes | |
, CASE WHEN is_size THEN pg_size_pretty(nr) END AS bytes_pretty | |
, CASE WHEN is_size THEN nr / NULLIF(x.ct, 0) END AS bytes_per_row | |
FROM ( | |
SELECT min(tableoid) AS tbl -- = 'public.tbl'::regclass::oid | |
, count(*) AS ct | |
, sum(length(t::text)) AS txt_len -- length in characters | |
FROM public.TABLE-NAME-HERE t -- provide table name *once* | |
) x | |
CROSS JOIN LATERAL ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#in your php.ini set session.gc_probability = 0 | |
#this disables php GC | |
# put this script via cron | |
# or in /etc/cron.hourly | |
/usr/bin/php -d session.save_path=/var/lib/php/session -d session.gc_probability=1 -d session.gc_divisor=1 -d session.gc_maxlifetime=3600 -r "session_start(); session_destroy();" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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])); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function randomInt(int $min, int $max) :int | |
{ | |
$getFloat = function() | |
{ | |
$bytes = random_bytes(7); | |
$bytes[6] = $bytes[6] | chr(0xF0); | |
$bytes .= chr(63); // exponent bias (1023) | |
$float = unpack('d', $bytes)[1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function randomInt(int $min, int $max) :int | |
{ | |
if (!is_int($min)) { | |
throw new \Exception('First parameter ($min) must be an integer'); | |
} | |
if (!is_int($max)) { | |
throw new \Exception('Second parameter ($max) must be an integer'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gpch.login.configuration; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | |
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |
import org.springframework.security.config.annotation.web.builders.WebSecurity; | |
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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() | |
{ |