Skip to content

Instantly share code, notes, and snippets.


Eric A. Scuccimarra escuccim

View GitHub Profile
escuccim /
Created Apr 17, 2018
Python Function to Flatten Nested Lists
# this works just like "unlist" in R
def flatten(l):
out = []
for item in l:
if isinstance(item, (list, tuple)):
return out
escuccim /
Created Jan 28, 2018
Code to sync columns for two pandas dataframes
# For two dataframes X1 and X2, sync columns in X2 to be same as X1 in same order.
missing_cols = set( X1.columns ) - set( X2.columns )
for c in missing_cols:
X2[c] = 0
X2 = X2[X1.columns]
escuccim / gist:e8c49993616468e6305e062e4d5765b2
Created Apr 12, 2017
MySQL Query to delete duplicate rows
View gist:e8c49993616468e6305e062e4d5765b2
DELETE n1 FROM names n1, names n2 WHERE > AND =
escuccim / unaccent.php
Created Apr 12, 2017
PHP Function to Remove Accents from Strings
View unaccent.php
function unaccent($string)
return preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);~i', '$1', htmlentities($string, ENT_COMPAT, 'UTF-8'));
escuccim / BackupDB.php
Created Jan 30, 2017
Laravel Command to Backup File to Amazon S3
View BackupDB.php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Aws\Laravel\AwsFacade as AWS;
class BackupDB extends Command
escuccim / metadata.php
Last active Jan 11, 2017
Laravel MetaData translation file
View metadata.php
return [
'default-title' => 'Default page title',
'default-description' => 'My whatever whatever web site default description text',
'/termsandconditions-title' => 'Terms and Conditions',
'/termsandconditions-description' => 'Terms and conditions for the website',
'/privacypolicy-title' => 'Privacy Policy',
'/privacypolicy-description' => 'Privacy policy for the website',
escuccim / helpers.php
Last active Jan 11, 2017
Laravel helper function to get translated page title and description from lang file metadata.php
View helpers.php
function getMetaData($type){
// set a default so it doesn't break phpunit
$page = $_SERVER['REQUEST_URI'];
$page = "/";
// if we are looking at a blog article just use the default for the main blog page
if(strpos($page, 'blog') !== false) {
$page = '/blog';
escuccim / helpers.php
Created Jan 10, 2017
Laravel Helper to set language from session
View helpers.php
function setLanguage(){
// set the app locale
App::setLocale( session('locale') ? session('locale') : config('app.locale'));
// set PHP locale for formatting dates
if(App::getLocale() == 'fr')
setlocale(LC_TIME, 'fr_CH.UTF-8');
escuccim / SetLanguage.php
Created Jan 10, 2017
Laravel Middleware to set language from subdomain
View SetLanguage.php
namespace App\Http\Middleware;
use Closure;
class SetLanguage
* Handle an incoming request.
You can’t perform that action at this time.