Skip to content

Instantly share code, notes, and snippets.

View WendySanarwanto's full-sized avatar
💭
Active

Wendy Sanarwanto WendySanarwanto

💭
Active
View GitHub Profile
@WendySanarwanto
WendySanarwanto / Receiving call from Shoutpoint
Last active December 19, 2016 01:07
Receiving Call from Shoutpoint API
Receiving Phone Call:
---------------------
By using Postman:
1. Get available Phone numbers:
Invoke: GET https://{{BASE_URL}}/PhoneNumbers/Available?is_sms=true&search_by=region&search_on=CA
Headers: X-Api-Key => ykFccAt1QpnJApkagGsLv4VkV8jbTODS
Number we pick: <Pick a number>
2. Provision selected phone number - if we have done it in prior step, skip this step:
@WendySanarwanto
WendySanarwanto / docker-machine-guide.txt
Last active July 26, 2017 23:32
Steps for creating , stopping , starting a Dockermachine & deploying containers into the docker machine where is hosted on AWS EC2
Create DockerMachine & deploy containers on it:
-----------------------------------------------
1. Run these command to create docker machine on AWS EC2:
docker-machine create --engine-install-url=https://web.archive.org/web/20170623081500/https://get.docker.com \
--driver amazonec2 \
--amazonec2-access-key AKI************* \
--amazonec2-secret-key 7j****************************** \
--amazonec2-instance-type t2.nano \
--amazonec2-region ap-southeast-1 <docker-machine-name>
@WendySanarwanto
WendySanarwanto / kms_encrypt_decrypt.ts
Created August 2, 2017 01:56
Encrypt Decrypt String using AWS KMS
import * as aws from "aws-sdk";
const kms = new aws.KMS({ region: "us-east-1" });
async function doStuff() {
// Encrypt
const encrypted = await kms.encrypt({
KeyId: "alias/test-key",
Plaintext: "abcd",
@WendySanarwanto
WendySanarwanto / router_nat.sh
Last active August 12, 2017 12:06
NAT-ing Wired Local Area Network's Computers to Linux(Ubuntu) Router that is connected to WAN (Internet), so that the Router can share the internet access to Computers connected to the Wired LAN
#!/bin/bash
# Given, `enp6s0` is the Router's LAN interface connected to Wired LAN.
# And `enxfcde56ff0106` is the Router's interface connected to WAN or internet devices (e.g. Phone in Tethering mode, Wireless/USB dongle modem)
# Reference: http://www.nairabytes.net/81-linux/418-how-to-set-up-a-nat-router-on-ubuntu-server-16-04
# Enable NAT on interface enxfcde56ff0106, use enxfcde56ff0106 for outgoing packets
iptables -t nat -A POSTROUTING -o enxfcde56ff0106 -j MASQUERADE
# Forward IP-packets from enxfcde56ff0106 to enp6s0 where there is an established initial request;
@WendySanarwanto
WendySanarwanto / demo-ses-send-email.js
Created August 14, 2017 09:50
A code sample of sending email from AWS SES.
'use strict';
const aws = require('aws-sdk');
exports.handler = (event, context, callback) => {
const homeRegion = "us-east-1";
const accessKeyId = "YOURACCESSKEYID";
const secretAccessKey = "YOURSECRETACCESKEY";
// load AWS SES
const ses_config = {
@WendySanarwanto
WendySanarwanto / cpuinfo.sh
Created November 12, 2017 11:41
Bash script for displaying CPU's current temperature & speed of all of its cores, on Banana Pi M3
#!/bin/bash
# Instructions:
# -------------
# 1. Save this script into an `.sh` file (e.g. cpuinfo.sh).
# 2. Make the `.sh` file to be executable by running `chmod` command. Example: chmod 755 cpuinfo.sh
# 3. Optionally, you could create a symbolic link to the `.sh` file. Example: ln -s cpuinfo.sh cpuinfo
# 4. An example of running the script on CLI terminal: `./cpuinfo.sh` or `./cpuinfo` if you created a symbolic link in prior step.
# 5. You can use `watch` command, in case you want to show the output of the script & refreshed periodically for each 2 seconds, 5 seconds, etc.
# Example: `watch -n 2 ./cpuinfo.sh` or `watch -n 2 ./cpuinfo`
@WendySanarwanto
WendySanarwanto / gist:745753963a04ce5b26b313f612f2c666
Last active May 26, 2018 03:26
Common useful Linux Terminal Commands
# uname –a => Display linux system information
# uname –r => Display kernel release information (refer uname command in detail)
# cat /etc/redhat_release => Show which version of redhat installed
# uptime => Show how long system running + load (learn uptime command)
# hostname => Show system host name
# hostname -i => Display the IP address of the host (all options hostname)
# last reboot => Show system reboot history (more examples last command)
# date => Show the current date and time (options of date command)
# cal => Show this month calendar (what more in cal)
# w => Display who is online (learn more about w command)
@WendySanarwanto
WendySanarwanto / redux_intro.js
Last active May 4, 2018 20:45
Understanding Redux
import Redux from 'redux';
// declare a function which takes state & action args (the reducer)
const reducer = (state = [], action) => {
// Act based on specific action.type
if (action.type === 'split_string') {
return action.payload.split(' ');
}
else if (action.type === 'add_char') {
return [...state, '!'];
@WendySanarwanto
WendySanarwanto / create_user_accounts_table.sql
Created May 25, 2018 06:08
Creating a new table with autoincrement column on Oracle database
CREATE TABLE USER_ACCOUNTS (
ID NUMBER(10) NOT NULL,
EMAIL VARCHAR(30) NOT NULL,
PASSWORD VARCHAR(100) NOT NULL
);
ALTER TABLE USER_ACCOUNTS ADD (
CONSTRAINT user_acc_pk PRIMARY KEY (ID)
);
@WendySanarwanto
WendySanarwanto / 1_App.jsx
Last active May 26, 2018 12:27
Steps of integrating redux, react-redux into React Native component
// App.js is the root component of the RN app.
import React, { Component } from 'react';
import { View, } from 'react-native';
// Your custom components
import { Header } from './components/common';
import LibraryList from './components/LibraryList';
// 1. Import redux's createStore function & react-redux's Provider component
import { createStore } from 'redux';