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
@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 / 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 / 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;
}
//Define the echo pin (receive the echo from the ultrasound)
#define SENSOR_ECHO_PIN 7
//Define the trig pin (trigger the ultrasonic emitter)
#define SENSOR_TRIG_PIN 8
//On some sort of sensors, echo and trig can be on the same pin
//Precalculate some values
const float SpeedOfSound = 343.2; // ~speed of sound (m/s) in air, at 20°C
const float MicrosecondsPerMillimetre = 1000.0 / SpeedOfSound; // microseconds per millimetre
const float MicrosecondsToMillimetres = (1.0 / MicrosecondsPerMillimetre); //distance by time elapsed
#include "Origo.h"
#include "Brain.h"
int Brain::addModule(AbstractBrain * module)
{
DEBUG_PRINT("Brain: Adding module ");
DEBUG_PRINT(module->getName());
DEBUG_PRINT("\n");
#define RST_PIN 8 //Reset pin
#define CHPD_PIN 9 //CHPD pin
#define GPIO_PIN 10 //Flashmode pin
void setup() {
//Open serial
Serial.begin(115200);
Serial1.begin(115200);
//Set pin modes on arduino