Skip to content

Instantly share code, notes, and snippets.

import sys
import glob
import serial
def serial_ports():
""" Lists serial port names
:raises EnvironmentError:
On unsupported or unknown platforms
@fvilante
fvilante / DictToNamedTuple
Created September 11, 2018 15:52
Python - Convert NamedTuple to Dict to NamedTuple
# tested on python 3.6
from typing import NamedTuple
class T(NamedTuple):
a: int
b: str
if __name__=='__main__':
# define a named tuple object
@fvilante
fvilante / lcd_hitachi.html
Last active December 3, 2019 20:33
LCD Hitach em HTML
<!--
PASSOS P/ RODAR ESTE CODIGO:
1. Abra o link: https://www.w3schools.com/js/tryit.asp?filename=tryjs_while
2. Copie e cole este codigo na pagina que vc abriu
3. Clique no botao "RUN" (cor verde)
4. Ajuste o tamanho da janela para melhor visualizacao do display
@fvilante
fvilante / example.js
Created January 4, 2019 23:34
Application Instantiation
// an organized way to initialize your application
// extract from this article: https://medium.freecodecamp.org/why-you-should-use-functional-composition-for-your-full-applications-eb7b702ffd4a
import config from './config';
import Database from './Database';
import Models from './Models';
import Server from './Server';
function startApplication() {
const env = config();
@fvilante
fvilante / filterArraysRamda.md
Created January 8, 2019 10:41 — forked from cezarneaga/filterArraysRamda.md
Filter array of objects by nested values using ramda: Sometimes you dont have access to backend and you want to filter the response from an endpoint based on certain criteria. While trivial on flat arrays, this gets a bit tricky if the property you want to query is deeply nested. This is where Ramda shines.

Say we have a prop.users of the shape:

const users = [
    {username: 'bob', age: 30, tags: [{name: 'work', id: 1}, {name: 'boring', id: 2}]},
    {username: 'jim', age: 25, tags: [{name: 'home', id: 3}, {name: 'fun', id: 4}]},
    {username: 'jane', age: 30, tags: [{name: 'vacation', id: 5}, {name: 'fun', id: 4}]}
];
namespace Maybe_ {
type n = Extract
type Undefined = typeof Undefined
const Undefined = Symbol.for("None") // undefined
@fvilante
fvilante / maptree.ts
Last active March 27, 2019 21:01
TS Algorithms
interface Node_<T> {
readonly value: T
readonly childreen: ReadonlyArray<Node_<T>> | undefined
}
const state: Node_<string> = {
value: "foo",
childreen: [
{
@fvilante
fvilante / patternMatch.ts
Last active September 17, 2019 20:17
Pattern Match
namespace Maybe_ {
type Undefined = typeof Undefined
const Undefined = Symbol.for("None") // undefined
interface Just<T> {
readonly type: "Just",
readonly val: T | Undefined
}
@fvilante
fvilante / TypeParameterNamingConventionsStudy.ts
Last active March 5, 2019 06:11
Comparisson of alternative type parameter naming in Typescript
// A study on alternative forms to name Typescript Type parameters
// original thread: https://twitter.com/sompylasar/status/1102446254292983808
// *********************************
// T,U,V convention
// *********************************
namespace mapStream_ {
export interface EventGenerator {
onEvent: (h: EventHandler) => void
}
type Food = string
export type Event = Food