Skip to content

Instantly share code, notes, and snippets.

View ktpm489's full-sized avatar
🎯
Focusing

ktpm489

🎯
Focusing
View GitHub Profile
@ktpm489
ktpm489 / iterm2-solarized.md
Created December 17, 2018 02:19 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@ktpm489
ktpm489 / IndexedDB101.js
Created December 5, 2018 09:37 — forked from cauerego/IndexedDB101.js
Very Simple IndexedDB Example
// quite untested, adapted from BigstickCarpet's gist, attempt to make it simpler to use
function openIndexedDB (fileindex) {
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
var openDB = indexedDB.open("MyDatabase", 1);
openDB.onupgradeneeded = function() {
var db = {}
@ktpm489
ktpm489 / read-files.js
Created November 17, 2018 18:08 — forked from betweenbrain/read-files.js
Node.js read multiple files, write into one
var fs = require('fs');
var Promise = require('promise');
var promises = [];
var readline = require('readline');
var readFile = function (file) {
return new Promise(function (resolve, reject) {
var lines = [];
var rl = readline.createInterface({
input: fs.createReadStream('./logs/' + file)
@ktpm489
ktpm489 / how-to-use-web3-with-react-native.md
Created November 7, 2018 09:14
How to set up web3.js (Ethereum JS API) with Create React Native App

How to set up web3.js with CRNA

This is a simple guide to get you started with using the Ethereum Javascript API (web3.js) with the Create React Native App project. This is not an in-depth guide.

TL;DR

If you are lazy and just want to get started, I have this project ready for you. It should work out-of-the-box.

Installation guide

  1. Make sure you have Node version 6 or later installed, if not, get it on the Node website
@ktpm489
ktpm489 / async-foreach.js
Created October 30, 2018 07:20 — forked from atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@ktpm489
ktpm489 / PromisAllWithFails.js
Created July 26, 2018 07:31 — forked from nhagen/PromisAllWithFails.js
Wait until all promises have completed even when some reject, with Promise.all
var a = ["sdfdf", "http://oooooolol"],
handleNetErr = function(e) { return e };
Promise.all(fetch('sdfdsf').catch(handleNetErr), fetch('http://invalidurl').catch(handleNetErr))
.then(function(sdf, invalid) {
console.log(sdf, invalid) // [Response, TypeError]
})
.catch(function(err) {
console.log(err);
})
@ktpm489
ktpm489 / install-mongodb.md
Created July 11, 2018 16:56 — forked from adamgibbons/install-mongodb.md
Install MongoDB on Mac OS X 10.9

Install MongoDB with Homebrew

brew install mongodb
mkdir -p /data/db

Set permissions for the data directory

Ensure that user account running mongod has correct permissions for the directory:

Giới thiệu thần chú Đại Bi và nghi thức ngắn gọn để tụng trì
*****************************
Theo kinh Thiên Thủ Thiên Nhãn Quán Thế Âm Bồ Tát Quảng Đại Viên Mãn Vô Ngại Đại Bi Tâm Đà La Ni, do ngài Già Phạm Đạt Ma dịch (thời Đường), toàn bài chú này có 84 câu, người trì tụng thần chú Đại Bi sẽ được 15 điều lành, không bị 15 thứ hoạnh tử bức hại.
Được 15 điều lành: 1. Sinh ra thường được gặp vua hiền, 2. Thường sinh vào nước an ổn, 3. Thường gặp vận may, 4. Thường gặp được bạn tốt, 5. Sáu căn đầy đủ, 6. Tâm đạo thuần thục, 7. Không phạm giới cấm, 8. Bà con hòa thuận thương yêu, 9. Của cải thức ăn thường được sung túc, 10. Thường được người khác cung kính, giúp đỡ, 11. Có của báu không bị cướp đoạt, 12. Cầu gì đều được toại ý, 13. Long, Thiên, thiện thần thường theo hộ vệ, 14. Được gặp Phật nghe pháp, 15. Nghe Chánh pháp ngộ được nghĩa thâm sâu.
Không bị 15 thứ hoạnh tử: 1. Chết vì đói khát khốn khổ, 2. Chết vì bị gông cùm, giam cầm đánh đập, 3. Chết vì oan gia báo thù, 4. Chết vì chiến trận, 5. Chết vì bị ác
@ktpm489
ktpm489 / aws-sns-example.js
Created July 8, 2018 05:36 — forked from tmarshall/aws-sns-example.js
aws-sdk sns example, in Node.js
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: '{AWS_KEY}',
secretAccessKey: '{AWS_SECRET}',
region: '{SNS_REGION}'
});
var sns = new AWS.SNS();