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 August 1, 2018 14:22
Django : Generate unique slug
# import signals and slugify
from django.db.models import signals
from django.template.defaultfilters import slugify
# function for use in pre_save
def yourmodel_pre_save(signal, instance, sender, **kwargs):
if not instance.slug:
slug = slugify(instance.attribute) # change the attibute to the field that would be used as a slug
new_slug = slug
# Import datetime
from datetime import date
today = datetime.today()
date = date.fromordinal(today.toordinal() - 30) # today - 30 days
object_list = Model.objects.filter(date_at__gte=date)