Skip to content

Instantly share code, notes, and snippets.

View json2d's full-sized avatar
🙂
try your baz!

Jason Yung json2d

🙂
try your baz!
View GitHub Profile
#!/usr/bin/env node
const solveWith = require('./lib/solve-with')
var stall = (input) => {
var [N,K] = input.split(' ')
var lastChains = [];
var curChains = [N];
var ppl = K;
while(true) {
#!/usr/bin/env node
const solveWith = require('./lib/solve-with')
const bigInt = require('jsbn').BigInteger
var stall = (input) => {
var [N,K] = input.split(' ')
// N = new bigInt(N)
K = new bigInt(K)
(0/0+"").repeat("7")+ " BatMan!"
// "NaNNaNNaNNaNNaNNaNNaN BatMan!"
var path = require('path');
var webpack = require('webpack');
var BUILD_DIR = path.resolve(__dirname, 'src/client/public');
var APP_DIR = path.resolve(__dirname, 'src/client/app');
config = {
entry: APP_DIR + '/index.jsx',
output: {
path: BUILD_DIR,
@json2d
json2d / react-datepicker-redux-form.js
Last active May 26, 2017 13:04
'react-datepicker' integration with 'redux-form@5.2.3'
import React, { Component } from 'react'
import moment from 'moment';
import 'react-datepicker/dist/react-datepicker.css';
export class DateInput extends Component{
constructor (props) {
super(props);
if(this.props.field.value) {
this.state = { selectedDate: moment(this.props.field.value) }
@json2d
json2d / mta-bustime-promise.js
Created June 20, 2017 21:04
mta-bustime-promise.js
const API_PATH = "http://bustime.mta.info/api"
const request = require('request')
function BusTime(key) {
this.key = key;
this.where = service('where')
this.siri = service('siri')
}
export const alphaAndLengthSort = (a,b) => {
if(a[0] == b[0]) { // if first character is equal (this is important)
return a.length - b.length // compare by length, if equal then
|| a.localeCompare(b) // compare by dictionary order
}else{
return a.localeCompare(b)
}
}
@json2d
json2d / match-number-regex
Created July 5, 2017 21:20
match-number-regex
/\b([0-9]+\.[0-9]*\b|([0-9]*\.[0-9]+)\b)/
//normally to pipe a -> b -> c:
a.pipe(b).pipe(c)
//could also compose pipings, this below is the same as above, (or is it?):
a.pipe(b.pipe(c))
//makes more sense when using a variable to define a composed piping instance
const bc = b.pipe(c)
a.pipe(bc)
d.pipe(bc)
@json2d
json2d / deptree-json-sync.js
Created August 4, 2017 16:10
Walk through dependency tree of installed packages via `npm ls`
const spawn = require('cross-spawn');
const path = require('path')
const ls = spawn.sync('npm', ['ls','--json']);
const tree = JSON.parse(ls.stdout)
const walkDepTree = (tree,cb) => {
const deps = tree.dependencies
if(deps) {