Skip to content

Instantly share code, notes, and snippets.

@pathtolearn
pathtolearn / CountingCodePoints
Created May 18, 2018 13:58
Counting Code Points
function codePointLength(text) {
let result = text.match(/[\s\S]/gu);
return result ? result.length : 0;
}
console.log(codePointLength("abc")); // 3
console.log(codePointLength("𠮷bc")); // 3
@pathtolearn
pathtolearn / Nodejs Load balancing
Last active May 4, 2018 11:47
NodeJS Load Balancing with nginx
https://docs.nginx.com/nginx/deployment-guides/node-js-load-balancing-nginx-plus/
https://mazira.com/blog/introduction-load-balancing-nodejs-2
@pathtolearn
pathtolearn / README.md
Created April 29, 2018 13:27 — forked from alienlebarge/README.md
Setting proxy with node.js

Node.js behind a proxy

Write proxy settings

$ npm config set proxy http://localhost:3128
$ npm config set https-proxy http://localhost:3128

This config is great for SquidMan app.

@pathtolearn
pathtolearn / usersandgroups
Created April 27, 2018 04:23
Working With Users and User Groups Linux
https://www.linode.com/docs/tools-reference/linux-users-and-groups/
@pathtolearn
pathtolearn / Started With Ionic
Last active April 26, 2018 04:25
Getting Started with Ionic
--> First Install Ionic and Cordova
npm i ionic cordova -g // this will install ionic cli and cordova (to convert to android and ios)
--> To Start
ionic start "proj name" type
cd proj folder
--> To Start
ionic serve
@pathtolearn
pathtolearn / Timezone
Created April 25, 2018 14:22
Set Timezone Ubbutnu
https://www.linuxhelp.com/how-to-check-and-set-timezone-in-ubuntu/
dpkg-reconfigure tzdata
A window opens --> select region --> select area
@pathtolearn
pathtolearn / Express JS Error Handling
Created April 25, 2018 05:22
Express JS Error Handling
http://expressjs.com/en/guide/error-handling.html
@pathtolearn
pathtolearn / PDF Report Phnatomjs
Created April 24, 2018 04:56
Create PDF Reports WithPhantomjs
var page = require('webpage').create(),
system = require('system'),
address, output, size;
address = system.args[1];
output = system.args[2];
page.viewportSize = { width: 2000 height: 600 };
if (system.args.length === 3 && system.args[1].substr(-4) === ".pdf") {
size = system.args[2].split('*');
@pathtolearn
pathtolearn / Only Numbers
Created April 23, 2018 18:06
Allow Only Numbers Angular
import { Directive, ElementRef, HostListener, Input } from '@angular/core';
@Directive({
selector: '[OnlyNumber]'
})
export class OnlyNumber {
constructor(private el: ElementRef) { }
@Input() OnlyNumber: boolean;
/**
* Mark and Sweep Garbage Collection technique.
* MIT Style License
* by Dmitry Soshnikov
*/
// This diff describes the simplest version of mark and sweep
// GC in order to understand the basic idea. In real practice the
// implementation can be much tricker and optimized.