Skip to content

Instantly share code, notes, and snippets.

JGWill jgwill

Block or report user

Report or block jgwill

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 docker-bash-aliases.sh
# 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 Oct 25, 2018
VSCode keeps removing the space you wrote, change to this config
View vscode-white-space-config.json
{
"editor.trimAutoWhitespace": false
}
@jgwill
jgwill / format-content-urls-as-html.php
Last active Oct 29, 2018
PHP parsing content to format URL to become clickable in HTML
View format-content-urls-as-html.php
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 Nov 3, 2018
@stcgoal Auto Restart a NodeJS Server When development files are changed, it restart the server.
View nodejs.nodemon.auto-restart-server.config.md

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 Nov 6, 2018
node.js - Watch a folder and execute an action when that happen
View node.js.x.watch-folder.js
//@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 Nov 6, 2018 — forked from aharshac/Fetch URL title - Node.js
Node.js snippet to fetch URL title
View Fetch URL title - Node.js
/*@@@@
@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 Nov 7, 2018
NodeJS parse argument using minimist package for Console App
View nodejs-cli-1811071711.js
// 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 Nov 7, 2018
MySQL Escape HTML char from a SQL view so right out of SQL the Text is Safe for browser
View mysql-safe-HTML-escaped-view.sql
--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`,
View x.get-clipboard.js
//@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 Nov 14, 2018
@stcgoal Combine 2 string to make a Path compatible with windows and linux
View make-path.js
var p = require('path');
var tpath = 'tmp';
tpath = p.join(tpath, 'mysubdir');
You can’t perform that action at this time.