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
@komkanit
komkanit / test.js
Last active December 8, 2017 11:41
allIp[i] = {}
allIp[i].usable = usableip()
allIp[i].ip2v4 = ip2v4()
this.state.allPossible.map((possible) => (
<tr>
<td>{possible.usable}</td>
<td>{possible.ip2v4}</td>
import ApolloClient from 'apollo-client';
import { ApolloLink } from 'apollo-link';
import { HttpLink } from 'apollo-link-http';
import { RetryLink } from 'apollo-link-retry';
import { InMemoryCache } from 'apollo-cache-inmemory';
const httpLink = new HttpLink({
uri: 'http://localhost:8080/graphql',
headers,
credentials: 'include',
import ApolloClient from 'apollo-client';
import { getOperationAST } from 'graphql';
import { ApolloLink } from 'apollo-link';
import { HttpLink } from 'apollo-link-http';
import { WebSocketLink } from 'apollo-link-ws';
import { InMemoryCache } from 'apollo-cache-inmemory';
const httpLink = new HttpLink({
uri: 'http://localhost:8080/graphql',
});
onDropdownChange = (e) => {
this.setState({
time: e.target.value, // ตาม option value
});
}
<select
onChange={this.onDropdownChange}
value={this.state.time}
>
var data = [
{
"firstname": "สมยศ",
"address": "3",
"district": "โชคเหนือ",
"amphoe": "ลำดวน",
"province": "สุรินทร์"
},
{
"firstname": "บุญหนา",
[2017-07-17 20:39:43] develop.ERROR: exception 'ErrorException' with message 'Array to string conversion' in /Users/komcal/Documents/work/mitphon/mitrphol-api/vendor/laravel/framework/src/Illuminate/Database/Grammar.php:39
Stack trace:
#0 /Users/komcal/Documents/work/mitphon/mitrphol-api/vendor/laravel/framework/src/Illuminate/Database/Grammar.php(39): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Array to string...', '/Users/komcal/D...', 39, Array)
#1 /Users/komcal/Documents/work/mitphon/mitrphol-api/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php(135): Illuminate\Database\Grammar->wrapTable(Array)
#2 /Users/komcal/Documents/work/mitphon/mitrphol-api/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php(77): Illuminate\Database\Query\Grammars\Grammar->compileFrom(Object(Illuminate\Database\Query\Builder), Array)
#3 /Users/komcal/Documents/work/mitphon/mitrphol-api/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php
@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() }),
)
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);
const Component = props => (
<div>
Count: {props.count}
<button onClick={props.increase}>Increment</button>
<button onClick={props.decrease}>Decrement</button>
</div>
);