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
<# | |
Original from: | |
https://www.thomasmaurer.ch/2015/03/move-files-to-folder-sorted-by-year-and-month-with-powershell/ | |
Sort files inside a folder and move them to YYYY/MM folders. | |
#> |
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
/* | |
cambiar character set y collation de tablas en mysql | |
nota, al parecer HeidiSQL tiene un bug, tal que al seleccionar la default collation a utf8_unicode_ci, las se cambia la tabla pero no las columnas, | |
si se usa la opcion "convert data" (un checkbox), cambia las columnas a utf8_unicode_ci, pero la tabla la deja como utf8_general_ci | |
para evitar eso, mejor usar el siguiente comando por tabla: | |
ref: http://georgepavlides.info/convert-all-tables-in-a-mysql-database-to-utf8_general_ci/ | |
// nota que en la pagina viene a utf8_general_ci, pero es igual usando utf8_unicode_ci |
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
// just for fun, because there already is a native function: | |
// array array_change_key_case( array $array [, int $case = CASE_LOWER ] ) // || CASE_UPPER | |
function _array_keys_lower($datos){ | |
// convertir keys de MAY a min | |
foreach($datos as $k => $v){ | |
if($k == 0){ | |
$cols = array_keys($v); | |
// pr($cols,"cols"); | |
$Mm = array(); |
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
int equalPairOfBits(int n, int m) { | |
return Integer.lowestOneBit(~(n^m)) ; | |
} | |
int equalPairOfBits(int n, int m) { | |
return (n^=~m)&-n ; | |
} | |
int equalPairOfBits(int n, int m) { | |
return ((n^~m)|((n^~m)-1)) - ((n^~m)-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
function equalPairOfBits(n, m) { | |
return n + m + 1 & ~m - n ; | |
} | |
function equalPairOfBits(n, m) { | |
return ~(n ^= m) & -~n; | |
} | |
function equalPairOfBits(n, m) { | |
return ~(n ^= m) & -~n; |
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
// ok: | |
// nota que el codigo es identico a el ejercicio 'different Rightmost Bit', simplemente cambiando la condicion del if | |
function equalPairOfBits($n, $m) { | |
return call_user_func(function($n,$m){ | |
$na = str_split(strrev(str_pad(decbin($n),32,'0',STR_PAD_LEFT))); | |
$ma = str_split(strrev(str_pad(decbin($m),32,'0',STR_PAD_LEFT))); | |
for($i = 0; $i <32; $i++){ | |
if($na[$i] == $ma[$i]){ | |
return pow(2,$i); | |
} |
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
// false cases | |
$a = array(); | |
$s = ""; | |
$s0 = "0"; // en php es false (por representar un 0), pero en otros lenguajes puede variar, e.g. en javascript se castea como true (por ser cadena no vacia) | |
$i = 0; | |
$b = false; | |
$f = 0.0; | |
$h = 0x00; // el vardump la reporta como int | |
$n = null; |
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
int differentRightmostBit(int n, int m) { | |
return (n^=m) & -n ; | |
} | |
int differentRightmostBit(int n, int m) { | |
return Integer.lowestOneBit(n^m) ; | |
} |
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
function differentRightmostBit(n, m) { | |
return (n^m) & -(n^m); | |
} | |
function differentRightmostBit(n, m) { | |
return (n ^= m) & -n; | |
} | |
function differentRightmostBit(n, m) { | |
return (n ^ m) & (~(n ^ m) + 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
// DDD: | |
function differentRightmostBit($n, $m) { | |
return call_user_func(function($n,$m){ | |
$na = str_split(strrev(str_pad(decbin($n),32,'0',STR_PAD_LEFT))); | |
$ma = str_split(strrev(str_pad(decbin($m),32,'0',STR_PAD_LEFT))); | |
for($i = 0; $i <32; $i++){ | |
if($na[$i] != $ma[$i]){ | |
return pow(2,$i); | |
} | |
} |
NewerOlder