Skip to content

Instantly share code, notes, and snippets.

View VITIMan's full-sized avatar

Victoriano Navarro VITIMan

View GitHub Profile
@VITIMan
VITIMan / electronic_resources.md
Last active September 18, 2017 06:54
Electronics
@VITIMan
VITIMan / mpd_resources.md
Last active September 14, 2017 07:19
Music Radio MPD Icecast Resources
@VITIMan
VITIMan / activitypub_resources.md
Created September 10, 2017 17:07
ActivityPub, JSON-LD, ActivityStreams resources
@VITIMan
VITIMan / docker-compose.md
Created September 5, 2017 07:40
Docker snippets

Debugging

If you are using the following within your code to debug:

import ipdb; ipdb.set_trace()

Then you may need to run the following for it to work as desired:

$ docker-compose -f file.yml run --service-ports image:tag
@VITIMan
VITIMan / json_array_requests.py
Created September 4, 2017 07:39
Requests library snippets
import requests
import json
# from https://stackoverflow.com/a/35534695
payload = [{"json": "array"}, {"another": "element"}]
headers = {'Content-Type': 'application/json', 'Accept':'application/json'}
requests.post(url,data=json.dumps(payload), headers=headers)
# In newer versions of requests
# from https://stackoverflow.com/a/35535240
@VITIMan
VITIMan / import_dynamic.py
Created August 30, 2017 14:16
Some dynamic imports snippets
"""
# From: https://stackoverflow.com/a/30941292
# Standard import
import importlib
# Load "module.submodule.MyClass"
MyClass = getattr(importlib.import_module("module.submodule"), "MyClass")
# Instantiate the class (pass arguments to the constructor, if needed)
instance = MyClass()
"""
@VITIMan
VITIMan / cli_curl.md
Last active September 19, 2017 14:52
command line