Skip to content

Instantly share code, notes, and snippets.

Avatar
🌀
WIP

Vlad Voloshyn NewEXE

🌀
WIP
View GitHub Profile
@NewEXE
NewEXE / index.php
Created May 9, 2021
Fast and simple getRandNumber function (PHP)
View index.php
<?php
$num = getRandNumber(5);
var_dump($num);
/**
* Returns fixed-length random integer.
*/
function getRandNumber(int $length): int
@NewEXE
NewEXE / index.php
Last active May 12, 2020
PHP random funtion
View index.php
<?php
// From old versions of Laravel
// Don't use in cryptography
function str_random($length = 16)
{
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
return substr(str_shuffle(str_repeat($pool, $length)), 0, $length);
}
@NewEXE
NewEXE / index.php
Last active Aug 18, 2021
Convert anything to string (PHP)
View index.php
<?php
/**
* @param mixed $value Value of any PHP type.
* @return string Value as readable string.
*/
function toString($value, $compactArray = true): string
{
$data_type = '';
if (is_array($value)) {
@NewEXE
NewEXE / ConvertToObj.cs
Last active Aug 30, 2021
Export Unity Game Objects to Wavefront OBJ
View ConvertToObj.cs
// On the basis: https://forum.unity.com/threads/export-obj-while-runtime.252262/
// How to use:
// Put file to Assets/Editor folder
// then select GameObject -> Export selected objects
// in Unity's main panel.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
@NewEXE
NewEXE / parser.php
Last active Sep 26, 2019
LoveRead.ec parser (PHP)
View parser.php
<?php
/**
* Book ID on loveread.ec
* For example, for
* http://loveread.ec/read_book.php?id=2555&p=1
* ID is 2555.
*
* @param int $id
*/
public function getFromLoveread(int $id) {
@NewEXE
NewEXE / test1.php
Last active Sep 15, 2018
PDO Memory Leak
View test1.php
<?php
// Related SO disscussion:
// https://stackoverflow.com/questions/52348483/pdo-mysqli-memory-leak-on-multiple-select-queries
$dbParams = [
'host' => 'localhost',
'dbname' => 'playground',
'username' => 'homestead',
'password' => 'secret',
];