Skip to content

Instantly share code, notes, and snippets.

View arthurio's full-sized avatar
🇺🇲
In Parker

Arthur Rio arthurio

🇺🇲
In Parker
View GitHub Profile
@arthurio
arthurio / build_dict.py
Created March 11, 2014 00:19
Build a dict in python - 2.6 syntax vs. 2.7
data = ['a', 'b', 'c']
# Python v2.7
my_dict = {key: i for i, key in enumerate(data)}
# Python v2.6
my_dict = dict((key, i) for i, key in enumerate(data))
@arthurio
arthurio / Bronto referral
Last active August 29, 2015 14:01
Javascript snippet to call the Bronto referral API
PT.api.call('/bronto/referral', {
method: 'post',
data: {
message: 'Example of message',
emails: ['example1@punchtab.com', 'example2@punchtab.com']
// OR emails: 'example1@punchtab.com,example2@punchtab.com'
},
success: function (response) {
console.log('OK');
},
@arthurio
arthurio / sign.py
Last active August 29, 2015 14:04
Webhook Signature Example
import hmac
import hashlib
import simplejson
from time import time
data = {
'timestamp': time(),
'user': {
'uid': 1234
}
@arthurio
arthurio / sample.json
Created July 17, 2014 21:11
Sample data for Purchase webhook
{
"timestamp": 1405631393.186916,
"user": {
"uid": "1234",
"first_name": "John",
"last_name": "Doe",
"email": "john.doe@example.com"
},
"transaction": {
"id": "123-345-678"
@arthurio
arthurio / .vimrc.after
Last active August 29, 2015 14:06
MacVim conf
color wombat
hi ColorColumn ctermbg=lightgrey guibg=#474747
" Cursor shape
hi Cursor guibg=orange guifg=white
set autoindent
set smartindent
set tabstop=4
@arthurio
arthurio / Extends
Created April 6, 2015 23:51
Python function to merge 2 dicts, similar to what angular does
'''
Extends a dict object A with the properties of a dict object B.
@param a: dict object
@param b: dict object
'''
def extends(a, b):
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict):
a[key] = extends(a[key], b[key])
@arthurio
arthurio / keybase.md
Created May 8, 2020 20:10
Keybase verification

Keybase proof

I hereby claim:

  • I am arthurio on github.
  • I am arthurio (https://keybase.io/arthurio) on keybase.
  • I have a public key ASCZuOqRvACWx0X4La-bIjFrt8FaUubXhRsM_zfRwpfGWAo

To claim this, I am signing this object:

@arthurio
arthurio / README.md
Last active April 23, 2021 00:34
FastApi - Override pydantic settings

Setup

pip install pytest pydantic

Run

pytest

#!/bin/zsh
set -euxo pipefail
for service in messaging-py
do
(
cd $service
git clean -fd .
mkdir $service
mv .* * $service || true