Skip to content

Instantly share code, notes, and snippets.

Jean Lescure jeanlescure

Block or report user

Report or block jeanlescure

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
@jeanlescure
jeanlescure / hot-reload-http-server-one-liner.sh
Created May 26, 2019
Quickly Setup Hot Reload Environment in OSX
View hot-reload-http-server-one-liner.sh
npx browser-sync start -s -f . --no-notify --host `ifconfig | grep "inet " | grep -v 127.0.0.1 | cut -d\ -f2` --port 8080
@jeanlescure
jeanlescure / rename-object-keys.md
Last active Feb 5, 2019
Javascript optimized function to rename keys of objects in an array
View rename-object-keys.md
function renameObjectKeys(objArr, renameMap) {
  const keys = Object.keys(renameMap);

  for (let i = objArr.length - 1; i >= 0; i -= 1) {
    for (let j = keys.length - 1; j >= 0; j -= 1) {
      delete Object.assign(
        objArr[i],
        {[renameMap[keys[j]]]: objArr[i][keys[j]] }
      )[keys[j]];
View ubuntu-init.sh
apt-get update
apt-get install -y software-properties-common
add-apt-repository -y ppa:certbot/certbot
apt-get update
apt-get install -y gpp python zip unzip mariadb-server nginx python-certbot-nginx
systemctl status mariadb
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
source ~/.bashrc
nvm install 10.13
npm install -g yarn
View useful-daily-dev.md

Delete all node_modules folders recursively

find . -name "node_modules" -type d -prune -exec rm -rf '{}' +

The -prune option skips child node_modules directories so that only top level node_modules are removed, for better performance.

Share MacOS X directory over NFS

View useful-git-things.md

Change wrong user name and email in all commits

Source: https://stackoverflow.com/a/4982271/2731075

git filter-branch --env-filter 'if [ "$GIT_AUTHOR_EMAIL" = "incorrect@email" ]; then
     GIT_AUTHOR_EMAIL=correct@email;
     GIT_AUTHOR_NAME="Correct Name";
     GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL;
     GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; fi' -- --all
View coming-soon.html
<link href="https://fonts.googleapis.com/css?family=Erica+One" rel="stylesheet">
<style>
body {
background: white;
font-family: 'Erica One', cursive;
}
</style>
<div style="text-align:center;font-size:30px;">
<h1 style="font-weight:normal;">COMING SOON</h1>
</div>
View postgres-mac-misc.sh
# Misc operations I use in OSX for PostgreSQL management
# Install brew and postgres
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install postgresql
postgres -V
# If password lost just change 'md5' to 'trust' for all users in following file
sudo vim /Library/PostgreSQL/10.x/data/pg_hba.conf
View init.sh
freebsd-update fetch install
pkg install -y nginx
rm /usr/local/etc/nginx/nginx.conf
wget https://gist.githubusercontent.com/jeanlescure/010660a00ea17907873cc4838f047efe/raw/22abe2f2dc670d47f5ba66518f0069e0464702dd/vcloud-nginx.conf -O /usr/local/etc/nginx/nginx.conf --no-check-certificate
mkdir -p /var/log/nginx
touch /var/log/nginx/access.log
touch /var/log/nginx/error.log
mkdir -p /usr/local/etc/nginx/sites-enabled/
mkdir -p /usr/local/etc/nginx/sites-available/
nginx -t
View p5.centered.rect.js
var rects = [];
var SQPI = (PI/64);
var xq = 0.01;
function r(x,y,w,h){
var self = this;
this.x = x;
this.y = y;
this.w = w;
this.h = h;
View postgres-init.md
$ sudo apt-get install -y postgresql-9.4 postgresql-contrib-9.4 libpq-dev
$ sudo su - postgres
postgres@user:~$ createuser user
postgres@user:~$ psql
postgres=# ALTER ROLE user WITH SUPERUSER CREATEDB REPLICATION LOGIN;
postgres=# \password user
postgres=# CREATE SCHEMA user;
postgres=# \q
postgres@user:~$ exit
You can’t perform that action at this time.