Skip to content

Instantly share code, notes, and snippets.

View aronanda's full-sized avatar

aronanda

View GitHub Profile
def visit_twitter_and_log_in
visit 'https://cards-dev.twitter.com/validator'📁
find('input.js-username-field').set(ENV['TWITTER_USERNAME'])
find('input.js-password-field').set(ENV['TWITTER_PASSWORD'])
click_on('Log in')
end
def enter_url_and_click_preview(url)
find('input.FormControl').set(url)
click_on('Preview card')
result = has_content?('Page fetched successfully')
@aronanda
aronanda / fine-state-machine.js
Last active April 16, 2020 05:18
Fine State Machine
const EventEmitter = require('events').EventEmitter
class PrivateStateMachine {
constructor(sm, opts = {}) {
this.state = opts.state
Object.defineProperty(this, 'sm', { value: sm })
Object.defineProperty(this, 'stateKey', { value: opts.stateKey || 'state' })
this._setData(opts.data)
this._setStates(opts)
Object.defineProperty(this.sm, this.stateKey, { value: this.state, enumerable: true, configurable: true })
@aronanda
aronanda / server.js
Last active December 2, 2018 04:23
Node.js Server
const http = require('http'),
url = require('url'),
fs = require('fs'),
path = require('path'),
port = process.env.PORT || 3000,
docroot = process.argv[2] || process.env.DOCROOT || '.',
log = console.log.bind(console)
http.createServer(function (req, res) {
log(`${ req.method } ${ req.url }`)
@aronanda
aronanda / logger.js
Last active July 29, 2018 19:13
JS Logger
const DEBUG = true
// const DEBUG = process.env.NODE_ENV !== 'production'
const LOG_DATE = true
const LOG_LOCALE = "en-US"
const LOG_DATE_OPTS = { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' }
const log = function (level, ...args) {
if (DEBUG) {
let prefix = ''
if (typeof level === 'string' && [ 'log', 'warn', 'error' ].includes(level)) {
@robertvunabandi
robertvunabandi / Calculator.js
Last active September 2, 2022 16:56
Simple calculator implementation using Finite State Machines.
"use strict";
class Calc {
constructor() {
this._setToBaseState();
}
_setToBaseState() {
// find static methods at end of Calc class
this.__FIRST = "0";
@rcludwick
rcludwick / nginx-docker-compose.yml
Last active July 14, 2018 03:14
Rob's nginx seafile docker compose.yml
version: "2"
networks:
default:
proxy:
services:
nginx:
restart: always
image: nginx:alpine
anonymous
anonymous / Ark.sol
Created January 11, 2018 10:36
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=false&gist=
pragma solidity ^0.4.19;
contract RequestForTruth {
address admin;
function RequestForTruth() public {
admin = msg.sender;
}
}
@raisiqueira
raisiqueira / fileUpload.vue
Created December 22, 2017 13:06
Simple file upload with Vue and Axios
<style>
input[type="file"]{
position: absolute;
top: -500px;
}
div.file-listing{
width: 200px;
}
@chriseth
chriseth / snarktest.solidity
Last active December 3, 2023 07:03
zkSNARKs test code
// This file is MIT Licensed.
//
// Copyright 2017 Christian Reitwiessner
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF O
@ChrisCates
ChrisCates / MerkleTree.js
Created September 15, 2017 01:46
Basic Merkle Tree Implementation in Node.js
const crypto = require('crypto');
class MerkleTree {
constructor(value, depth, width) {
this.depth = depth;
this.width = width;
let nodes = depth * width;
let valueLength = Math.ceil(value.length / nodes);
let valueArray = this.generateArray(value, valueLength);