Skip to content

Instantly share code, notes, and snippets.

@Rocckk
Rocckk / http-json-echo.py
Created March 12, 2019 16:50 — forked from bsingr/LICENSE.txt
http json echo server written in python3
#!/usr/bin/env python3
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import urlparse
import json
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
parsed_path = urlparse(self.path)
self.send_response(200)
@Rocckk
Rocckk / dummy-web-server.py
Created April 1, 2019 15:17 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
@Rocckk
Rocckk / graph_models.md
Created August 14, 2019 11:23 — forked from rg3915/graph_models.md
Generate graphic model Django with PyGraphViz

How to generate graphic model Django with PyGraphViz?

sudo apt-get install graphviz libgraphviz-dev pkg-config
virtualenv -p python2.7 .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install pygraphviz
pip uninstall pyparsing
pip install -Iv https://pypi.python.org/packages/source/p/pyparsing/pyparsing-1.5.7.tar.gz#md5=9be0fcdcc595199c646ab317c1d9a709
@Rocckk
Rocckk / py_cx_ora_dates
Created September 24, 2019 14:41
Working with dates and timestamps using python and cx_oracle. Prefer to_date and to_timestamp with format strings. Don't like the alter session option. Some folks described problems with unicode so I added the unicode strings.
#! /bin/python
import cx_Oracle
import platform
print ("Python version: " + platform.python_version())
print ("cx_Oracle version: " + cx_Oracle.version)
print ("Oracle client: " + str(cx_Oracle.clientversion()).replace(', ','.'))
connection = cx_Oracle.connect('user/pass09@tns')
cursor = connection.cursor()
@Rocckk
Rocckk / views.py
Created October 8, 2019 14:55 — forked from reidransom/views.py
Returning binary data from a Django view
from django.http import HttpResponse
def django_file_download_view(request):
filepath = '/path/to/file.xlsx'
with open(filepath, 'r') as fp:
data = fp.read()
filename = 'some-filename.xlsx'
response = HttpResponse(mimetype="application/ms-excel")
response['Content-Disposition'] = 'attachment; filename=%s' % filename # force browser to download file
response.write(data)
@Rocckk
Rocckk / curl.md
Created February 2, 2020 14:07 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.