This file contains 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
<input | |
type="checkbox" | |
checked={this.state.filters.find(f => f.column === 'exchange').operand.indexOf('binance') > -1} | |
onChange={() => this.onExchangeClick('binance')} | |
/> |
This file contains 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
onExchangeClick(operand) { | |
this.setState((state) => { | |
const exchangeColumn = state.filters.find(filter => filter.column === 'exchange'); | |
if (exchangeColumn.operand.indexOf(operand) === -1) { | |
return ({ | |
filters: [ | |
...state.filters.filter(f => f.column !== 'exchange'), // this will return other elements of filters array that has no column = exchange | |
{ ...exchangeColumn, operand: [...exchangeColumn.operand, operand] }, | |
], | |
}); |
This file contains 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
import { | |
GraphQLSchema, | |
GraphQLObjectType, | |
GraphQLString, | |
GraphQLNonNull, | |
GraphQLBoolean, | |
GraphQLList, | |
GraphQLInt | |
} from 'graphql'; | |
import { |
This file contains 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
loadItems = (pagingState) => { | |
if(!pagingState){ | |
console.log("loadItems pagingState false") | |
axios.get('/api/v1/news?pagingState', { // request for the 1st news | |
headers: { | |
Authorization: 'Bearer '+localStorage.getItem('token') | |
} | |
}).then((response) => { | |
if(response.data.rows.length !== 0){ | |
var encodeURLPagingState = encodeURIComponent(response.data.pagingState) |
This file contains 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
import React from 'react'; | |
import Footer from '../Footer'; | |
import axios from 'axios'; | |
import { withRouter } from 'react-router'; | |
import './style.css' | |
class Login extends React.Component { | |
state = { | |
email: '', |
This file contains 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
var aString = "I am a string" | |
var aNumber = 1; | |
var aType = typeof aNumber; | |
var aFunction = function () { | |
return "A value"; | |
} | |
var foo = aFunction(); | |
var aBoolean = true; | |
var aNull = null; | |
var anArray = [1,2,3]; |
This file contains 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
var app = express(); | |
const indexPath = path.join(__dirname, './public/index.html') | |
const publicPath = express.static(path.join(__dirname, './public')) | |
app.use('/public', publicPath) | |
app.use('/graphql', graphQLHTTP({graphiql: true, schema, pretty: true})); // graphql endpoint | |
app.get('/', function (_, res) { res.sendFile(indexPath) }); | |
let http = require('http'); | |
let server = http.createServer(app); | |
server.listen(4000, () => console.log("app in 4000")); |
This file contains 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
function power(base, exponent) { | |
if (exponent == 0) { | |
return 1; | |
} | |
else { | |
return base * power(base, exponent - 1); | |
} | |
} | |
console.log(power(2, 3)); |
This file contains 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
// Sample 1 | |
function wrapValue(n) { | |
var localVariable = n; | |
return function() { return localVariable; }; | |
} | |
var wrap1 = wrapValue(1); /* invoke wrapValue with argument 1(n on parameter), 1 will then be assigned to the localVariable. | |
Remember that wrapValue returns a function, so it's like you're assigning a function to wrap1 that | |
returns the localVariable value, in this case, 1. */ | |
var wrap2 = wrapValue(2); |
This file contains 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
// alert requires only one argument, the 2nd and 3rd arguments are ignored and alerts only "Hello" | |
alert("Hello", "Good Evening", "How do you do?"); | |
function power(base, exponent) { | |
if (exponent == undefined) { | |
debugger; | |
exponent = 2; | |
} | |
var result = 1; | |
for (var count = 0; count < exponent; count++) { |
NewerOlder