Skip to content

Instantly share code, notes, and snippets.

View thundernet8's full-sized avatar
🎯
Focusing

✨ Touchumind thundernet8

🎯
Focusing
View GitHub Profile
@thundernet8
thundernet8 / tsx-snippet.json
Created September 5, 2017 07:18
create a new tsx file
{
// Place your snippets for TypeScript React here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"New TSX FILE": {
"prefix": "itsx",
"body": [
"import * as React from \"react\";",
@thundernet8
thundernet8 / glog.sh
Last active August 22, 2017 06:50
glog alias with emoji support
brew install emojify
alias glog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --color | emojify | less -r"
let data = "Charge Time,Customer Name,Customer Ref,Amount,Bank Ref,Customer Notes,Topup Number,Status,Operator,Comfirm Type";
records.forEach(record => {
data += `\n${getDate(
record.transTime * 1000
)},${record.customerName},${record.customerRef},${(record.amount / 100).toFixed(
2
)},${record.bankRef},${record.extral.replace(
",",
""
)},${record.topupNumber},${record.confirmStatus},${record.operator},${record.confirmType}`;
@thundernet8
thundernet8 / gist:c64e979b15e26e84552199d11c4711a1
Created July 28, 2017 16:41 — forked from RichFromGalvanize/gist:5873044
An image piping example using Node.js, express, and request...BOOYA!
var request = require('request');
var express = require('express');
var app = express();
app.get('/goofy', function(req, res) {
request('http://images1.wikia.nocookie.net/__cb20120715102950/disney/images/a/a5/Disneygoofy2012.jpeg').pipe(res);
});
app.get('/loop', function(req, res) {
res.render('mypage');
node --max-old-space-size=1024 my-node-script.js #increase to 1gb
node --max-old-space-size=2048 my-node-script.js #increase to 2gb
node --max-old-space-size=3072 my-node-script.js #increase to 3gb
node --max-old-space-size=4096 my-node-script.js #increase to 4gb
node --max-old-space-size=5120 my-node-script.js #increase to 5gb
node --max-old-space-size=6144 my-node-script.js #increase to 6gb
node --max-old-space-size=7168 my-node-script.js #increase to 7gb
node --max-old-space-size=8192 my-node-script.js #increase to 8gb
/**
* Object.omit
*
* Returns a (shallow) copy of an object, with specified keys omitted.
*
* @param object sourceObject
* @param string omitKeys, ...
*
* @return object
*/
@thundernet8
thundernet8 / getTopDomain.ts
Created July 14, 2017 09:50
get top domain of url
export function getTopDomain(url: string = "") {
url = url || window.location.hostname;
url = url.replace(/(https?:\/\/)?(www.)?/i, "");
let urlArr = url.split(".");
url = urlArr.slice(urlArr.length - 2).join(".");
if (url.indexOf("/") !== -1) {
@thundernet8
thundernet8 / lint
Created July 7, 2017 07:00
git pre-commit lint
#!/bin/sh
files=$(git diff --cached --name-only --diff-filter=ACM | grep -v "genServices/" | grep -v "genAdminServices/")
tsFiles=$(echo "$files" | grep -E "\.tsx?$")
jsFiles=$(echo "$files" | grep -E "\.jsx?$")
if [ "$tsFiles" = "" -a "$jsFiles" = "" ]; then
exit 0
fi
@thundernet8
thundernet8 / settings.json
Created July 7, 2017 06:59
Vscode settings for current project
{
"typescript.tsdk": "./node_modules/typescript/lib",
"path-intellisense.mappings": {
"genServices": "${workspaceRoot}/genServices",
"~genServices": "${workspaceRoot}/genServices"
},
"eslint.enable": true,
"prettier.useTabs": true,
"files.exclude": {
"node_modules": true,
class ExtensibleError extends Error {
constructor (message: string) {
super()
// Set this.message
Object.defineProperty(this, 'message', {
configurable: true,
enumerable: false,
value: message !== undefined ? String(message) : ''
})