Skip to content

Instantly share code, notes, and snippets.

Avatar

Cristina Silva crissilvaeng

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am crissilvaeng on github.
  • I am crissilvaeng (https://keybase.io/crissilvaeng) on keybase.
  • I have a public key ASCfEFRXivc3yNwHQhyho0GDFhw-nH-FmIUga8pDdhczHwo

To claim this, I am signing this object:

@crissilvaeng
crissilvaeng / main.rs
Created Oct 24, 2022
Exercism Poker Card to Cactus Kev's Poker Card
View main.rs
let mut chars = val.chars();
let suit = chars.next_back().unwrap().to_string();
let rank = chars.as_str();
let mut card: u32 = 0;
card |= match rank {
"2" => 1 << 16 ^ (0 << 8) + 2,
"3" => 1 << 17 ^ (1 << 8) + 3,
"4" => 1 << 18 ^ (2 << 8) + 5,
"5" => 1 << 19 ^ (3 << 8) + 7,
@crissilvaeng
crissilvaeng / alias
Last active Oct 21, 2021
Git Aliases
View alias
close = !sh -c 'git branch -d $1' -
local = rev-parse --abbrev-ref HEAD
swap = !sh -c 'git switch -c $1 --track origin/\"$(git local)\"' -
sync = pull --rebase --autostash
@crissilvaeng
crissilvaeng / gitr
Created Oct 20, 2021
Git Recursive
View gitr
#!/bin/bash
find . -type d -mindepth 1 -maxdepth 1 -print0 | while read -d $'\0' folder; do
    echo -e "\033[0;35m$folder\033[0m"
    git -C $folder $@
done
@crissilvaeng
crissilvaeng / notification.js
Created May 28, 2021
Nuxt – Notification Plugin
View notification.js
import Notification from '@/components/Notification'
import Vue from 'vue'
const NotificationClass = Vue.extend(Notification)
export default ({ app }, inject) => {
inject('notification', {
show({ ctx, title, message = '', type = 'info' }) {
const notification = new NotificationClass({
propsData: { title, message, type },
@crissilvaeng
crissilvaeng / app.py
Created May 10, 2021
Flask with Parse Server JWT Middleware
View app.py
import os
import requests
from functools import wraps
from flask import Flask, request
PARSE_SERVER_URL = os.environ['PARSE_SERVER_URL']
PARSE_APPLICATION_ID = os.environ['PARSE_SERVER_URL']
app = Flask(__name__)
@crissilvaeng
crissilvaeng / nginx.conf.sigil
Created May 6, 2021
Dokku – NGINX Configuration without maximum body size
View nginx.conf.sigil
server {
listen [::]:{{ .NGINX_PORT }};
listen {{ .NGINX_PORT }};
server_name {{ .NOSSL_SERVER_NAME }};
access_log /var/log/nginx/{{ .APP }}-access.log;
error_log /var/log/nginx/{{ .APP }}-error.log;
include {{ .DOKKU_ROOT }}/{{ .APP }}/nginx.conf.d/*.conf;
@crissilvaeng
crissilvaeng / main.py
Created Apr 12, 2021
Playground – Schedule Problem – Greedy vs NonGreedy Algorithm
View main.py
from timeit import default_timer as timer
from random import randrange, choice
from itertools import combinations
from dataclasses import dataclass
from operator import attrgetter
from io import StringIO
from typing import List, Optional, Sequence, Tuple
@dataclass
@crissilvaeng
crissilvaeng / main.py
Last active Apr 8, 2021
Classic Computer Science Problems in Python – GeneticAlgorithm – SimpleEquation
View main.py
from __future__ import annotations
from copy import deepcopy
from enum import Enum
from functools import reduce
from heapq import nsmallest
from itertools import tee
from math import radians, sqrt, sin, cos, atan2
from random import choices, random, shuffle, randrange
from statistics import mean
from operator import add
View main.py
from itertools import combinations
from random import choice
players = ['Cristina', 'Rodrigo', 'Moises', 'Wagner', 'Arthur']
league = list(combinations(players, 2))
print(league)
def victory_host(ranking, host, away):
ranking[host] = ranking.get(host, 0) + 3