This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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: [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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] | |
| } | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <vector> | |
| #include <queue> | |
| using namespace std; | |
| int n, m; | |
| int s, d, w; | |
| int ans = 0; | |
| struct Node { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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) {} | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const movieLists = [{ | |
| name: "New Releases", | |
| videos: [{ | |
| "id": 70111470, | |
| "title": "Die Hard", | |
| "rating": 4.0 | |
| }, { | |
| "id": 654356453, | |
| "title": "Bad Boys", | |
| "rating": 5.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const a = [[1] , [2, 3], [4, 5]] | |
| const concatAll = (nums) => | |
| nums.reduce( | |
| (result, num) => [...result, ...num] | |
| , []) | |
| console.log(concatAll(a)) |
NewerOlder