Skip to content

Instantly share code, notes, and snippets.

View cardotrejos's full-sized avatar

Ricardo Trejos cardotrejos

View GitHub Profile
@bmorrisondev
bmorrisondev / ps-workflow.yaml
Created April 5, 2023 21:35
Creates a new branch & deploy request in PlanetScale when a PR is opened and schema.prisma is changed
name: Prisma PR PlanetScale Demo
on:
pull_request:
types: [opened]
paths:
- schema.prisma
env:
PLANETSCALE_ORG: bmorrison-ps
PLANETSCALE_DB: recipes_db
@kddnewton
kddnewton / json.rb
Last active October 6, 2023 09:25
JSON parser with pattern matching
require "json"
struct = { "a" => 1, "b" => 2, "c" => [1, 2, 3], "d" => [{ "e" => 3 }, nil, false, true, [], {}] }
source = JSON.dump(struct)
tokens = []
index = 0
until source.empty?
tokens <<
@TKadyear
TKadyear / gist:a6e15abc65a76525f0551e053f499987
Created May 31, 2022 10:16
Workflow Deploy with gh-pages
name: 🚀Deploy
on:
push:
branches:
- main
jobs:
deploy-to-gh-pages:
runs-on: ubuntu-latest
@PJUllrich
PJUllrich / big-o.md
Last active April 28, 2024 14:19
Big-O Time Complexities for Elixir Data Structures

Big-O Time Complexities for Elixir data structures

Map [1]

Operation Time Complexity
Access O(log n)
Search O(log n)
Insertion O(n) for <= 32 elements, O(log n) for > 32 elements [2]
Deletion O(n) for <= 32 elements, O(log n) for > 32 elements
@SomajitDey
SomajitDey / IPFS-NAT-traversal-using-ngrok.md
Last active January 12, 2023 04:02
Hosting IPFS node with ngrok

Hosting IPFS from behind NAT/Firewall using a free reverse proxy (ngrok)

  1. Expose localhost's port 4001 to public internet using ngrok: ngrok tcp 4001. Tip: Use -region= flag for lower latency.
  2. Note the hostname and port returned by ngrok in the form: tcp://hostname:port -> localhost:4001
  3. Open the ipfs config json file ~/.ipfs/config
  4. Edit as follows: Addresses.Announce=["/dns4/put-the-hostname-here/tcp/put-the-port-here"]
  5. Save the config file
  6. ipfs daemon
@jdnichollsc
jdnichollsc / Bitcoin.md
Last active November 9, 2022 18:36
🇨🇴 Criptomonedas & BlockChain 🇪🇸

Bitcoin

Es la primera criptomoneda o activo financiero digital descentralizado de la historia que permite realizar transacciones de forma segura, privada y sin intermediarios alrededor del mundo. Satoshi Nakamoto es el pseudónimo que fue utilizado por la persona o el grupo de personas que diseñaron y crearon el ecosistema Bitcoin.

La motivación de Satoshi Nakamoto para concebir Bitcoin fue crear un nuevo sistema de dinero electrónico que utilice por completo una red de pares que no necesite un tercero de confianza (intermediario financiero) para realizar las transacciones y cuya oferta no pueda ser alterada por ninguna otra parte. En otras palabras Bitcoin trasladaría las características deseables del dinero físico (falta de intermediarios, irrevocabilidad de las transacciones) al mundo digital y las combinaría con una política monetaria rigurosa que no se pueda manipular para producir inflación inesperada en beneficio de terceros, acosta de los tenedores de dicha moneda. Nakamoto lo logro utilizando te

@getify
getify / 1.js
Last active August 4, 2023 06:24
Converting English number sentences ("one hundred forty two point three") to numeric digits ("142.3")
convert("one hundred five"); // "105"
convert("six hundred and fifty three"); // "653"
convert("zero zero one two three"); // "123"
convert("twelve o three"); // "1203"
convert("thirteen zero nine"); // "1309"
convert("fifteen sixteen"); // "1516"
convert("fourteen ninety two"); // "1492"
convert("nineteen ten"); // "1910"
convert("twelve hundred"); // "1200"
convert("twenty three hundred"); // "2300"
Card = Struct.new(:suit, :rank) do
include Comparable
def precedence() = [SUITS_SCORES[self.suit], RANKS_SCORES[self.rank]]
def rank_precedence() = RANKS_SCORES[self.rank]
def suit_precedence() = SUITS_SCORES[self.rank]
def <=>(other) = self.precedence <=> other.precedence
def to_s() = "#{self.suit}#{self.rank}"
@melvic-ybanez
melvic-ybanez / what-i-didnt-know-about-fp-2020.md
Last active December 29, 2023 18:32
What I Didn't Know about Functional Programming until 2020

What I Didn't Know about Functional Programming until 2020

  1. Programming using a series of transformations and aggregations, something I've been doing for years, is known as programming in the map/reduce style.
  2. The more abstract the type is, the greater its cardinality, and the smaller the set of operations it supports. So make use of universal quantifiers, particularly by implementing fully parametric functions. They guide you on how to implement their term-level definitions by narrowing down the number of possible implementations. In other words, the type system of Scala (or Haskell, for that matter) is not only great for capturing compile-time errors, but is also capable of leading you to the correct solution.
  3. You can encode union types by combining different Scala features such as type constructors, subtyping and implicits, and by taking advantage of the Curry-Howard Isomorphism and De Morgan's Laws for neg
@pearagit
pearagit / uninstall-nix-osx.sh
Created September 10, 2020 12:51 — forked from expelledboy/uninstall-nix-osx.sh
[Uninstall Nix Macos] #nix
#!/bin/bash
# !!WARNING!!
# This will DELETE all efforts you have put into configuring nix
# Have a look through everything that gets deleted / copied over
nix-env -e '.*'
rm -rf $HOME/.nix-*
rm -rf $HOME/.config/nixpkgs