Skip to content

Instantly share code, notes, and snippets.

View tidjungs's full-sized avatar

Waewprach Suthirawut tidjungs

  • Jitta
View GitHub Profile
const whitelist = [process.env.FRONTEND_NAME, process.env.ADMIN_NAME];
const corsOptions = {
origin: function (origin, callback) {
if (origin === undefined || whitelist.indexOf(origin) !== -1) {
callback(null, true)
} else {
callback(new Error('Not allowed by CORS'));
if (config.secure) {
}
}
@tidjungs
tidjungs / playground.exs
Created August 19, 2017 13:52
elixir tutorial script
# anonymous function
b = "World"
a = fn(b) -> "Hello #{b}" end
IO.puts a.(b)
# shorthand anonymous function
c = &("Hello #{&1}")
d = &(&1 + &2)
IO.puts c.(b)
const path = require('path')
const webpack = require('webpack')
module.exports = {
devtool: 'eval-source-map',
context: path.resolve(__dirname, 'src'),
entry: {
app: [
'react-hot-loader/patch',
'./index'
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
#define MAX_N 100000
typedef pair<int, int> P;
int n, m;
vector<P> adj[MAX_N];
// avg graph and moving avg
// send product_id
{
// ใช้ plot graph avg
data: [
{ id: 1, time: , farm1: 2000, farm2: 1000, farm3: 4000, type: 1week | 1month | 1 year | 2 year | 5 year }
{ id: 2, time: , farm1: 3000, farm2: 5000, farm3: 4000, type: 1week | 1month | 1 year | 2 year | 5 year }
],
// ใช้ แสดง moving avg
farms: [
// avg graph and moving avg
// send product_id
{
duration: [“JAN 2016”, “FEB 2016”, “ MARCH 2016”, “April 2016”]
farms: [
{
farmName: name,
price: [10,20,30,40]
}
]
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
int n, m;
int s, d, w;
int ans = 0;
struct Node {
#include <stdio.h>
struct Node {
Node *parent;
int rank;
int val;
Node(int val, Node *parent=0, int rank=0)
: val(val), parent(parent), rank(rank) {}
};
const movieLists = [{
name: "New Releases",
videos: [{
"id": 70111470,
"title": "Die Hard",
"rating": 4.0
}, {
"id": 654356453,
"title": "Bad Boys",
"rating": 5.0
const a = [[1] , [2, 3], [4, 5]]
const concatAll = (nums) =>
nums.reduce(
(result, num) => [...result, ...num]
, [])
console.log(concatAll(a))