Skip to content

Instantly share code, notes, and snippets.

View ramalho's full-sized avatar
🏠
Working from home

Luciano Ramalho ramalho

🏠
Working from home
View GitHub Profile
@ramalho
ramalho / charindex.py
Created May 8, 2020 07:20
Functions to create an inverted index to find Unicode characters by name
"""
``char_index`` builds an inverted index mapping words to sets of Unicode
characters which contain that word in their names. For example::
>>> index = char_index(32, 65)
>>> sorted(index['SIGN'])
['#', '$', '%', '+', '<', '=', '>']
>>> sorted(index['DIGIT'])
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
>>> index['DIGIT'] & index['EIGHT']
from random import shuffle
from typing import Sequence, List, Any
def sample(population: Sequence, size: int) -> List:
if size < 1:
raise ValueError('size must be >= 1')
result = list(population)
shuffle(result)
return result[:size]
@ramalho
ramalho / elide.py
Created July 24, 2019 08:36
elide: cut text at or before max_len, keeping complete words if possible
#!/usr/bin/env python3
def elide(text, max_len, ellipsis='…'):
if len(text) <= max_len:
return text
cut = max_len
while cut > 0 and text[cut - 1].isalnum():
cut -= 1
@ramalho
ramalho / parameterized_test.exs
Created May 14, 2019 01:34 — forked from damonkelley/parameterized_test.exs
Parameterized Tests in Elixir
defmodule ParamerizedTest do
use ExUnit.Case
@parameters [
{0, 0},
{1, 1},
{2, 4},
{3, 9},
]
@ramalho
ramalho / faixa_limitada.py
Created March 6, 2019 22:10
Resposta entre dois valores
resposta = -1
while resposta < 0 or resposta > 150:
try:
resposta = int(input('Digite um valor entre 0 e 150: '))
except ValueError:
continue
@ramalho
ramalho / vizinhos.sh
Created March 4, 2019 15:54
Network neighborhood
#!/bin/bash
nmap -sn 192.168.15.0/24 | grep report | cut -d " " -f 5,6
@ramalho
ramalho / net-promoter-score.ipynb
Last active May 22, 2018 17:48
Net Promoter Score® Calculation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ramalho
ramalho / sinais.py
Created May 19, 2018 13:38
Arquivos do Coding Dojo com pytest na Lendico (2018-05-18)
#!/usr/bin/env python3
import sys
def search(query, data):
query = query.replace('-',' ')
words = set(query.upper().split())
for code, char, name in data:
name = name.replace('-',' ')
if words <= set(name.split()):

Principles of Adult Behavior

  1. Be patient. No matter what.
  2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him.
  3. Never assume the motives of others are, to them, less noble than yours are to you.
  4. Expand your sense of the possible.
  5. Don’t trouble yourself with matters you truly cannot change.
  6. Expect no more of anyone than you can deliver yourself.
  7. Tolerate ambiguity.
  8. Laugh at yourself frequently.
@ramalho
ramalho / go-missing-examples.md
Created January 14, 2018 14:50 — forked from andrestc/go-missing-examples.md
Go std lib funcs/methods missing examples

About this

This list has the goal of helping developers interested in contributing to the Go language but are unsure of where to start. This was not generated manually so some functions and methods here may not require examples (maybe because they are too simple, e.g .String()) and some of these may only make sense in a package level example (which are not considered for this list yet). Use your best judgment and check the documentation before you open up a CL to add an example.

I will try to keep this list as up to date as possible. If you find any mistakes, please comment below and I will try to fix it. I plan on release the code I used to generate this in the future, so other go projects can benefit from it.