Skip to content

Instantly share code, notes, and snippets.

View chowryan's full-sized avatar

Ryan Chow chowryan

  • San Francisco, CA
View GitHub Profile
@chowryan
chowryan / infura_ws_test.js
Created February 16, 2019 00:45
infura_ws_test.js
const WebSocketClient = require('websocket').client;
const client = new WebSocketClient({tlsOptions: {rejectUnauthorized: false}});
let currentBlockFilter = ''
let lastMessageReceived = new Date().getTime()
let lastPing = new Date().getTime()
let lastBlockTime = new Date().getTime()
let totalBlockTime = 0
@chowryan
chowryan / sample.js
Last active November 12, 2018 09:33
react setstate?
// Method 1:
class Parent extends Component {
state = { foo: '', bar: '', buzz: '' }
render() {
return (
<Child
setParentState={this.setState}
>
)
const prompt = require('prompt');
class TicTacToe {
constructor() {
this.winner = null;
this.board = [
[' ', ' ', ' '],
[' ', ' ', ' '],
[' ', ' ', ' '],
const vowelDoubler = array => {
const vowels = ['a', 'e', 'i', 'o', 'u'];
let resultLength = array.length;
for (let i = 0; i < array.length; i += 1) {
if (vowels.includes(array[i])) {
resultLength += 1;
}
}
let offset = resultLength - array.length;
for (let i = resultLength - 1; i >= 0; i -= 1) {