Skip to content

Instantly share code, notes, and snippets.

View jeandat's full-sized avatar
😁
Coding

Jean DAT jeandat

😁
Coding
View GitHub Profile
@jeandat
jeandat / git_branch_in_prompt.sh
Last active October 16, 2015 12:29
Show the current git branch in prompt (bash) to avoid checking the branch every time or worse use the wrong branch.
# Add current git branch in prompt
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOUR="\[\033[0m\]"
PS1="$GREEN\u@$(hostname)$NO_COLOUR:\w$YELLOW\$(parse_git_branch)$NO_COLOUR\$ "
@jeandat
jeandat / enable_mysql_log_in_table_general_log.sql
Last active October 16, 2015 12:24
It is possible to activate mysql log in order to see all executed queries. Several options : table or file.
-- For those blessed with MySQL >= 5.1.12:
-- If you prefer to output to a table:
SET GLOBAL log_output = 'TABLE';
SET GLOBAL general_log = 'ON';
-- Take a look at the table mysql.general_log
-- If you prefer to output to a file:
@jeandat
jeandat / count_lines_number.md
Last active October 16, 2015 12:21
Count lines number in a project

Count lines number in files

By combining the power of git and bash, we can have in an instant an estimation of lines number in a project.

For instance to count lines number in versionned perl files:

$ git ls-files | egrep ".*(driver|core).*pl$" | xargs wc -l
  • git ls-files will only return files versionned which is a first interesting filter.
@jeandat
jeandat / gitconfig.md
Last active April 7, 2019 11:17
Global git configuration

Git Configuration

I put this configuration on every machine I work on in ~/.gitconfig.

It set the global scope ; equivalent to git config --global <key> <value>.

[user]
	name = jeandat
	email = jean.dat@gmail.com
@jeandat
jeandat / edit_plist_file.md
Created September 23, 2016 08:11
A nice way to edit an iOS plist file from the shell

A nice way to edit an iOS plist file from the shell

Source

#!/bin/bash

if [[ ! -f /usr/libexec/PlistBuddy ]]; then
    exit 0
fi
@jeandat
jeandat / ionic2-env-conf.md
Last active January 8, 2017 18:07
Allow using different configuration files in order to instrument the build

ExtendedDefinePlugin will replace ENV variables by their configuration value. Uglify will remove dead code.

1. Copy and modify webpack.config.js

// EDIT by Jean DAT
// Custom code in order to load different configuration files based on context (targeted environment).
// In a configuration file, I store things like the API url to use, etc.
var ExtendedDefinePlugin = require('extended-define-webpack-plugin');
@jeandat
jeandat / pre_post_hook_prompt.md
Created January 16, 2017 14:23
Pre & Post hook for bash prompt (terminal)

PRE / POST Hook for Bash Prompt

Explained here.

AT_PROMPT=1 
# This will run before any command is executed.
function PreCommand() {
  if [ -z "$AT_PROMPT" ]; then
 return
@jeandat
jeandat / my-prompt.md
Last active January 16, 2017 14:41
My Customized Bash Prompt
# Get current git branch
function parse_git_branch () {
       git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
BLACK="\[\033[0;30m\]"
RED="\[\033[0;31m\]"
GREEN="\[\033[0;32m\]"
YELLOW="\[\033[0;33m\]"
BLUE="\[\033[0;34m\]"

Comment avoir deux instances autonomes de Firefox utilisant chacun un profil différent

Créer un nouveau profil MyProfile depuis le gestionnaire de profil :

open -a Firefox --args -ProfileManager

Lancer firefox en utilisant ce profil :

@jeandat
jeandat / angular-cli+yarn.md
Last active October 25, 2020 12:26
Create a new angular project with @angular/cli and yarn

Tell ng to use yarn all the times:

$ ng set --global packageManager=yarn

Create a new angular4 project:

$ ng new myapp --ng4 --routing --style=scss