This file contains 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
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
class SetLanguage | |
{ | |
/** | |
* Handle an incoming request. |
This file contains 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 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'); | |
} |
This file contains 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 getMetaData($type){ | |
// set a default so it doesn't break phpunit | |
if(isset($_SERVER['REQUEST_URI'])) | |
$page = $_SERVER['REQUEST_URI']; | |
else | |
$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'; |
This file contains 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
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', | |
]; |
This file contains 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
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
use Aws\Laravel\AwsFacade as AWS; | |
class BackupDB extends Command | |
{ | |
/** |
This file contains 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 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')); | |
} |
This file contains 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
DELETE n1 FROM names n1, names n2 WHERE n1.id > n2.id AND n1.name = n2.name |
This file contains 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
# 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] |
This file contains 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
# this works just like "unlist" in R | |
def flatten(l): | |
out = [] | |
for item in l: | |
if isinstance(item, (list, tuple)): | |
out.extend(flatten(item)) | |
else: | |
out.append(item) | |
return out |
This file contains 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
# mean encoding | |
means = X_tr.groupby(col).target.mean() | |
train_new[col+'_target_mean'] = train_new[col].map(means) | |
val_new[col+'_target_mean'] = val_new[col].map(means) |
OlderNewer