Skip to content

Instantly share code, notes, and snippets.

View foliveira's full-sized avatar
👨‍💻
I may be slow to respond.

Fábio Oliveira foliveira

👨‍💻
I may be slow to respond.
View GitHub Profile
@foliveira
foliveira / fix-manjaro-keys.sh
Created July 16, 2023 11:36
Cannot update Manjaro Linux: Unknown trust with Archlinux-keyring
#!/bin/bash
pacman-mirrors
pacman -Syy
pacman -S archlinux-keyring manjaro-keyring
pacman-key --init
pacman-key --populate archlinux manjaro
pacman-key --refresh-keys
pacman -Syu
@foliveira
foliveira / yubi-colemak.sh
Created July 26, 2017 18:38
yubikey-colemak
#!/bin/sh
ykpersonalize -S 06050a0e08170b0f1c11180d16090c1986858a8e88978b8f9c91988d96898c99271e1f202122232425262b9e28
@foliveira
foliveira / 0-introduction.md
Last active March 1, 2017 13:39
Cardinality Estimation

Why?

Counting unique elements of a finite set usually requires linear time/space; this means the bigger the set of unique elements the more time/space it will take us to keep an exact count of unique elements.

A good example of this is the usage of an HashSet - we add an element to a Set (to ensure uniqueness), it gets hashed and stored:

  • In case it's the first one, it is added and that's it;

  • In case it isn't (in case of an hash collision, duplicate value, etc) various things can happen; most common implementations use [Linear Probing][1]

@foliveira
foliveira / count-watchers.js
Last active April 5, 2018 12:50
Tricks for Angular performance
(function () {
var root = angular.element(document.getElementsByTagName('body'));
var countWatchers_ = function(element, scopes, count) {
var scope;
scope = element.data().$scope;
if (scope && !(scope.$id in scopes)) {
scopes[scope.$id] = true;
if (scope.$$watchers) {
@foliveira
foliveira / max.ex
Last active August 29, 2015 14:14
Fun with Elixir
defmodule Fun do
def max([x]), do: x
def max([ head | tail ]), do: Kernel.max(head, max(tail))
end
@foliveira
foliveira / foliveira-yld-entry.json
Last active August 29, 2015 14:09
My bio for the yld.io team page
{
"path": "fabio+oliveira",
"firstName": "Fábio",
"lastName": "Oliveira",
"role": "Node.js",
"longRole": "Node.js Consultant",
"location": "Lisbon, Portugal",
"organization": "YLD Limited",
"bio": "Fábio is a professional Node.js developer, with a huge appetite for learning. Always curious and eager to learn more, he considers himself a full-stack developer and has worked on projects ranging from augmented reality frameworks to realtime analytics products. In his list of interests one can find diverse subjects such has photography, Star Wars, cats and reading 'out-of-the-ordinary' literature.",
"twitter": "fanoliveira",

Keybase proof

I hereby claim:

  • I am foliveira on github.
  • I am foliveira (https://keybase.io/foliveira) on keybase.
  • I have a public key whose fingerprint is F11E 0B4B D7C8 643E 0611 0AC5 D1C6 57CB 6E5B 48DD

To claim this, I am signing this object:

@foliveira
foliveira / process.js
Created January 3, 2014 16:12
Price calculation based on a Index-Tree in Javascript (of Phone Numbers)
function Process(num, h) {
var first_num = num.charAt(0)
var following_nums = num.slice(1)
var first_num_hash_hit = h[first_num]
var following_nums_lookahead = following_nums.charAt(0)
if(!first_num_hash_hit.hasOwnProperty(following_nums_lookahead))
return null
if(following_nums.length === 0)
@foliveira
foliveira / LazyQsort.cs
Created June 28, 2011 16:22 — forked from duarten/LazyQsort.clj
A lazy quick sort
public static IEnumerable<T> LazyQsort<T>(IEnumerable<T> seq, Func<T, T, bool> comp)
{
if (seq.Any() == false)
{
return Enumerable.Empty<T>();
}
var pivot = seq.First();
var xs = seq.Skip(1);
return LazyQsort(xs.Where(x => comp (x, pivot)), comp)