Skip to content

Instantly share code, notes, and snippets.

View macabeus's full-sized avatar
:octocat:
⁽⁽٩(๑˃̶͈̀ ᗨ ˂̶͈́)۶⁾⁾

Bruno Macabeus macabeus

:octocat:
⁽⁽٩(๑˃̶͈̀ ᗨ ˂̶͈́)۶⁾⁾
View GitHub Profile
@robotlolita
robotlolita / purr.md
Last active May 10, 2017 20:39
Why Purr is awful

You appear to be advocating a new:

  • functional
  • imperative
  • object-oriented
  • procedural
  • stack-based
  • "multi-paradigm"
  • lazy
  • eager
  • statically-typed
-- `Cont r a` é o tipo de uma computação que produz um `a` e, quando completa,
-- irá produzir um `r`. Você pode ver como uma linha de produção com uma parte
-- "faltando" - essa parte é a função `a -> r` que o `Cont` precisa para estar
-- "completo".
newtype Cont r a = Cont { runCont :: (a -> r) -> r }
-- pode não ser imediatamente óbvio por que uma função do tipo `(a -> r) -> r`
-- precisa, em geral, produzir um `a` internamente - por parametricidade, só existem
-- duas formas de uma função polimórfica do tipo `(a -> r) -> r` existir:
@sibelius
sibelius / useCaretPosition.tsx
Created January 25, 2021 20:59
listen to caret position of an input
const useCaretPosition = () => {
const [caret, setCaret] = useState({
selectionStart: 0,
selectionEnd: 0,
});
const onEvent = useCallback((e) => {
const input = e.target;
setCaret({
iex> So.Exclude.exclude1
Name ips average deviation median
substract 9.18 M 0.109 μs ±358.78% 0.100 μs
mapset_difference 4.00 M 0.25 μs ±17781.86% 0.0 μs
enum_filter 3.70 M 0.27 μs ±1712.25% 0.20 μs
ordsets 2.63 M 0.38 μs ±1348.35% 0.30 μs
Comparison:
substract 9.18 M
mapset_difference 4.00 M - 2.30x slower
@hjJunior
hjJunior / jwt-payload-parse.dart
Created January 15, 2019 18:00
Get payload of JWT token in Dart language
import 'dart:convert';
Map<String, dynamic> parseJwt(String token) {
final parts = token.split('.');
if (parts.length != 3) {
throw Exception('invalid token');
}
final payload = _decodeBase64(parts[1]);
final payloadMap = json.decode(payload);

Instantiation in O(n)

Most of the time instantiation is actually O(n log n), this mostly don't matter as types are always small. But for big types by having an additional memory cell on every type, an array / vector can be created.

Invariants

Doesn't matter how forall is encoded, instantiation needs to copy all sections of a type that may include an occurence of the free variable being instantiated.

Maybe an additional branching can be used to prevent allocation.

@slashdotdash
slashdotdash / elixir-tips.md
Last active September 19, 2022 23:02
Elixir tips
@dahngeek
dahngeek / gist:9edfd50fcc06a45d7b3cb818b4403406
Created October 13, 2016 21:17
How to map an ip + port to a local domain using hosts file and netsh
I managed to achieve this by using Windows included Networking tool netsh.
As Mat points out : The hosts file is for host name resolution only, so a combination of the two did the trick for me.
Example
Overview
example.app:80
| <--Link by Hosts File
@robotlolita
robotlolita / oop.md
Last active May 24, 2023 21:23
O que é OOP? Por que Java não deve ser considerado uma linguagem com um bom suporte para esse paradigma?

Objeto é a noção de uma entidade que é definida inteiramente pelo seu comportamento. E esse comportamento é dinâmicamente selecionado. Em outras palavras, eu "peço" um objeto para "andar," e como ele vai fazer isso é inteiramente definido pelo objeto.

O exemplo:

objeto.anda()

Captura bem essa idéia. Eu tenho uma mensagem "anda," mas eu não consigo dizer o que essa função faz direto do meu código, porque isso depende no comportamento dinâmico da execução do programa (em uma linguagem estáticamente tipada você consegue optimizar isso, mas o raciocínio do código continua o mesmo).

@lhorie
lhorie / longest-keyword-sequence.md
Last active November 13, 2024 04:15
What's the longest keyword sequence in Javascript?