Skip to content

Instantly share code, notes, and snippets.

@leomrocha
leomrocha / quickstart.py
Created September 10, 2020 17:36
Google Sheet example for credential encryption modification
# Modified to add cryptography from the spreadsheet example:
# https://developers.google.com/sheets/api/quickstart/python
# https://github.com/gsuitedevs/python-samples/blob/master/sheets/quickstart/quickstart.py
#
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@leomrocha
leomrocha / metainfo.py
Created May 23, 2020 16:39 — forked from andreasvc/metainfo.py
Extract metadata from Project Gutenberg RDF catalog into a Python dict.
"""Extract metadata from Project Gutenberg RDF catalog into a Python dict.
Based on https://bitbucket.org/c-w/gutenberg/
>>> md = readmetadata()
>>> md[123]
{'LCC': {'PS'},
'author': u'Burroughs, Edgar Rice',
'authoryearofbirth': 1875,
'authoryearofdeath': 1950,
@leomrocha
leomrocha / find_arch.py
Created March 19, 2019 16:02
Python, finding if the architecture is 32 or 64 bits
# This file is to sum up how to get the hardware architecture (32 or 64 bits)
# solutions are taken from here:
# https://stackoverflow.com/questions/1405913/how-do-i-determine-if-my-python-shell-is-executing-in-32bit-or-64bit-mode-on-os
# https://stackoverflow.com/questions/1842544/how-do-i-detect-if-python-is-running-as-a-64-bit-application
def get_platform():
"""
Finds if the platform is 32 or 64 bits
Several different ways are tried in case one fails
mainApp.directive('vextab', function($compile){
return{
//note, WARNING with E (Element) it breaks the placement of the player
restrict: 'EC',
//restrict: 'C',
link: function(scope, element, attrs){
try {
new Vex.Flow.TabDiv(element);
}
mainApp.directive('vexchord', function($compile){
//console.log("rendering vextab");
return{
restrict: 'E',
link: function(scope, element, attrs){
var el = createChordElement(createChordStruct(attrs.key, attrs.string, attrs.shape));
$compile(el)(scope);
element.replaceWith(el);
//console.log("finish vexchord processing");
}
mainApp.directive('vextab', function($compile){
//console.log("rendering vextab");
var canvas = document.createElement('canvas');
renderer = new Vex.Flow.Renderer( canvas,
//Vex.Flow.Renderer.Backends.SVG);
Vex.Flow.Renderer.Backends.CANVAS);
artist = new Vex.Flow.Artist(10, 10, 800, {scale: 0.8});
vextab = new Vex.Flow.VexTab(artist);
return{
mainApp.directive('markdown', function (){
//console.log("evaluating markdown");
var converter = new Showdown.converter();
return {
restrict: 'AEC',
link: function (scope, element, attrs) {
//console.log("evaluating markdown 2");
var htmlText = converter.makeHtml(element.text() || '');
element.html(htmlText);
}
def get_code_message(num):
"""
gets an or simple string and returns a descriptive message of the status
"""
translate_codes = {
100: "100 Continue",
101: "101 Switching Protocols",
200: "200 OK",
201: "201 Created",
202: "202 Accepted",