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 / random.js
Created February 4, 2023 19:54
secure random in nodejs
'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);
@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 / calc.js
Created August 26, 2022 13:55
3reel slot calc.
/* 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 = [
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 (
#!/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();"
@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 / randomstuff.php
Last active September 16, 2021 14:05
randomstuff
<?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];
@vip3r011
vip3r011 / dist.php
Last active November 14, 2020 09:21
distribution
<?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');
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;
@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()
{