Skip to content

Instantly share code, notes, and snippets.

Reis mreis1

  • Marcio Reis
Block or report user

Report or block mreis1

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
@mreis1
mreis1 / index.js
Created Sep 2, 2019
node-graceful-sample
View index.js
// _ __ _ _ _
// _ __ ___ __| | ___ __ _ _ __ __ _ ___ ___ / _|_ _| | | |_ ___ ___| |_
// | '_ \ / _ \ / _` |/ _ \_____ / _` | '__/ _` |/ __/ _ \ |_| | | | |_____| __/ _ \ __| __|
// | | | | (_) | (_| | __/_____| (_| | | | (_| | (__ __/ _| |_| | |_____| |_ __\__ \ |_
// |_| |_|\___/ \__,_|\___| \__, |_| \__,_|\___\___|_| \__,_|_| \__\___|___/\__|
// |___/ *
// This examples shows that noce-graceful can be used across the project with no issues
// We can attach multiple listeners, the app will quit once all listeners are resolved.
// We can do this by calling done() ---> registerWithSetTimeout
// or we can do this by returning a promise ---> registerWithPromise
View Sort Array of objects by property
Sort Array of objects by property
var homes = [
{
"h_id": "3",
"city": "Dallas",
"state": "TX",
"zip": "75201",
"price": "162500"
}, {
View memory-cache.ts
/**
Usage:
Stores something in memory and also in local storage.
By default data expires after 30 minutes but you can provide your own expiration interval
or null to set it as Permanent lifetime.
*/
const THIRTY_MIN = 30 * 60 * 1000;
View Remove all ending characters matching a given pattern on a string
var str = 'FFA0000000'; // Our starting string where we want to remove all '00'
var reg = /[0]{2,2}$/;
var match = reg.exec(str);
while(match = reg.exec(str)){
var x = str.split('');
x.splice(match.index,2);
str = x.join('');
console.log(str, match)
}
View experiment-with-decorators.ts
import {
Injectable,
Inject,
Container,
InjectionToken
} from '@decorators/di';
import {FBGenericParser} from 'htz-firebird';
const API_URL = new InjectionToken('API_URL');
const MY_FACTORY = new InjectionToken('MY_FACTORY');
@mreis1
mreis1 / Usefull regex
Created Dec 1, 2018
Usefull js regex
View Usefull regex
Replace content between two comments
var content = `
//@CR_NAME
var BAR='';
var FOO='';
//@CR_END_NAME
`;
@mreis1
mreis1 / send_string.js
Created Nov 25, 2018
Digital Ocean Console SendString
View send_string.js
/*
Open your digital ocean console.
Paste the script below.
Then do: sendString('YOUR_TEXT_TO_SEND_TO_CONSOLE');
*/
var sendString = (function(rfb, force, sendDelay) {
sendDelay = sendDelay || 25;
var _q = [];
var _qStart = function() {
var chr = _q.shift();
@mreis1
mreis1 / flash-app.js
Created Sep 26, 2018 — forked from brianmacarthur/flash-app.js
Flash messaging in Express 4: express-flash vs. custom middleware in ejs, handlebars, or jade
View flash-app.js
var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var flash = require('express-flash');
var handlebars = require('express-handlebars')
var app = express();
var sessionStore = new session.MemoryStore;
// View Engines
You can’t perform that action at this time.