Skip to content

Instantly share code, notes, and snippets.

View ktpm489's full-sized avatar
🎯
Focusing

ktpm489

🎯
Focusing
View GitHub Profile
@ktpm489
ktpm489 / debug-signing.properties
Created July 22, 2019 23:00 — forked from niraj-shah/debug-signing.properties
Debug Build Signing for Cordova
# location of keystore
storeFile=/path/to/app.keystore
# Key alias
keyAlias=alias_name
# Store password
storePassword=Password1
# Key password
import { Injectable } from '@angular/core';
import * as firebase from 'firebase';
//...omitted
@Injectable()
export class AuthService {
resetPassword(email: string) {
var auth = firebase.auth();
return auth.sendPasswordResetEmail(email)
@ktpm489
ktpm489 / typescript_cheatsheet.ts
Created July 11, 2019 13:43 — forked from petcarerx/typescript_cheatsheet.ts
Typescript Cheat Sheet - Syntax features and examples
// _____ __ _ _
///__ \_ _ _ __ ___/ _\ ___ _ __(_)_ __ | |_
// / /\/ | | | '_ \ / _ \ \ / __| '__| | '_ \| __|
// / / | |_| | |_) | __/\ \ (__| | | | |_) | |_
// \/ \__, | .__/ \___\__/\___|_| |_| .__/ \__|
// |___/|_| |_|
//Typescript Cheat Sheet: every syntax feature exemplified
//variables are the same as javascript, but can be defined with a type:
var myString:string;
@ktpm489
ktpm489 / ConvertVie.js
Created July 5, 2019 16:23 — forked from hu2di/ConvertVie.js
JavaScript: Chuyển tiếng Việt có dấu sang không dấu
function change_alias(alias) {
var str = alias;
str = str.toLowerCase();
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g,"a");
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g,"e");
str = str.replace(/ì|í|ị|ỉ|ĩ/g,"i");
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g,"o");
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g,"u");
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g,"y");
str = str.replace(/đ/g,"d");
@ktpm489
ktpm489 / remote react bootstrap table example
Created April 18, 2019 07:06 — forked from xabikos/remote react bootstrap table example
An example of a react bootstrap table that fetches the data asynchronously when navigating between pages and when changing the page size
import React, {Component} from 'react';
import {BootstrapTable, TableHeaderColumn} from 'react-bootstrap-table';
import _ from 'lodash';
const dataTable = _.range(1, 60).map(x => ({id: x, name: `Name ${x}`, surname: `Surname ${x}`}));
// Simulates the call to the server to get the data
const fakeDataFetcher = {
fetch(page, size) {
return new Promise((resolve, reject) => {
@ktpm489
ktpm489 / Login.js
Created March 8, 2019 02:20 — forked from bruce/Login.js
React + Redux + localStorage Login example
// components/Login/Login.js
class Login extends Component {
// ...
handleSubmit(evt) {
evt.preventDefault();
this.props.mutate(this.state)
.then(({ data }) => {
@ktpm489
ktpm489 / gist:02942b11091519f65c5fbca0fd9b9b31
Last active February 28, 2019 03:30
Promise with timeout
--------- demo promise + setTimeout---
async function test() {
let promises = [];
let aa = 0;
for (let i = 0; i < 3; i++) {
// promises.push(
// aa = aa + i);
promises.push( new Promise((resolve)=> {
// wait 3s
setTimeout(()=> resolve(aa++),3)
@ktpm489
ktpm489 / 1.rreaddir.js
Created February 27, 2019 15:03 — forked from timoxley/1.rreaddir.js
async/await recursive fs readdir
import { join } from 'path'
import { readdir, stat } from 'fs-promise'
async function rreaddir (dir, allFiles = []) {
const files = (await readdir(dir)).map(f => join(dir, f))
allFiles.push(...files)
await Promise.all(files.map(async f => (
(await stat(f)).isDirectory() && rreaddir(f, allFiles)
)))
return allFiles

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@ktpm489
ktpm489 / Cryptojs
Last active April 16, 2019 12:12 — forked from MAAARKIN/Cryptojs
//var salt = CryptoJS.lib.WordArray.random(256/32);
//var iv = CryptoJS.lib.WordArray.random(256/32);
//console.log('salt '+ salt );
//console.log('iv '+ iv );
var salt = CryptoJS.enc.Hex.parse("28698aadc97f3ad8");
var iv = CryptoJS.enc.Hex.parse("73ac39603da6e205");
console.log('salt '+ salt );
console.log('iv '+ iv );
var key128Bits = CryptoJS.PBKDF2("Secret Passphrase", salt, { keySize: 256/32 });