Skip to content

Instantly share code, notes, and snippets.

Avatar

Sergi Tur Badenas acacha

View GitHub Profile
@acacha
acacha / platform_game.js
Last active Apr 1, 2016
Phaser platform game basic with audio from http://www.lessmilk.com/game/platformer/
View platform_game.js
var playState = {
preload: function() {
game.stage.backgroundColor = '#3498db';
game.load.spritesheet('player', 'assets/player.png', 28, 22);
game.load.image('wall', 'assets/wall.png');
game.load.image('ground', 'assets/ground.png');
game.load.image('dust', 'assets/dust.png');
View AuthServiceProvider
<?php namespace PrivacyDriver\Providers;
use Cache;
use Config;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Collection;
use Artisan;
use Gate;
use PrivacyDriver\Cache\PDRedisStore;
View Vue auth workflow example
<div id="app">
<div v-if="userId">
<p>You are logged in! Your user ID is: {{userId}}</p>
<p>Click <a @click="logout">here</a> to logout</p>
</div>
<div v-if="!userId">
<p>I don't know you. You should <a @click="login">login</a>.</p>
</div>
</div>
@acacha
acacha / hello.js
Last active Oct 18, 2016
hello world
View hello.js
function hello($name,$sn1){
echo "Hola " . $name . " " . $sn1 . "!";
}
@acacha
acacha / basicauth.php
Last active Nov 17, 2016
PHP HTTP Basic Authentication
View basicauth.php
<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
}
View AdminUsersSeeder.php
<?php
use Illuminate\Database\Seeder;
/**
* Class AdminUsersSeeder
*/
class AdminUsersSeeder extends Seeder
{
/**
@acacha
acacha / gist:b59aa63d8fed9347b929
Created Jan 19, 2015
isConnected Android. Check if device is connected
View gist:b59aa63d8fed9347b929
private static boolean isConnected(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = null;
if (connectivityManager != null) {
networkInfo =
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
}
return networkInfo == null ? false : networkInfo.isConnected();
}
@acacha
acacha / mysql_backup.sh
Last active Mar 18, 2017
Mysql Backup
View mysql_backup.sh
#!/bin/sh
#CÒPIA DE SEGURETAT BASE DE DADES MEDIAWIKI
# First clean files older than 20 days: http://acacha.org/mediawiki/index.php/Tmpwatch
tmpreaper --verbose 20d /linux2/backups/mysql
inici=`date`
dia=`date "+%Y%m%d"`
mysql_backups_folder="/linux2/backups/mysql"
echo "##################################################################################"
echo "Executant còpia de base de dades (mysqldump) de mediawiki. Inici: $inici"
echo "##################################################################################"
View _convert_date_to_sql_date
protected function _convert_date_to_sql_date($date)
{
$date = substr($date,0,10);
if(preg_match('/\d{4}-\d{2}-\d{2}/',$date))
{
//If it's already a sql-date don't convert it!
return $date;
}elseif(empty($date))
{
return '';
@acacha
acacha / adminlte_box.html
Last active Jun 15, 2017
AdminLTE widget/box example
View adminlte_box.html
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Removable</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
</div>
</div>
<div class="box-body">
The body of the box