Skip to content

Instantly share code, notes, and snippets.

View reinaldons's full-sized avatar
👾

Reinaldo Nolasco Sanches reinaldons

👾
View GitHub Profile
import json
with open('json file path') as f:
json_data = json.load(f)
json_data[0]['key'] = 'new value'
print(json.dumps(json_data))
@reinaldons
reinaldons / gist:851672
Created March 2, 2011 20:26
PostgreSQL - Grouping all client subscriptions and multiply unitary value by quantity only when product ID is not 64
SELECT
client.id,
client.name,
fop.start_effective_date,
fop.end_effective_date,
EXTRACT(month FROM fop.end_effective_date)::integer AS month,
SUM(CASE subscription.product_id WHEN 64 THEN subscription.unit_value ELSE subscription.unit_value * subscription.qty END) AS total
FROM
master
LEFT JOIN
@reinaldons
reinaldons / sms-gw-json-to-csv.py
Created October 30, 2015 16:08
Load a JSON generated by SMS-GW API /api/v1/products/(product_name)/messages and wwriting a CSV file with some fields
import json
import csv
from optparse import OptionParser
def json_to_csv(json_filename, csv_filename):
with open(json_filename, 'r') as json_file:
json_decoded = json.load(json_file)
with open(csv_filename, 'w') as csv_file:
import urllib
import requests
# OAuth2 Server URL
URL = 'https://oauth2.server'
# URL to redirect after login
REDIRECT_URI = 'https://redirect.url'
# Client ID and Secret Key
CLIENT_ID = ''
Verifying that +reinaldons is my blockchain ID. https://onename.com/reinaldons
@reinaldons
reinaldons / partial_flaskr_tests.py
Created May 8, 2013 00:13
MongoDB with no disk file persist
import socket
from time import sleep
import os
import unittest
import tempfile
from subprocess import Popen, PIPE
from flask import url_for
import flaskr
#!/usr/bin/env python
import cgi
import urllib
import urllib2
import sys
import cgitb
cgitb.enable()
#!/usr/bin/env python
import cgi
import urllib
import urllib2
import sys
import cgitb
cgitb.enable()
AMQ_URL = 'http://amq:8161/api/message/healthcheck.xpto?type=queue&clientId=xpto'

Keybase proof

I hereby claim:

  • I am reinaldons on github.
  • I am reinaldons (https://keybase.io/reinaldons) on keybase.
  • I have a public key whose fingerprint is 5902 BA8F 5386 C10A 8E02 7A52 0AE9 1492 F02C D42C

To claim this, I am signing this object:

@reinaldons
reinaldons / .bashrc
Last active September 2, 2016 12:08
Append for Kubuntu .bashrc
# autoenv
. /usr/local/bin/activate.sh
. /usr/share/virtualenvwrapper/virtualenvwrapper.sh
. ~/.bash_prompt
export GOROOT=/usr/lib/go-1.6
export PATH=$PATH:$GOROOT/bin