Skip to content

Instantly share code, notes, and snippets.

View poteirard's full-sized avatar
🤍

Gerard Brull poteirard

🤍
View GitHub Profile
04c0e9c2df6ecd45da1c41ed27fc993361bf5001a5ba288c6d8cf817201bc268777720f0b121fee28a95eb5be247f238c7d778a56c921cb19c4b8bf5313650fcbc
@poteirard
poteirard / snakify.js
Created December 14, 2017 14:24 — forked from incik/snakify.js
Transform camelCase keys of an object into snake_case
function snakifyKeys(fields) {
// because this function can receive map of ArrayNodes, we have to do this
let jsonFields = JSON.parse(JSON.stringify(fields));
for (let key in jsonFields) {
if (jsonFields[key] instanceof Object) {
// we need to go deeper!
jsonFields[key] = snakifyKeys(jsonFields[key]);
}
@poteirard
poteirard / mostUsedPhpFunctions.php
Last active October 24, 2016 12:57
List most used php functions in a tree of directories with php files
<?php
$baseDir = 'phpfiles/path/';
$dir = new RecursiveDirectoryIterator($baseDir);
$Iterator = new RecursiveIteratorIterator($dir);
$regexFiles = new RegexIterator($Iterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);
$phpFunctions = get_defined_functions();
$functionsCount = array();
foreach ($regexFiles as $filename => $file) {
@poteirard
poteirard / 0_reuse_code.js
Created December 31, 2015 14:31
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console