Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Chamuth Chamandana Thilakarathne Chamuth

🏠
Working from home
View GitHub Profile
View bucket.js
const functions = require('firebase-functions');
const express = require("express");
const path = require('path');
const bodyParser = require('body-parser');
const admin = require("firebase-admin");
var serviceAccount = require("./serviceAccountKey.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
View gist:57cd842c49bd055d96b16e9d31b2c19b
const admin = require("firebase-admin");
var serviceAccount = require("./serviceAccountKey.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://vlearn-lanka.firebaseio.com",
storageBucket: "vlearn-lanka.appspot.com"
});
@Chamuth
Chamuth / lkphones.ts
Created Nov 21, 2018
Validate Sri Lankan phones numbers and get their carrier
View lkphones.ts
export module LKPhoneValidator
{
export function Validate(phone : string) : PhoneValidation
{
// remove starting +94
phone = phone.replace("+94", "0");
// Consider number length
if ((phone.startsWith('0') && phone.length == 10) || (!phone.startsWith('0') && phone.length == 9) && /^\d+$/.test(phone))
{
View log
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\SPT\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install' ]
2 info using npm@6.4.1
3 info using node@v8.10.0
4 verbose npm-session 2003944f504d7f47
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall traveller@1.0.0
7 info lifecycle traveller@1.0.0~preinstall: traveller@1.0.0
@Chamuth
Chamuth / 0_reuse_code.js
Created Jul 6, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Chamuth
Chamuth / drupal-views-share-global-text-field
Created Jun 10, 2017 — forked from chrisjlee/drupal-views-share-global-text-field
share url's for facebook, twitter, pinterest with just get variables
View drupal-views-share-global-text-field
<ul>
<li class="share-text">Share this>/li>
<li class="share-tw"><a href="http://twitter.com/share?text=[title]"><span></span></a></li>
<li class="share-fb"><a href="http://www.facebook.com/sharer.php?u=/node/[nid]&p=[title]"><span></span></a></li>
<li class="share-pinterest"><a href="http://pinterest.com/pin/create/button/?url=/node/[nid]&description=[title]"><span></span></a></li>
</ul>
You can’t perform that action at this time.