Skip to content

Instantly share code, notes, and snippets.

View fcgomes92's full-sized avatar
:octocat:
Batata é bom

Fernando fcgomes92

:octocat:
Batata é bom
View GitHub Profile

Poker hand ranking

Write a function that tells you the best scoring for a given poker hand of 5 cards. For instance:

(score [[3 :diamonds] [3 :hearts] [3 :spades] [5 :hearts] [:king :clubs]])
=> :three-of-a-kind ;; three 3s

Cards are represented as a tuple of rank (number or name if it's a face card) and suit. Face card names are the keywords :ace, :king, :queen, :jack. Suits are :diamonds, :spades, :hearts, :clubs.

from datetime import datetime
links = [
'https://g1.globo.com/rj/rio-de-janeiro/noticia/pf-cumpre-mandados-em-mais-um-desdobramento-da-lava-jato-no-rio.ghtml',
'https://g1.globo.com/sp/sao-paulo/noticia/ataque-a-tiros-mata-1-e-deixa-2-feridas-em-frente-a-hotel-em-sp-veja-video.ghtml',
'https://globoesporte.globo.com/olimpiadas-de-inverno/noticia/nervosa-isadora-williams-sofre-queda-na-final-da-patinacao-e-chora-muito-triste.ghtml',
'https://g1.globo.com/agenda-do-dia/noticia/sexta-feira-23-de-fevereiro.ghtml',
'https://g1.globo.com/rj/rio-de-janeiro/noticia/general-richard-nunez-sera-o-secretario-de-seguranca-do-rj.ghtml',
'https://g1.globo.com/rj/rio-de-janeiro/noticia/comandante-de-instituicao-de-ensino-da-pm-do-rj-e-exonerado-policiais-denunciam-abusos.ghtml',
@ipbastola
ipbastola / jq to filter by value.md
Last active April 25, 2024 17:14
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

@zbyte64
zbyte64 / sample.py
Created June 27, 2016 23:00
Docker py put archive example
import tarfile
import time
from io import BytesIO
admin_password = 'xxxxx'
#write password to file
pw_tarstream = BytesIO()
pw_tar = tarfile.TarFile(fileobj=pw_tarstream, mode='w')
file_data = admin_password.encode('utf8')
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@jmvrbanac
jmvrbanac / app.py
Created February 18, 2016 01:05
Using Jinja2 with Falcon
import os
import falcon
import jinja2
def load_template(name):
path = os.path.join('templates', name)
with open(os.path.abspath(path), 'r') as fp:
return jinja2.Template(fp.read())
@dhbradshaw
dhbradshaw / gist:e2bdeb502b0d0d2acced
Last active August 16, 2023 17:50
Rename field using migrations in django 1.7
To change a field name in django 1.7+
1. Edit the field name in the model (but remember the old field name: you need it for step 3!)
2. Create an empty migration
$ python manage.py makemigrations --empty myApp
3. Edit the empty migration (it's in the migrations folder in your app folder, and will be the most recent migration) by adding
migrations.RenameField('MyModel', 'old_field_name', 'new_field_name'),
to the operations list.