Skip to content

Instantly share code, notes, and snippets.

View martin-martin's full-sized avatar
⛰️
hill view from the balcony

Martin Breuss martin-martin

⛰️
hill view from the balcony
View GitHub Profile
@martin-martin
martin-martin / example_unflattened.json
Created October 15, 2019 04:55
Output of unflattening the flattened OCDS CSV format from CCS published Contracts data on data.gov.uk
This file has been truncated, but you can view the full file.
{
"main": [
{
"uri": "https://www.contractsfinder.service.gov.uk/Published/Notice/releases/41b7c3fd-6856-4cb5-a1f7-a9ee1c987e50.json",
"publishedDate": "2019-10-01T22:33:37Z",
"publisher": {
"name": "IN-TEND LIMITED",
"scheme": "GB-GOVUK-crown_comercial_service",
"uri": "https://www.contractsfinder.service.gov.uk"
},
@martin-martin
martin-martin / 109504-2019.json
Created October 14, 2019 03:27
Example OCDS JSON downloaded through the scraper script
{
"uri": "https://enoticetest.service.xgov.uk/Notice/Published/109504-2019",
"version": "1.1",
"extensions": [
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_bid_extension/v1.1.4/extension.json",
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_finance_extension/v1.1/extension.json",
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_location_extension/v1.1.4/extension.json",
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_lots_extension/v1.1.4/extension.json",
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_participationFee_extension/v1.1.4/extension.json",
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_partyDetails_scale_extension/master/extension.json",
@martin-martin
martin-martin / activate
Created October 7, 2019 04:54
Example activate script for a Python Virtual Environment
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
# reset old environment variables
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
default 12:20:24.249218 +0930 iShowU Instant [com.apple.main-thread] Property kAudioDevicePropertyDeviceIsRunningSomewhere changed on device BLUE USB Audio 2.0. Send to delegate: (null)
default 12:20:26.644546 +0930 iShowU Instant [com.apple.main-thread] Property kAudioDevicePropertyDeviceIsRunningSomewhere changed on device BLUE USB Audio 2.0. Send to delegate: (null)
default 12:20:30.178706 +0930 iShowU Instant [com.apple.main-thread] Property kAudioDevicePropertyDeviceIsRunningSomewhere changed on device BLUE USB Audio 2.0. Send to delegate: (null)
default 12:20:31.211486 +0930 iShowU Instant [com.apple.main-thread] Property kAudioDevicePropertyDeviceIsRunningSomewhere changed on device BLUE USB Audio 2.0. Send to delegate: (null)
default 12:20:31.737888 +0930 iShowU Instant [com.apple.main-thread] Property kAudioDevicePropertyDeviceIsRunningSomewhere changed on device BLUE USB Audio 2.0. Send to delegate: (null)
default 12:20:31.874060 +0930 iShowU Instant [com.apple.main-thread] Property kAudioDeviceProp
import os
import tweepy
# fetch the secrets from our virtual environment variables
CONSUMER_KEY = os.environ['TWITTER_CONSUMER_KEY']
CONSUMER_SECRET = os.environ['TWITTER_CONSUMER_SECRET']
ACCESS_TOKEN = os.environ['TWITTER_ACCESS_TOKEN']
ACCESS_SECRET = os.environ['TWITTER_ACCESS_SECRET']
# CLASSES AND OBJECT-ORIENTED PROGRAMMING
class Ingredient:
"""Models an ingredient including its name and amount."""
def __init__(self, name, amount):
self.name = name
self.amount = amount
def __str__(self):
return f"There are {self.amount} of {self.name}."
@martin-martin
martin-martin / base.html
Created August 7, 2018 10:00
Django templates: show authentication links depending on user authentication status
<!DOCTYPE html>
<html>
<head>
<title>nameme</title>
</head>
<body>
<nav>
<!-- below block allows to show/hide authentication info
depending on user's authentication status -->
{% if not user.is_authenticated %}
@martin-martin
martin-martin / views.py
Created August 7, 2018 09:48
working authentication with Django 2.1 (including some gotchas!)
from django.shortcuts import render, redirect
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.contrib.auth import login, authenticate, logout
# Create your views here.
def signup_user(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid(): # first see whether all is good
@martin-martin
martin-martin / friend_count.py
Created June 22, 2018 12:24
get user's friend count from twitter using tweepy
import os
import tweepy
# fetch the secrets from our virtual environment variables
CONSUMER_KEY = os.environ['TWITTER_CONSUMER_KEY']
CONSUMER_SECRET = os.environ['TWITTER_CONSUMER_SECRET']
ACCESS_TOKEN = os.environ['TWITTER_ACCESS_TOKEN']
ACCESS_SECRET = os.environ['TWITTER_ACCESS_SECRET']
@martin-martin
martin-martin / .gitignore
Last active February 20, 2019 03:42 — forked from octocat/.gitignore
Some common .gitignore configurations
# Virtual Environments #
########################
env/
.env/
venv
.venv
# Compiled source #
###################
*.com