Skip to content

Instantly share code, notes, and snippets.

Timothee Moulin timotheemoulin

Block or report user

Report or block timotheemoulin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Microsoft.PowerShell_profile.ps1
# Powershell Custom Functions
# Timothée Moulin
#
# Change directory to the root workspace directory
Function tim-goto-workspace-tim {
cd ~/www
ls
}
Set-Alias -Name www -Value tim-goto-workspace-tim
@timotheemoulin
timotheemoulin / switch-vs-if-else.php
Created May 1, 2019
Avoid if else structure when possible
View switch-vs-if-else.php
<?php
global $i;
$i = 0;
function test() {
global $i;
var_dump(++$i);
return $i;
}
switch (test()) {
@timotheemoulin
timotheemoulin / ssh-compile
Last active Mar 28, 2019
SSH config files compilation from multiple files
View ssh-compile
# Include this snippet in your .zshrc or .bashrc file to compile multiple ssh config files into one.
# Put the file anywhere and source it from your .zshrc or .bashrc file with : source /path/to/ssh-compile
# This can be useful if you share a config file among several people like in your company and also some private hosts.
# call ssh-compile-config to get all the files matching ~/.ssh/.config* and combine them into the final ~/.ssh/config file
alias ssh-compile-config='echo -n > ~/.ssh/.config && cat ~/.ssh/config* > ~/.ssh/.config'
ssh-compile-config
# fetch all the configured hosts
h=()
@timotheemoulin
timotheemoulin / convert-db-latin-utf8.sh
Last active Nov 27, 2018
Convert all tables and columns from a given database from old ISO to UTF8.
View convert-db-latin-utf8.sh
#!/usr/bin/env bash
# Timothée Moulin
#
# Install : copy this script anywhere (you can place it in the (/usr/local/bin) directory
# and give it the execution permission : chmod +x convert-db-latin-utf8.sh
#
# You must call this script and give it the following parameters.
# 1) [required] database user
# 2) [required] database name
View php-object-reference.php
<?php
$foo = new StdClass();
$foo->bar = new StdClass();
$foo->bar->baz = 'toto';
// this contains the main object
var_dump($foo);
@timotheemoulin
timotheemoulin / convert-8859-utf8.sh
Last active Aug 13, 2018
convert files from iso-8859-1 to utf8
View convert-8859-utf8.sh
#!/usr/bin/env bash
# Timothée Moulin
#
# Install : copy this script anywhere (you can place it in the (/usr/local/bin) directory
# and give it the execution permission : chmod +x convert-8859-utf8.sh
#
# You can use this script either by calling it directly to convert a single file
# or you can give it to the "find -exec" command to convert a batch of files.
# e.g.
View wordpress_phpmailer_development.php
<?php
/*
Plugin Name: PHP Mailer Override
Version: 1.0.0
Description: Override config for development environment.
Author: Timothée Moulin
Author URI: https://timothee-moulin.me/
*/
defined( 'ABSPATH' ) OR exit;
View PHP things
<?php
var_dump(count(array())); // 0
var_dump(count(false)); // 1
var_dump(count(true)); // 1
var_dump(count(null)); // 0
var_dump(count(1)); // 1
var_dump(count(0)); // 1
var_dump(count('asdf')); // 1
var_dump(in_array(true, ['foo', 'bar', ])); // true
You can’t perform that action at this time.