Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Coding time

Vinicius Souza vsouza

:octocat:
Coding time
View GitHub Profile
@KronicDeth
KronicDeth / elixirconf-2017-recap.md
Created Sep 22, 2017
Recap of all talks at ElixirConf 2017
View elixirconf-2017-recap.md

Elixir Native UI - Boyd Multerer https://www.youtube.com/watch?v=77FW-jrCyCs

Thinking In Ecto - Darin Wilson https://www.youtube.com/watch?v=YQxopjai0CU

  1. Repository pattern https://youtu.be/YQxopjai0CU?t=2m12s
  2. Explicitness https://youtu.be/YQxopjai0CU?t=5m29s
@matryer
matryer / term_context.go
Last active Sep 28, 2020
Making Ctrl+C termination cancel the context.Context
View term_context.go
func main() {
ctx := context.Background()
// trap Ctrl+C and call cancel on the context
ctx, cancel := context.WithCancel(ctx)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
defer func() {
signal.Stop(c)
@bmhatfield
bmhatfield / .zshrc
Last active Apr 18, 2021
OSX Keychain Environment Variables
View .zshrc
# If you use bash, this technique isn't really zsh specific. Adapt as needed.
source ~/keychain-environment-variables.sh
# AWS configuration example, after doing:
# $ set-keychain-environment-variable AWS_ACCESS_KEY_ID
# provide: "AKIAYOURACCESSKEY"
# $ set-keychain-environment-variable AWS_SECRET_ACCESS_KEY
# provide: "j1/yoursupersecret/password"
export AWS_ACCESS_KEY_ID=$(keychain-environment-variable AWS_ACCESS_KEY_ID);
export AWS_SECRET_ACCESS_KEY=$(keychain-environment-variable AWS_SECRET_ACCESS_KEY);
@lucasrcosta
lucasrcosta / tornado_handler_thread_decorator.py
Last active Feb 20, 2019
Tornado Handler Thread Decorator
View tornado_handler_thread_decorator.py
from concurrent.futures import ThreadPoolExecutor
from datetime import timedelta
from tornado import gen
from tornado.concurrent import run_on_executor
THREADPOOL_MAX_WORKERS = 10
THREADPOOL_TIMEOUT_SECS = 30
def onthread(function):
@vsouza
vsouza / request.swift
Last active May 31, 2016
Simple HTTP request. Swift backend implementation
View request.swift
import HTTP
import File
import HTTPSClient
import JSON
var url: String?
do {
let client = try! Client(uri: "https://api.github.com:443")
var response = try client.get("/repos/vsouza/awesome-ios/git/trees/HEAD")
let buffer = try response.body.becomeBuffer()
@mixxorz
mixxorz / graphene.py
Last active Apr 24, 2021
Get requested fields from ResolveInfo. Graphene python.
View graphene.py
"""
MIT License
Copyright (c) 2018 Mitchel Cabuloy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
View csv_diff.py
import pandas as pd
data = {'a': [1, 3, 4, 4], 'b': [1, 3, 2, 3]}
df = pd.DataFrame(data=data)
df.to_csv("data/old_data.csv")
data2 = {'a': [1, 3, 5, 4], 'b': [1, 3, 2, 3]}
df2 = pd.DataFrame(data=data2)
df2.to_csv("data/new_data.csv")
@madhums
madhums / gin_html_render.go
Last active Mar 15, 2021
render html templates in gin (go)
View gin_html_render.go
// Package GinHTMLRender provides some sugar for gin's template rendering
//
// This work is based on gin contribs multitemplate render https://github.com/gin-gonic/contrib/blob/master/renders/multitemplate
//
// Usage
//
// router := gin.Default()
//
// // Set html render options
// htmlRender := GinHTMLRender.New()
@patik
patik / how-to-squash-commits-in-git.md
Last active Apr 23, 2021
How to squash commits in git
View how-to-squash-commits-in-git.md

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

@harlow
harlow / golang_job_queue.md
Last active May 11, 2021
Job queues in Golang
View golang_job_queue.md