Skip to content

Instantly share code, notes, and snippets.

View komkanit's full-sized avatar
🍔
code for food

komkanit komkanit

🍔
code for food
View GitHub Profile
$data = json_decode($result['payment_custom_field']);
print_r($data);
echo '***';
if(isset($data['3'])){
echo $data['3'];
$a = $data['3'];
}
@komkanit
komkanit / pure.js
Last active January 28, 2017 11:28
const add = (x, y) => x + y
console.log(add(2,3)) // 5
@komkanit
komkanit / HOF.js
Last active January 28, 2017 12:20
const add = (x, y) => x + y
const minus = (x, y) => x - y
const logSomeThing = (func) => (...args) => {
console.log(func(...args))
}
const logAdd = logSomeThing(add)
const logMinus = logSomeThing(minus)
logAdd(20, 5) // 25
@komkanit
komkanit / HOC.js
Last active January 29, 2017 03:13
const CalculateWrapper = (WrappedComponent, operation) => (props) => (
<div>
<div>{props.x + operation + props.y}</div>
<WrappedComponent {...props} />
</div>
)
const Increment = (props) => ( <h1>{props.x + props.y}</h1> )
const Decrease = (props) => ( <h1>{props.x - props.y}</h1> )
#include<iostream>
#include<stdio.h>
using namespace std;
typedef struct _NODE {
int val;
struct _NODE *left;
struct _NODE *right;
int weight;
SELECT CustNo, CustFirstName, CustLastName, CustCity
fROM Customer
WHERE CustBal > 150 and CustNo in
(SELECT CustNo FROM OrderTbl WHERE OrderTbl.OrdDate between '2550/02/1' and '2550/02/28')
SELECT CustNo, CustFirstName, CustLastName
fROM Customer
WHERE EXISTS
(SELECT * FROM OrderTbl WHERE Customer.CustNo = OrderTbl.CustNo and Customer.CustState = 'CO' and OrderTbl.OrdDate < '2550/02/1' or OrderTbl.OrdDate > '2550/02/28' GROUP BY OrderTbl.CustNo)
#include<stdio.h>
#include<vector>
using namespace std;
int main() {
int n;
vector<int> a[100000];
int num[100000];
int size = 0;
const Component = props => (
<div>
Count: {props.count}
<button onClick={props.increase}>Increment</button>
<button onClick={props.decrease}>Decrement</button>
</div>
);
import { compose, withState, withHandlers } from recompose
const enhance = compose(
withState('count', 'setCounter', 0),
withHandlers({
increase: ({ setCounter }) => () => setCounter(n => n + 1),
decrease: ({ setCounter }) => () => setCounter(n => n - 1),
})
)
export default enhance(Component);
@komkanit
komkanit / refs.js
Last active January 21, 2018 17:31
import { compose, withProps } from recompose
class RefsStore {
store(name, value) {
this[name] = value;
}
}
const enhance = compose(
withProps({ refs: new RefsStore() }),
)