Skip to content

Instantly share code, notes, and snippets.

View marteinn's full-sized avatar
✖️
🥕

Martin Sandström marteinn

✖️
🥕
View GitHub Profile
@marteinn
marteinn / bottleserver.hy
Last active July 13, 2019 08:56
An example on how to use [hy](https://github.com/hylang/hy) with bottle
#! /usr/bin/env hy
(import [bottle [route run template]])
(with-decorator (route "/hello/<name>")
(defn index [name]
(template "<b>Hello {{name}}</b>!" :name name)))
(run :host "localhost" :port 8080)
@marteinn
marteinn / example-how-to-return-utf8-based-cvs-from-django.md
Created June 6, 2019 06:23
How to return csv in utf-8 format from a Django view

How to return csv in utf-8 format from a Django view

This is a example on how to return a utf-8 encoded csv form a django view.

import csv
import codecs

from django.contrib.auth import get_user_model
from django.views import View
@marteinn
marteinn / code-retreat-2019.md
Last active April 22, 2019 08:51
Notes from my code retreat 2019

Code retreat 2019

Projects

  • wagtail-alt-generator
    • Added translation support with the google translate api
    • Battled with a bug that made tags not be generated when image is uploaded through a page, still unsolved and connected when tags beeing overriden by form handling in wagtail
    • Fixed a bug related to the azure implementation (endpoints had changed and regions was introduced)
    • Improved the test suite with mock stubs for providers
    • Added CI integration
  • Rewrote the docs
@marteinn
marteinn / serverless-handler-with-textract.js
Last active April 20, 2019 12:36
How to pass a file to AWS Textract using serverless.js, where the file is in base64 format.
/*
This is a example serverless.js handler where we pass the
document we want to analyze as a base64 string (in a json payload)
and returns the result from textract.
Request:
{
"document": "/9j/4AAQS......."
}
@marteinn
marteinn / test.coco
Last active January 8, 2019 21:40
Testing coconut language (http://coconut-lang.org/) and bottle.py
"""
Installation:
pip install coconut
pip install bottle
pip install peewee
Running:
coconut test.coco && python test.py
"""
@marteinn
marteinn / example.md
Last active December 9, 2018 18:55
How to upsert an array to a google spreadsheet in Node.js

How to upsert an array to a google spreadsheet in Node.js

The api documentation for Google Spreadsheets is good and all, but is missing some straightforward usage examples, so here is one I could not find, how to take a plain multidimensional array with a header and write everything to a spreadsheet, replacing the old content.

const SPREADSHEET_ID = "ABC123";
const auth = new google.auth.OAuth2(
    client_id,
    client_secret,
    redirect_uris[0],

Software Development Process Audits - Simplified

1 Prepare and Plan

1.1 Clarify Global Goals and Objectives

1.2 Assemble an Audit Team

  • The team may consist of three to six people

1.3 Understand the Project

@marteinn
marteinn / case_converter.py
Created October 8, 2018 12:50
A helper for converting dictionary keys between camel and snake case
import re
def snake_case_to_camel_case(val):
return converter(val, snake_case_to_camel_case, snake_to_camel)
def camel_case_to_snake_case(val):
return converter(val, camel_case_to_snake_case, camel_to_snake)