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 / 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 / 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 / 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 / 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 / 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 / Deploy on github pages.md
Last active March 18, 2017 01:09
Little idea to deploy a folder on the gh-pages branch automatically.

Deploy on Github Pages from a folder

  1. Create the gh-pages branch and initialize it with nothing except a .gitkeep file.

  2. Add gh-pages/ folder in .gitignore to keep git history clean.

  3. From the master branch, clone the gh-pages branch into the gh-pages folder:

@jeandat
jeandat / Uninstall-pkg.md
Created March 22, 2017 06:53 — forked from githubutilities/Uninstall-pkg.md
Uninstall pkg manually in OS X

Mac Uninstall pkg Manually

  • using pkgutil
# list all your installed packages
pkgutil --pkgs

# show your package info
pkgutil --pkg-info 
@jeandat
jeandat / check_open_port.md
Created May 2, 2017 20:16
Check open port
$ sudo lsof -nP -i:80
# Example: vmnet-nat 1045    root  9u  IPv4 0x8380  0t0  TCP *:80 (LISTEN)