Skip to content

Instantly share code, notes, and snippets.

View matheusho's full-sized avatar

Matheus Oliveira matheusho

View GitHub Profile
#!/bin/bash
# How to use:
# curl -o- gist-url | bash
function reset_shell() {
echo "Reset $SHELL";
exec "$SHELL";
}

Quake log parser

Task 1 - Construa um parser para o arquivo de log games.log e exponha uma API de consulta.

O arquivo games.log é gerado pelo servidor de quake 3 arena. Ele registra todas as informações dos jogos, quando um jogo começa, quando termina, quem matou quem, quem morreu pq caiu no vazio, quem morreu machucado, entre outros.

O parser deve ser capaz de ler o arquivo, agrupar os dados de cada jogo, e em cada jogo deve coletar as informações de morte.

Exemplo

@matheusho
matheusho / wtihDispatch.js
Last active January 22, 2018 11:53
Workaround to connect actions and state without redux and react-redux library
import React from 'react'
const bindActionCreator = (dispatch, actionCreator) => {
return () => dispatch(actionCreator.apply(this, arguments))
}
const bindActionCreators = (actions, dispatch) => {
const keys = Object.keys(actions)
const boundActionCreators = {}
# Before run this file open your terminal and run command:
xcode-select --install
echo "====> GITHUB_PERSONAL_KEY"
echo "export GITHUB_PERSONAL_KEY='your-key'" >> ~/.bashrc
source ~/.bashrc
# How to run this script
/usr/bin/ruby -e "$(curl -fsSL https://gist.githubusercontent.com/matheusho/1502ddd903a42c56fda93be137ab95f6/raw/33ae6793c29ba79f01bcda21f07a6e5575b0f5a9/configure-macos.sh)"
@matheusho
matheusho / django_signals_slugify.py
Last active October 13, 2024 00:01
Django : Generate unique slug
# import signals and slugify
from django.db.models import signals
from django.template.defaultfilters import slugify
class Post(models.Model):
text = models.TextField("Post text")
# function for use in pre_save
# Import datetime
from datetime import date, timedelta
# date.today() returns the current date
# timedelta(days=X) takes the "days" attribute to subtract days from the current date
date = date.today() - timedelta(days=30)
# The "__gte" lookup search finds records where the date
# is greater than or equal to the comparison value
object_list = Model.objects.filter(date_at__gte=date)