Skip to content

Instantly share code, notes, and snippets.

Alexey Kopytko sanmai

View GitHub Profile
@sanmai
sanmai / isset_vs_array_key_exists.php
Last active Mar 20, 2020 — forked from alcaeus/in_array_vs_isset_vs_array_key_exists.php
Performance comparision: isset vs. array_key_exists
View isset_vs_array_key_exists.php
<?php
function testPerformance($name, Closure $closure, $runs)
{
$start = microtime(true);
for (; $runs > 0; $runs--)
{
$_ = $closure();
}
$end = microtime(true);
@sanmai
sanmai / example.txt
Last active Apr 20, 2019
Signed file example
View keybase.md

Keybase proof

I hereby claim:

  • I am sanmai on github.
  • I am sanmai (https://keybase.io/sanmai) on keybase.
  • I have a public key ASAEQqjFdv38mOryXsV-joWg1qDmcWwQr5mtqYaih13nDAo

To claim this, I am signing this object:

View README.md
@sanmai
sanmai / dropbox_ext4.c
Created Aug 15, 2018 — forked from dimaryaz/dropbox_ext4.c
Dropbox ext4 hack
View dropbox_ext4.c
/*
* dropbox_ext4.c
*
* Compile like this:
* gcc -shared -fPIC -ldl -o libdropbox_ext4.so dropbox_ext4.c
*
* Run Dropbox like this:
* LD_PRELOAD=./libdropbox_ext4.so ~/.dropbox-dist/dropboxd
*/
View Dropbox_fix.markdown

Hey guys,

I have a really terrible hack, but it appears to work, so...

Dropbox calls statfs64 to get the filesystem type. Now, if only there was a way to change its return value to "ext4"... oh wait, there is!

Here's code of the new function: dropbox_ext4.c

/*
@sanmai
sanmai / stats_rand_gen_normal.php
Created Apr 27, 2018
Marsaglia polar method in PHP - stats_rand_gen_normal polyfill
View stats_rand_gen_normal.php
<?php
if (!function_exists('stats_rand_gen_normal')) {
function stats_rand_gen_normal($mu, $sigma) {
do {
$u = (rand() / getrandmax()) * 2 - 1;
$v = (rand() / getrandmax()) * 2 - 1;
$s = $u * $u + $v * $v;
} while ($s >= 1 || $s == 0);
$multiplier = sqrt(-2 * log($s) / $s);
View 47k-80-80-ignore-random-noreverse-chr1.csv
We can't make this file beautiful and searchable because it's too large.
10430,10504,1,1
10472,10534,13,2
10472,10548,3,3
14470,14672,1,4
14470,14698,13,5
15119,15342,3,6
16140,16409,1,7
17453,17513,1,8
17453,17542,1,9
You can’t perform that action at this time.