Skip to content

Instantly share code, notes, and snippets.

View jgwill's full-sized avatar

Guillaume Descoteaux-Isabelle jgwill

View GitHub Profile
@jgwill
jgwill / docker-bash-aliases.sh
Created October 24, 2018 03:38
Alias for docker
# call this from ~/.bashrc
# like source ~/projects/Dockcommander/docker-bash-aliases.sh
alias d=docker
alias dcl='docker container ps -a'
alias dps=dcl
alias dcstats='docker stats'
alias dcs='docker stats'
alias dr='docker run'
alias drm='docker rm '
@jgwill
jgwill / vscode-white-space-config.json
Last active October 25, 2018 14:38
VSCode keeps removing the space you wrote, change to this config
{
"editor.trimAutoWhitespace": false
}
@jgwill
jgwill / format-content-urls-as-html.php
Last active October 29, 2018 18:35
PHP parsing content to format URL to become clickable in HTML
foreach ($chatDatas as $chat)
{
//Expression capturing URL string
$urlXpression = '~(?:(https?)://([^\s<]+)|(www\.[^\s<]+?\.[^\s<]+))(?<![\.,:])~i';
//replacing in text URL with formatted HTML Linked Tag
$chatHTML = preg_replace($urlXpression, '<a href="$0" target="_blank" title="$0">$0</a>', $chat);
//display each chat element
echo "<tr><td>"
. $chatHTML["ChatLine"]
@jgwill
jgwill / nodejs.nodemon.auto-restart-server.config.md
Last active November 3, 2018 00:37
@stcgoal Auto Restart a NodeJS Server When development files are changed, it restart the server.

Auto Restart a NodeJS Server

When development files are changed, it restart the server.

npm start

Ref & info

  • Package:NodeMon
  • sudo npm install nodemon -g
@jgwill
jgwill / node.js.x.watch-folder.js
Last active November 6, 2018 00:43
node.js - Watch a folder and execute an action when that happen
//@a Watch a folder and do something with the changes
var watchPath = "/www/x/fs_watch_folder_1811051535/tests";
console.log("Watching test path: " + watchPath);
var fs = require("fs");
var sleep = require("sleep");
fs.watch(watchPath, (eventType, filename) => {
console.log(eventType);
// could be either 'rename' or 'change'. new file event and delete
@jgwill
jgwill / Fetch URL title - Node.js
Last active November 6, 2018 18:59 — forked from aharshac/Fetch URL title - Node.js
Node.js snippet to fetch URL title
/*@@@@
@a Fetch a uniform resource locator title using NodeJS
@d Nov 6, 2018 at 10:10 AM
@tlid 181106091002
@kw
@metatxt Automatic formatting of uniform of the service location when it is posted
@s Working
@CR
@ECR
@jgwill
jgwill / nodejs-cli-1811071711.js
Last active November 7, 2018 22:28
NodeJS parse argument using minimist package for Console App
// cliapp.js
"use strict";
const args = require("minimist")(process.argv.slice(2));
//console.log(args);
console.log(args.i);
@jgwill
jgwill / mysql-safe-HTML-escaped-view.sql
Last active November 7, 2018 22:49
MySQL Escape HTML char from a SQL view so right out of SQL the Text is Safe for browser
--Fix inserting Script into code being executed
select `af_chat`.`tbl_chat`.`Id` AS `Id`,`af_chat`.`tbl_chat`.`Tlid` AS `Tlid`,
replace(replace(replace(
`af_chat`.`tbl_chat`.`ChatLine`,'&','&amp;'),'<','&lt;'),'>','&gt;')
AS `ChatLine`,
@jgwill
jgwill / x.get-clipboard.js
Created November 10, 2018 18:09
@stcgoal Getting clipboard in NodeJS, thanks to : https://github.com/sindresorhus/clipboardy
//@stcgoal Getting clipboard in NodeJS, thanks to : https://github.com/sindresorhus/clipboardy
const clipboardy = require('clipboardy');
//clipboardy.writeSync('🦄');
var r = clipboardy.readSync();
//
@jgwill
jgwill / make-path.js
Created November 14, 2018 18:36
@stcgoal Combine 2 string to make a Path compatible with windows and linux
var p = require('path');
var tpath = 'tmp';
tpath = p.join(tpath, 'mysubdir');