Skip to content

Instantly share code, notes, and snippets.

View joaorafaelm's full-sized avatar
🏠
Working from home

João joaorafaelm

🏠
Working from home
View GitHub Profile
@joaorafaelm
joaorafaelm / Dockerfile
Created January 16, 2024 23:54 — forked from adtac/Dockerfile
#!/usr/bin/env docker run
#!/usr/bin/env -S bash -c "docker run -p 8080:8080 -it --rm \$(docker build --progress plain -f \$0 . 2>&1 | tee /dev/stderr | grep -oP 'sha256:[0-9a-f]*')"
# syntax = docker/dockerfile:1.4.0
FROM node:20
WORKDIR /root
RUN npm install sqlite3
@joaorafaelm
joaorafaelm / command
Last active July 13, 2022 21:23
Prefix your commits with the branch name
curl -o '.git/hooks/prepare-commit-msg' https://gist.githubusercontent.com/joaorafaelm/4fedbd643fba2804df0117ac2b170da7/raw/prepare-commit-msg && chmod +x .git/hooks/prepare-commit-msg
@joaorafaelm
joaorafaelm / oneoff.py
Created April 23, 2021 15:37
one off periodic task using django celery beat
from django_celery_beat.models import PeriodicTask, ClockedSchedule
from django.utils.timezone import localtime, timedelta
import json
now = localtime()
clocked, _ = ClockedSchedule.objects.get_or_create(
clocked_time=now + timedelta(days=10)
)
PeriodicTask.objects.create(
@joaorafaelm
joaorafaelm / pdb.py
Created March 29, 2019 17:29
sub process debugging
import sys
import pdb
class ForkedPdb(pdb.Pdb):
"""A Pdb subclass that may be used
from a forked multiprocessing child
"""
def interaction(self, *args, **kwargs):
_stdin = sys.stdin
@joaorafaelm
joaorafaelm / LDApredict.py
Created November 22, 2017 19:17 — forked from ululh/LDApredict.py
LDA (Latent Dirichlet Allocation) predicting with python scikit-learn
# derived from http://scikit-learn.org/stable/auto_examples/applications/topics_extraction_with_nmf_lda.html
# explanations are located there : https://www.linkedin.com/pulse/dissociating-training-predicting-latent-dirichlet-lucien-tardres
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.decomposition import LatentDirichletAllocation
import pickle
# create a blank model
lda = LatentDirichletAllocation()
@joaorafaelm
joaorafaelm / openwordnetpt.py
Created October 27, 2017 23:15 — forked from erickrf/openwordnetpt.py
Functions to access the OpenWordnetPT graph
# -*- coding: utf-8 -*-
'''
Functions to read the OpenWordnetPT from RDF files and provide
access to it.
'''
import rdflib
from six.moves import cPickle
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer
from sklearn.datasets import fetch_20newsgroups
from sklearn.decomposition import NMF, LatentDirichletAllocation
def display_topics(model, feature_names, no_top_words):
for topic_idx, topic in enumerate(model.components_):
print "Topic %d:" % (topic_idx)
print " ".join([feature_names[i]
for i in topic.argsort()[:-no_top_words - 1:-1]])
@joaorafaelm
joaorafaelm / activate
Last active September 11, 2016 15:56 — forked from xiongchiamiov/activate
export GOPATH="$(builtin cd "$(dirname "${BASH_SOURCE[0]:-$_}" )" && pwd)"
export OLDPS1=$PS1
export PS1="[go:$(basename $GOPATH)] $PS1"
deactivate() {
export PS1=$OLDPS1
unset GOPATH
unset OLDPS1
unset deactivate
}
@joaorafaelm
joaorafaelm / .bashrc
Last active September 8, 2016 01:53 — forked from vsouza/.bashrc
Golang 1.5 setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
@joaorafaelm
joaorafaelm / System Design.md
Created April 18, 2016 12:48 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?