Skip to content

Instantly share code, notes, and snippets.

View NguyenTungs's full-sized avatar

Nguyen Tung NguyenTungs

View GitHub Profile
@NguyenTungs
NguyenTungs / app.js
Created June 25, 2016 08:49 — forked from DanisHack/app.js
Rendering angularjs app using ejs from node server and how to use a JS variable which is passed to ejs template for angular app.
//@server in express js file
var data = {};
data.title = "My First APP";
data.arr=[{x:1, y:1}, {x:2, y:2}, {x:3, y:4}];
res.render('/ejsFile', data);
@NguyenTungs
NguyenTungs / html5-video-streamer.js
Created April 24, 2017 07:05 — forked from lleo/html5-video-streamer.js
This is an enhancement to Gist#1993068 https://gist.github.com/paolorossi/1993068 . I found what was needed to demonstrate a functioning video stream was a HTML file with a <video> tag pointing to the streamer.
#!/usr/bin/env node
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
* Modified from https://gist.github.com/paolorossi/1993068
*/
var http = require('http')
, fs = require('fs')
, util = require('util')
@NguyenTungs
NguyenTungs / aws.sns.js
Created December 22, 2017 04:16 — forked from anshul313/aws.sns.js
AWS SNS ( Simple Push Notification ) using Node.js
var AWS = require('aws-sdk');
AWS.config.update({accessKeyId: config.AWSAccessKeyId, secretAccessKey: config.AWSSecretKey,{region: config.AWSRegion}});
var sns = AWS.SNS();
var params ={
Name:"test",
Platform:"GCM",//or APNS (Apple ) or ADM (Amazon)
Attributes:{ // required
@NguyenTungs
NguyenTungs / notify-awssns2fcm.js
Created December 22, 2017 06:57 — forked from shinoda-ak/notify-awssns2fcm.js
Notify FCM for Android via AWS SNS
// Notify Target ARN for Android device
'use strict';
const AWS = require('aws-sdk');
const sns = new AWS.SNS({
apiVersion: '2010-03-31',
region: 'MY_REGION'
});
if (process.argv.length < 3) {
console.log('Usage: node notify.js ENDPOINT_ARN');
process.exit();
@NguyenTungs
NguyenTungs / app.js
Created December 22, 2017 07:14 — forked from tatsuyaueda/app.js
Lambda to AWS SNS Linphone Push Notification
console.log('Loading function');
var aws = require('aws-sdk');
var sns = new aws.SNS({
apiVersion: '2010-03-31',
region: 'us-east-1'
});
exports.handler = function(params, context) {
db.messages.insert({"subject":"Joe owns a dog", "content":"Dogs are man's best friend", "likes": 60, "year":2015, "language":"english"})
db.messages.insert({"subject":"Dogs eat cats and dog eats pigeons too", "content":"Cats are not evil", "likes": 30, "year":2015, "language":"english"})
db.messages.insert({"subject":"Cats eat rats", "content":"Rats do not cook food", "likes": 55, "year":2014, "language":"english"})
db.messages.insert({"subject":"Rats eat Joe", "content":"Joe ate a rat", "likes": 75, "year":2014, "language":"english"})
## Creating a Text Index
@NguyenTungs
NguyenTungs / firebase_detect_data.js
Created March 15, 2018 06:49 — forked from anantn/firebase_detect_data.js
Firebase: Detecting if data exists. This snippet detects if a user ID is already taken
function go() {
var userId = prompt('Username?', 'Guest');
checkIfUserExists(userId);
}
var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users';
function userExistsCallback(userId, exists) {
if (exists) {
alert('user ' + userId + ' exists!');
@NguyenTungs
NguyenTungs / firebase_detect_data.js
Created March 15, 2018 06:49 — forked from anantn/firebase_detect_data.js
Firebase: Detecting if data exists. This snippet detects if a user ID is already taken
function go() {
var userId = prompt('Username?', 'Guest');
checkIfUserExists(userId);
}
var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users';
function userExistsCallback(userId, exists) {
if (exists) {
alert('user ' + userId + ' exists!');
const people = Array.from(document.querySelectorAll('.people p'));
const names = peopleArray.map(person => person.textContent);
// ---------------------------------------------------------------
const names = Array.from(document.querySelectorAll('.people p'), person => {
return person.textContent
});