Skip to content

Instantly share code, notes, and snippets.

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

Lucivaldo lucivaldo

🏠
Working from home
View GitHub Profile
@jmflannery
jmflannery / application_controller.rb
Created October 28, 2016 15:21
authenticate_with_http_token example in a rails controller
def authenticate_token
@user = authenticate_with_http_token do |key, options|
token = Token.find_by key: key
token.user if token
end
head 401 unless @user
end
@luzfcb
luzfcb / installing_pyenv_on_ubuntu_based_distros.md
Last active April 18, 2025 22:04
Quick install pyenv and Python

Tested only on Ubuntu 24.04, KDE Neon User Edition (based on Ubuntu 24.04) and OSX Mojave or higher.

will probably work on other newer versions, with no changes, or with few changes in non-python dependencies (apt-get packages)

NOTE: Don't create a .sh file and run it all at once. It may will not work. Copy, paste, and execute each command below manually. :-)

Ubuntu

# DO NOT RUN THIS AS A ROOT USER
@lucivaldo
lucivaldo / config.fish
Last active October 31, 2024 21:46
My fish config
set -x GITLAB_PERSONAL_ACCESS_TOKEN abc
set -x ATHENAS_API_TOKEN abc
set -x SOLAR_API_TOKEN abc
set -x JQ_ATHENAS '.results[0] | { field1, field2, field3, field4: field4.subfield1.name }'
# go lang
fish_add_path /usr/local/go/bin
# flutter
@lucivaldo
lucivaldo / getGitLabIssuesByMilestone.js
Last active September 18, 2021 17:38
Exemplo de código JS para realizar várias chamadas assíncronas para API backend utilizando iterables e for await...of
const fetchAllResources = async (resources, params) => {
const asyncIterable = {
[Symbol.asyncIterator]() {
return {
page: '1',
finished: false,
async next() {
if (!this.finished) {
const response = await api.get(resources, {
params: { ...params, page: this.page },