Skip to content

Instantly share code, notes, and snippets.

View gpbaculio's full-sized avatar

Glendon Philipp Baculio gpbaculio

  • Zone 3, Poblacion El Salvador City, Misamis Oriental
View GitHub Profile
<input
type="checkbox"
checked={this.state.filters.find(f => f.column === 'exchange').operand.indexOf('binance') > -1}
onChange={() => this.onExchangeClick('binance')}
/>
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] },
],
});
import {
GraphQLSchema,
GraphQLObjectType,
GraphQLString,
GraphQLNonNull,
GraphQLBoolean,
GraphQLList,
GraphQLInt
} from 'graphql';
import {
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)
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: '',
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];
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"));
function power(base, exponent) {
if (exponent == 0) {
return 1;
}
else {
return base * power(base, exponent - 1);
}
}
console.log(power(2, 3));
// 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);
// 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++) {