Skip to content

Instantly share code, notes, and snippets.

@atrakeur
atrakeur / updater.php
Last active August 29, 2015 13:57
A simple php utility to make a backup actual version and extract a new version of a website from an uploaded zip.
<?php
/*
* Configuration
*/
// Le nom de ce fichier
$filename = "updater.php";
// Le repertoire ou extraire la nouvelle version
$extractdir= "./";
// Le repertoire ou sauvegarder l'ancienne version
<?php
/*
* Defaut display of Carbon dates can be changed using the method
* This method have to be called BEFORE outputing any date to string
*/
\Carbon\Carbon::setToStringFormat('d-m-Y H:i:s');
/*
* Can be setup in your models constructors like this:
*/
@atrakeur
atrakeur / ApiController.php
Created June 10, 2014 21:01
An laravel's style implementation of API handler.
<?php
/*************************************************
* API base controller for laravel
*************************************************/
class ApiController extends Controller {
/**
* Create a json Response including errors and no data
* @param array $errors the errors
* @return responce The responce including error data
@atrakeur
atrakeur / LaravelEnhancedModel.php
Created June 18, 2014 20:01
A simple way to add toObject ability to eloquent models. Usefull for generating stdClass objects instead of flat arrays.
<?php namespace Atrakeur\EnhancedModels;
use \stdClass;
abstract class EnhancedModel extends \Eloquent {
/*****************************************
* Act like toArray but generate stdClass objects on the current object.
*****************************************/
public function toObject()
@atrakeur
atrakeur / androidstudio.sh
Created November 4, 2014 10:26
Download and launch android studio (used in corporate env with limited storage & programs)
cd /tmp
wget https://dl.google.com/dl/android/studio/ide-zips/0.8.14/android-studio-ide-135.1538390-linux.zip
zip -r android-studio-ide-135.1538390-linux.zip .
idea-IC-135.1230/bin/idea.sh
rm -rf idea-IC-135.1230
rm -f android-studio-ide-135.1538390-linux.zip
@atrakeur
atrakeur / InstallController.php
Created January 23, 2015 17:52
Laravel database installation script
<?php
use Symfony\Component\Console\Output\BufferedOutput;
class InstallController extends BaseController {
public function index($user, $pass)
{
//check trivial pour éviter les reset intenpestifs
//a vous d'implemnter votre propre méthode de verrification
if ($user != "MonUser" || $pass != "MonPass")
@atrakeur
atrakeur / wercker.yml
Created August 5, 2015 07:52
Wercker deploy phpunit coverage and phpdoc to a git repo (github webpages for example)
deploy:
steps:
# Add SSH-Key to current box
# You have to generate an ssh key in wercker, add it to your github/bitbucket accoung
# Then you have to add the ssh key to your env vars in wercker
- leipert/add-ssh-key-gh-bb:
keyname: deploy_ssh
# Add bitbucket to known hosts, so they won't ask us whether we trust bitbucket (change this if using github)
# on your local machine use ssh-keyscan github.com >> thefingerprint to get it
- add-to-known_hosts:
@atrakeur
atrakeur / ConvertJ2ObjC.sh
Created August 19, 2015 10:06
Bash script to convert a Java Android module to IOS with J2ObjC
# Variables d'env (paths divers)
export APPPATH=$(pwd)/data # Le chemin vers votre module java a convertir
export J2OBJC=~/utils/j2objc-0.9.7 # Le chemin vers votre install de j2ObjC
# Convert tous les fichiers dans src/main/java
# Place l'export dans build/objc
# Ignore les fichiers commençant pas Android
# Cela permet de prefixer par Android/IOS les codes propres aux deux plateformes
cd $APPPATH
$J2OBJC/j2objc -use-arc -d build/objc -sourcepath src/main/java \
@atrakeur
atrakeur / php7.php
Created December 5, 2015 20:46
PHP 7 example of a static typed function
<?php
function multiply(int a, int b) : float {
return a * b;
}
@atrakeur
atrakeur / HelloWorldEsp8266.ino
Last active March 15, 2016 12:10
Sample code to start using an esp8266 from an arduino. See full blog post on https://www.atrakeur.com/blog/art27-ajoutez_du_wifi_sur_votre_projet_arduino_simplement
#define RST_PIN 8
#define CHPD_PIN 9
#define DISP_PIN 13
void setup() {
//Ouvre le serial vers le pc (serial) et vers l'esp (serial1)
Serial.begin(9600);
Serial1.begin(115200);
//Leonardo: On attend l'ouverture du serial sur le pc avant de continuer
while(!Serial);