Skip to content

Instantly share code, notes, and snippets.

View eduardonunesp's full-sized avatar

Eduardo Pereira eduardonunesp

View GitHub Profile
@eduardonunesp
eduardonunesp / nginx.conf
Created September 21, 2015 23:27
nginx domain and subdomain reverse proxy
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
@eduardonunesp
eduardonunesp / chat.go
Last active September 22, 2015 15:58 — forked from gmarik/chat.go
package main
import (
"bufio"
"net"
)
type Client struct {
incoming chan string
outgoing chan string
(function() {
'use strict';
new Vue({
el: '#beerApp',
data: {
botecos : [],
openDetails : []
},
@eduardonunesp
eduardonunesp / split_channels.html
Last active October 13, 2015 23:28
Split 7.1 Channels (tested in Safari 9)
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<script>
function checkForEC3Support() {
var video = document.createElement('video');
return (video.canPlayType('audio/mp4;codecs="ec-3"') !== '');
}
Function.prototype.partial = function() {
// CODE HERE
var fn = this, args = Array.prototype.slice.call(arguments);
return function() {
var replace = function(arr) {
var pos = 0;
return {
next : function() {
return arr[pos++];
'use strict';
import Hapi from 'hapi';
import Promise from 'bluebird';
const server = new Hapi.Server();
server.register([
require('hapi-async-handler')
], function(error) {
@eduardonunesp
eduardonunesp / esnextbin.md
Last active April 6, 2016 12:38
esnextbin sketch

Node.js exam

Quick practical exam for node.js candidates.

Requirements

  • load tags.txt to get an array of tags
  • for each of these tags, find out how many times that tag appears within the objects in data/*.json (note: objects can be nested).
const moment = require('moment');
function dayDiff(d1, d2) {
return Math.abs(moment(d2).diff(d1, 'days'));
}
const dateLen = {
'day' : 1,
'week' : 7,
'month': 31,
/*
Given an array of integers, calculate which fraction of its elements are positive, which fraction of its elements are negative, and which fraction of its elements are zeroes, respectively. Print the decimal value of each fraction on a new line.
Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with absolute error of up to 10−410−4 are acceptable.
Input Format
The first line contains an integer, NN, denoting the size of the array.
The second line contains NN space-separated integers describing an array of numbers (a0,a1,a2,…,an−1)(a0,a1,a2,…,an−1).