Skip to content

Instantly share code, notes, and snippets.

View Pakinwet's full-sized avatar

Pakinwet Saksamerprom Pakinwet

  • Bangkok, Thailand
View GitHub Profile
@Pakinwet
Pakinwet / CountryCodes.json
Created September 14, 2022 04:23 — forked from anubhavshrimal/CountryCodes.json
Country and Dial or Phone codes in JSON format
[
{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"
@Pakinwet
Pakinwet / Commit Formatting.md
Created March 22, 2022 18:19 — forked from clemtibs/Commit Formatting.md
Angular Commit Format Reference Sheet

Commit Message Guidelines

We have very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history. But also, we use the git commit messages to generate the Angular change log.

Commit Message Format

Each commit message consists of a header, a body and a footer. The header has a special format that includes a type, a scope and a subject:

React guidelines to support content theming in Open edX (Braden's proposal)

  1. Build the UI out of small, modular React components as much as possible.
  2. Build two types of components: "customizable" ones that only compose others using JSX and contain little-or-no HTML nor logic, as well as "internal" components that contain logic and detailed HTML and CSS, etc.
  3. In customizable components, include placeholders like {this.extraContent} in the render() method so that subclasses don't have to override render().

Bad example:

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@Pakinwet
Pakinwet / otpverify.js
Created May 26, 2020 08:37 — forked from theanam/otpverify.js
OTP verification without database, full sample source code
const otpGenerator = require("otp-generator");
const crypto = require("crypto");
const key = "verysecretkey"; // Key for cryptograpy. Keep it secret
function createNewOTP(phone){
// Generate a 6 digit numeric OTP
const otp = otpGenerator.generate(6, {alphabets: false, upperCase: false, specialChars: false});
const ttl = 5 * 60 * 1000; //5 Minutes in miliseconds
const expires = Date.now() + ttl; //timestamp to 5 minutes in the future
const data = `${phone}.${otp}.${expires}`; // phone.otp.expiry_timestamp
@Pakinwet
Pakinwet / gist:9bc1d5417b3e6b1fb448eede38055b93
Created October 29, 2019 17:14 — forked from rmatil/gist:8d21620c11039a442964
Connect MySQL database in Vagrant VM from Host machine

Connecting to Vagrant VM MySQL database from host

This gist shows how to connect to your vagrant MySQL database from the host machine.

Change Address Binding from MySQL

  • Connect to vagrant using vagrant ssh
  • Edit file /etc/mysql/my.cnf:
    • Change parameter bind-address to 0.0.0.0 to allow all incoming connection attempts
@Pakinwet
Pakinwet / countries.json
Created January 23, 2019 19:06 — forked from keeguon/countries.json
A list of countries in JSON
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
//Install plugin
cordova plugin add PLUGIN_NAME // or localtion/PLUGIN_NAME
//Compile and Build plugin cordova
cordova build android // for android
cordova build iod // for ios
cordova build // All platform
//Run for test app cordova
cordova run android // for android
@Pakinwet
Pakinwet / range_data_2_fields.json
Created August 29, 2016 02:36
same case sql query (salary_min BETWEEN 20000 AND 60000 ) OR (salary_max BETWEEN 20000 AND 60000 )
{
"from": 0,
"size": 50,
"query": {
"bool": {
"should": [
{
"range": {
"pos_salary_min": {
"gte": 20000,