Skip to content

Instantly share code, notes, and snippets.

View acacha's full-sized avatar

Sergi Tur Badenas acacha

View GitHub Profile
@acacha
acacha / platform_game.js
Last active April 1, 2016 14:24
Phaser platform game basic with audio from http://www.lessmilk.com/game/platformer/
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');
<?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;
<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 October 18, 2016 13:52
hello world
function hello($name,$sn1){
echo "Hola " . $name . " " . $sn1 . "!";
}
@acacha
acacha / basicauth.php
Last active November 17, 2016 17:59
PHP HTTP Basic Authentication
<?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>";
}
<?php
use Illuminate\Database\Seeder;
/**
* Class AdminUsersSeeder
*/
class AdminUsersSeeder extends Seeder
{
/**
@acacha
acacha / gist:b59aa63d8fed9347b929
Created January 19, 2015 11:44
isConnected Android. Check if device is connected
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 March 18, 2017 14:39
Mysql Backup
#!/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 "##################################################################################"
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 June 15, 2017 10:25
AdminLTE widget/box example
<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