Skip to content

Instantly share code, notes, and snippets.

View francisbrito's full-sized avatar
💭
💻 🌴 🇩🇴

Francis Brito francisbrito

💭
💻 🌴 🇩🇴
View GitHub Profile

Keybase proof

I hereby claim:

  • I am francisbrito on github.
  • I am francisbrito (https://keybase.io/francisbrito) on keybase.
  • I have a public key ASBpE_OKf-1UHzPZDbgVC6KUPt5xqZL977rTcU03QLthBQo

To claim this, I am signing this object:

@francisbrito
francisbrito / main.c
Created June 22, 2018 17:19
frdm-kl25z voltimeter test
/* p7_1.c: A to D conversion of channel 0
* This program converts the analog input from channel 0 (PTE20)
* using software trigger continuously.
* Bits 10-8 are used to control the tri-color LEDs. LED code is
* copied from p2_7. Connect a potentiometer between 3.3V and
* ground. The wiper of the potentiometer is connected to PTE20.
* When the potentiometer is turned, the LEDs should change color.
*/
#include <MKL25Z4.h>
#include "fsl_debug_console.h"

Best practices

  • Always limit resource usage (memory, CPU)

    • You can determine how much resources your application consumes by doing docker stats <container>
  • Specify log driver configuration

  • Consider limit the amount and size of files generates if using JSON logger.
describe('My suite', () => {
it('works with promises', done => {
multiplyAsync(4, 5)
.then(r => expect(r).toBe(20))
.then(done);
});
it('works even if promises reject', done => {
divideAsync(2, 0)
.catch(e => expect(e.message).toBe('Attempted to divide by zero'))
.then(done);
@francisbrito
francisbrito / get-user-group-info.js
Created March 17, 2016 06:15
Gets group information (name, id, description, url, logo url) from Facebook Graph API.
const http = require('got');
const coroutine = require('co');
const querystring = require('querystring');
const ACCESS_TOKEN = '<ACCESS_TOKEN>';
const groupNamesOrIds = [
'JavaScript Dominicana',
1398701893767285, // Ruby.do
'hfsantodomingo',
@francisbrito
francisbrito / .babelrc
Last active January 26, 2016 15:52
WIP: Proof of Concept for a MongoDB data mapper.
{
"presets": ['es2015-node4']
}
/**
* 3rd party imports.
*/
var express = require('express');
var mongodb = require('mongodb');
/**
* Local imports.
*/
// foo.js
module.exports = 'foo';
// index.js
var foo = require('./foo');
console.log(foo); // foo
// bar.js
exports.qux = 'qux';
exports.nix = 'nix';
@francisbrito
francisbrito / index.js
Created January 18, 2016 14:07
Mongorito test example.
const test = require('blue-tape');
const Promise = require('bluebird');
const mongorito = require('mongorito');
/**
* A simple Mongorito Model. Nothing special.
*/
const Post = require('./models').Post;
/**
@francisbrito
francisbrito / mpj.js
Created October 20, 2015 01:35
Demonstrative snippet showing how small, focused functions can abstract implementation details
const selector = '[data-list] [data-scroll-thing]';
function onKeyPressed(event) {
if (isIgnoredKey(event)) return;
const target = event.target;
const letter = getSanitizedLetterFromKey(event.keyCode);
if (!letter) return;
let scrollContainer = getParentElementMatchingSelector(target, selector);