Skip to content

Instantly share code, notes, and snippets.

@depeele
depeele / gist:66656a73bf53773ae852f6613ae05876
Created May 22, 2016 00:18
HackerRank Javascript stdin using an ES6 generator and larger buffer
'use strict';
function* Lines( stream ) {
const EOL = require('os').EOL;
const Fs = require('fs');
const buf = new Buffer(1024);
while (Fs.readSync(stream.fd, buf, 0, buf.length)) {
let lines = buf.toString().split( EOL );
if (lines.length < 1) { break; }
@depeele
depeele / hackerrank.js
Created May 22, 2016 00:06
HackerRank Javascript stdin using an ES6 generator
'use strict';
function* Lines( stream ) {
const EOL = require('os').EOL;
const Fs = require('fs');
const buf = new Buffer(1);
while( true ) {
const chars = [];
while (Fs.readSync(stream.fd, buf, 0, buf.length)) {
@depeele
depeele / designer.html
Created August 23, 2014 14:56
designer
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../core-animated-pages/core-animated-pages.html">
<link rel="import" href="../core-animated-pages/transitions/hero-transition.html">
<link rel="import" href="../core-pages/core-pages.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@depeele
depeele / test-when.js
Last active December 14, 2015 15:28
A small example of progress chaining using node.js and https://github.com/cujojs/when
var When = require('when');
/*******************************************************
* Define a class with asynchronous methods
*
*/
function Test() { return this.init(); }
Test.prototype = {
init: function() {
var self = this;