Skip to content

Instantly share code, notes, and snippets.

View alanrsoares's full-sized avatar

Alan Soares alanrsoares

View GitHub Profile
@alanrsoares
alanrsoares / ArithmetichEvaluator.markdown
Last active August 29, 2015 14:00
A Pen by Alan R. Soares.
@alanrsoares
alanrsoares / QuestionsCrawler.js
Last active August 29, 2015 14:05
Simple crawler that fetches questions from the aa.co.nz quiz and stores it locally in a json database
#!/usr/bin/env node
(function() {
'use strict';
var _ = require('lodash');
var Questions = (function() {
var low = require('lowdb');
var db = low('db.json');
<!DOCTYPE html>
<html>
<head>
<script src="http://static.jsbin.com/js/vendor/traceur.js"></script>
<meta charset="utf-8"
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div id="test-out"></div>
<script id="jsbin-javascript">
/*
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var ofType, fib, assertEqual;
@alanrsoares
alanrsoares / cache.js
Last active February 14, 2016 23:06
An overly-simplified cache library for node v4+
'use strict';
const lowdb = require('lowdb');
const storage = require('lowdb/file-sync');
const db = lowdb(`${ __dirname }/db.json`, { storage });
const COLLECTION_ID = 'cache';
const ONE_HOUR = 3600;
const isValidCacheKey = (key, ttl) =>
@alanrsoares
alanrsoares / Vagrantfile
Last active March 7, 2016 21:37
UXE Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Config Github Settings
github_username = "fideloper"
github_repo = "Vaprobash"
github_branch = "1.4.2"
github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}"
# Because this:https://developer.github.com/changes/2014-12-08-removing-authorizations-token/
@alanrsoares
alanrsoares / polish-notation-parser.js
Last active November 15, 2016 00:07
A Tiny Polish Notation (Lisp-like) Arithmetic Parser Built in ES6 - live demo => http://jsbin.com/tuqoqaw/11/edit?js,console
/*
A Tiny Lisp Arithmetic Parser
----------------------------------
Built with <3 by @alanrsoares
*/
// functional helpers
const apply = f => (...xs) => xs.reverse().reduceRight(f)
const compose = (...fs) => (...args) =>
(([g, ...gs]) =>
@alanrsoares
alanrsoares / lazyRange.js
Last active April 15, 2016 05:34
Lazy range implementation with Symbol.iterator - live demo => http://jsbin.com/jeguzo/edit?js,console
// Practical Application of a Symbol.iterator
// to build a Lazy Sequence
const asc = xs => xs.sort((a, b) => a - b)
class Range {
constructor(to, from = 0, step = 1) {
this.step = step
if (typeof to === 'undefined' || to === null) {