Skip to content

Instantly share code, notes, and snippets.

View jgwill's full-sized avatar

Guillaume Descoteaux-Isabelle jgwill

View GitHub Profile
@jgwill
jgwill / js.regex.1812090515.js
Last active December 9, 2018 23:40
@stcaction How to extract email in string using regular expression
//@stcaction How to extract email in string using regular expression
var re = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/g;
var text = "my email is my@mydomain.com";
function extractEmails(text) {
return text.match(re);
@jgwill
jgwill / vscode.publish-extension.181209.sh
Created December 9, 2018 10:47
@q How to publish a vscode package extension using command line?
#@q How to publish a vscode package extension using command line?
#Install the tool
sudo npm install -g vsce
# Publishing
vsce publish
@jgwill
jgwill / bs.abbreviation.1812090556.html
Created December 9, 2018 10:57
Abbreviation using Boostrap
<body>
<p> Abbreviation: <abbr title="An Advancing company">Google</abbr></p>
</body>
@jgwill
jgwill / angular.json
Created December 9, 2018 11:52
Observation of an Angular Project Structure
{
"rulesDirectory": [
"codelyzer"
],
"rules": {
"arrow-return-shorthand": true,
"callable-types": true,
"class-name": true,
"comment-format": [
true,
@jgwill
jgwill / what.is.rail.nodejs.framework.1812090720.sh
Created December 9, 2018 12:21
@q What is Rails On Node: Opinionated Node.js Framework?
#@q What is Rails On Node: Opinionated Node.js Framework?
# Features
# Create a new multithread Node.js server with Pug templating with 8 threads (Ruby on Rails has 5 for their server's scalibity)
# Setup your own database (any SQL database or MongoDB)
# Generate new api controllers
# Generate new api versions
# Creates automatic API documentation for endpoints on creation with no extra configuration
# Creates automatic unit tests for endpoints on creation with no extra configuration
# Generate new pages with assets with a custom route with code splitting
# Use serverside React or Vanilla JS (JQuery, etc.)
@jgwill
jgwill / README.md
Created December 9, 2018 13:09
gixdeco NPM Package Readme

gixdeco

@stcgoal Extract decorator from string

Install

#!/bin/bash
npm i gixdeco --save

Usage

@jgwill
jgwill / a-extract-url-nodejs-sample-1812111058.js
Created December 11, 2018 15:58
How do I extract url in content using nodejs?
const text = 'Lorem ipsum dolor sit amet, //sindresorhus.com consectetuer adipiscing http://yeoman.io elit.';
getUrls(text);
//=> Set {'http://sindresorhus.com', 'http://yeoman.io'}
@jgwill
jgwill / ZNotWorkingIn-Pythonista.py
Last active December 11, 2018 22:12 — forked from sirleech/gist:2660189
Python Read JSON from HTTP Request of URL
# Load Json into a Python object
import urllib2
import json
req = urllib2.Request("http://localhost:81/sensors/temperature.json")
opener = urllib2.build_opener()
f = opener.open(req)
json = json.loads(f.read())
print json
print json['unit']
@jgwill
jgwill / js.jquery.register-a-click-handler.181211.js
Created December 12, 2018 01:25
Register a Click Handler using jQuery
$("#wrap_chat_messages").click(function () {
alert("Handler for .click() called.");
});
@jgwill
jgwill / frameguard-allow-X-Frame-Options
Created December 12, 2018 01:30
Enable X-Frame-Options on express.js
const frameguard = require('frameguard')
// Don't allow me to be in ANY frames:
app.use(frameguard({ action: 'deny' }))
// Only let me be framed by people of the same origin:
app.use(frameguard({ action: 'sameorigin' }))
app.use(frameguard()) // defaults to sameorigin
// Allow from a specific host: