Skip to content

Instantly share code, notes, and snippets.

View lnmunhoz's full-sized avatar

Lucas N. Munhoz lnmunhoz

View GitHub Profile
@lnmunhoz
lnmunhoz / .block
Created February 21, 2019 05:56
1. Centered Circle
license: mit
@lnmunhoz
lnmunhoz / fizzbuzz.md
Last active July 2, 2017 01:23
Coding Dojo - 29/10/2016

#Fizz Buzz

  • weslley39
  • lnmunhoz

##Elixir

defmodule FizzBuzz do
  def run(n) when (rem(n, 3) == 0) and (rem(n, 5) == 0) do
    IO.puts("FizzBuzz")
@lnmunhoz
lnmunhoz / README.md
Last active November 25, 2020 09:23
Atom: Enable fix files on save with linter-eslint

Atom: Enable fix files on save with linter-eslint

Atom linter-eslint has a very handy command to fix the file with specified linting rules.

You can lint your file with by calling Command + P and typing Fix.

This saves time but you still need to type Fix over and over again to fix your file. Its more time saving if you could lint your file on saving, right? You can!

There's two ways you can config this behaviour. Follow the method that most please you:

@lnmunhoz
lnmunhoz / fromNow.js
Created September 2, 2016 13:35
Moment fromNow methods. Minimalist implementation.
/**
* Lucas Nogueira Munhoz
* Start: 08:40AM - End: 10:03AM
*/
// units.js
const units = { second: 1000 };
units.minute = 60 * units.second;
units.hour = 60 * units.minute;
units.day = 24 * units.hour;
@lnmunhoz
lnmunhoz / meteor-async.md
Created March 10, 2016 22:50 — forked from joscha/meteor-async.md
Meteor Async Guide

From Meteor's documentation:

In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.

This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.

Basic async

Sometimes we need to run async code in Meteor.methods. For this we create a Future to block until the async code has finished.

@lnmunhoz
lnmunhoz / navbar.sass
Created August 20, 2015 19:07
boostrap3: navbar collapsed by default for all screen sizes.
@media (max-width: 2000px)
.navbar-header
float: none
.navbar-left, .navbar-right
float: none !important
.navbar-toggle
display: block
.navbar-collapse
border-top: 1px solid transparent
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1)
@lnmunhoz
lnmunhoz / bytesToString.cs
Created June 30, 2015 14:00
Convert Hash of Bytes to String
public string ByteArrayToString(byte[] ba)
{
StringBuilder hex = new StringBuilder(ba.Length * 2);
foreach (byte b in ba) hex.AppendFormat("{0:x2}", b);
return hex.ToString();
}
@lnmunhoz
lnmunhoz / saveFileStream.cs
Created March 24, 2015 19:42
Save FileStream into Disk
// file is our stream
var fileStream = File.Create(@"..\"+ file.FileName, (int) file.Length);
var bytesInStream = new byte[file.Length];
file.Read(bytesInStream, 0, bytesInStream.Length);
fileStream.Write(bytesInStream, 0, bytesInStream.Length);
@lnmunhoz
lnmunhoz / index.html
Created February 11, 2015 17:14
RealTime chart with ChartJS, Socket.io and KnockoutJS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="lnmunhoz">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/2.1.0/knockout-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.1/Chart.js"></script>
@lnmunhoz
lnmunhoz / server.js
Created December 16, 2014 20:04
server.js
'use strict';
var express = require('express');
var app = express();
var server = require('http').Server(app);
var bodyParser = require('body-parser');
var port = process.env.PORT || 3000;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));