Skip to content

Instantly share code, notes, and snippets.

View dkdndes's full-sized avatar

PR dkdndes

View GitHub Profile
@dkdndes
dkdndes / django-json-response
Last active January 21, 2017 16:38
Serialize to JSON when Django-rest-framework or Tastypie is to heavy
import json
from django.http import HttpResponse
class JSONResponse(HttpResponse):
"""
Return a JSON serialized HTTP resonse
"""
def __init__(self, request, data, status=200):
serialized = json.dumps(data)
super(JSONResponse, self).__init__(
@dkdndes
dkdndes / objectify_parse_with_schema
Last active April 23, 2022 01:38
lxml objectify xml with xsd schema
def objectify_parse_with_schema(schemaname, infilename):
schema = etree.XMLSchema(file=schemaname)
parser = objectify.makeparser(schema=schema)
doctree = objectify.parse(infilename, parser=parser)
root = doctree.getroot()
return doctree, root

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@dkdndes
dkdndes / yaml2json.py
Created March 17, 2017 13:50 — forked from noahcoad/yaml2json.py
Python to Convert yaml to json
# convert yaml to json
# pip3 install pyyaml
# http://pyyaml.org/wiki/PyYAMLDocumentation
# py3 yaml2json.py < ~/code/manpow/homeland/heartland/puphpet/config.yaml
# gist https://gist.github.com/noahcoad/51934724e0896184a2340217b383af73
import yaml, json, sys
sys.stdout.write(json.dumps(yaml.load(sys.stdin), sort_keys=True, indent=2))
@dkdndes
dkdndes / docker-compose.yml
Last active July 7, 2018 15:37
Docker-Compose django-channels multichat example which allows scalable (async) workers
# Example for a scalable worker for Andrew Goodwins django-channels multichat example
# from https://www.excella.com/insights/scaling-django-channels-with-docker
#
# Replace the existing docker-compose.yml at
# https://github.com/andrewgodwin/channels-examples/tree/master/multichat
#
# Follow the docker-compose steps for db migration, etc. and then
#
# $ docker-compose ps
# $ docker-compose scale worker=5 &
@dkdndes
dkdndes / SpeiOneTimePayment.md
Created March 1, 2018 15:52 — forked from leofischer/SpeiOneTimePayment.md
SPEI One Time Payment

#Curl

curl --request POST \
  --url https://api.conekta.io/orders \
  --header 'accept: application/vnd.conekta-v2.0.0+json' \
  -u key_eYvWV7gSDkNYXsmr: \
  --header 'content-type: application/json' \
  --data '{
    "line_items": [{
@dkdndes
dkdndes / api_urls.py
Last active July 9, 2019 09:55
djstribe url missing in docu; place the code in /payments/ and /api/
# Payments
url(r'^payments/', include('djstripe.contrib.rest_framework.urls', namespace="rest_payments")),
@dkdndes
dkdndes / docker_swarm_init_in_doid.sh
Last active May 29, 2018 09:01
Start a Docker Swarm Clustern within "Docker in Docker (doid)"
#!/bin/bash
# Init Swarm master
docker swarm init
# Get join token:
SWARM_TOKEN=$(docker swarm join-token -q worker)
echo $SWARM_TOKEN
# Get Swarm master IP (Docker for Mac xhyve VM IP)
import os import os
from django.conf import settings
from django.contrib.auth import get_user_model
User = get_user_model()
print (os.environ['EMAIL'] + ' user already exists') if User.objects.filter(email=os.environ['EMAIL'],username=os.environ['USERNAME']) else User.objects.create_superuser(os.environ['USERNAME'], os.environ['EMAIL'], os.environ['PASSWORD'])
"""This file checks, if the package is installed on the current system."""
import os
import sys
import argparse
from importlib import import_module
def main():
"""
Check if the package name is installed.