Skip to content

Instantly share code, notes, and snippets.

View thomascrepain's full-sized avatar
🎯
Focusing

Thomas Crepain thomascrepain

🎯
Focusing
View GitHub Profile
@thomascrepain
thomascrepain / Global Debug Function
Created November 29, 2013 12:41
Debug function to be temporally added in global namespace to quickly have a var_dump everywhere in the application
function debug($msg, $exit=true) {
if($_SERVER['REMOTE_ADDR'] == '192.168.0.0') { // only for my ip
echo "<pre>";
var_dump($msg);
echo "</pre>";
if ($exit) {
exit;
}
}
@thomascrepain
thomascrepain / MySQL Cheat sheet
Last active December 29, 2015 17:39
MySQL Cheat sheet - much used but not remembered
# create user
CREATE USER 'myuser'@'%' IDENTIFIED BY 'password';
# grant user all rights on database
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' WITH GRANT OPTION;
# create database with UTF8 character set
create database databasename DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
# To dump a Mysql database and gzip it:
@thomascrepain
thomascrepain / Git Cheat Sheet
Last active March 9, 2023 09:25
Git Cheat sheet - much used but not remembered
# refresh remote branches
git fetch -p
# checkout remote branch
git checkout -t origin/branchname
# delete local branch
git branch -d branchname
# list remote branch
# Ignore everything in this directory
*
# Except this file
!.gitignore
@thomascrepain
thomascrepain / Command line magic Cheat Sheet
Last active January 11, 2021 19:51
Command line magic Cheat Sheet - much used but not remembered
# Search & replace over multiple files (Linux)
find . -type f -print0 | xargs -0 sed -i 's/foo/bar/g'
# Search & replace over multiple files (Mac OS X)
find . -type f -print0 | xargs -0 sed -i '' -e 's/foo/bar/g'
# remove empty files in a directory
find /tmp -size 0 -print0 |xargs -0 rm
# Run command in multiple directories
for dir in ./*; do (cd "$dir" && echo "$dir" && cowsay "boo"); done
@thomascrepain
thomascrepain / Timer.php
Last active August 29, 2015 14:10
Timer class
<?php
/**
* Class Timer
*/
class Timer
{
/**
* @var float|null
*/
protected $startTime;
@thomascrepain
thomascrepain / broken-links-test
Last active August 29, 2015 14:16
Test website for broken links
@thomascrepain
thomascrepain / geo.md
Created October 1, 2015 11:34
Latitude/Longitude

Calculate distance, bearing and more between Latitude/Longitude points http://www.movable-type.co.uk/scripts/latlong.html

-- Spherical Law of Cosines: calculate distance to other points

SET @lat = 51.053283, @lon = 3.720359;
SELECT *
FROM (
       SELECT
 *,
#!/bin/bash
# Installs the bare minimum to start a docker container on a Raspberry Pi. Make sure you start from a fresh copy of Raspbian (light)
# See: https://www.raspberrypi.org/downloads/raspbian/
#
# Run this script as sudo
# Install docker
curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh