Skip to content

Instantly share code, notes, and snippets.

@pwldp
pwldp / ScalableClient.py
Created March 9, 2018 11:00
python 3 scalable client - run workers in threads
#!/usr/bin/env python3
"""
Class for scalable client which runs workers in threads
"""
#
import random
import threading
import time
#
#
@pwldp
pwldp / read_large_file.py
Last active April 19, 2017 09:06
Read large text files in Python, line by line without loading it in to memory
with open( filePath ) as infile:
"""
# read first line and remember it
first_line = infile.readline()
# or only skip first line
next( infile )
"""
for line in infile:
print line
@ekiara
ekiara / django-getting-a-model-from-a-string.md
Last active April 11, 2022 11:59
django-getting-a-model-from-a-string
@Cheaterman
Cheaterman / .gitignore
Last active March 29, 2024 03:56
Kivy Login example
*.pyc
@SpotlightKid
SpotlightKid / aescrypt.py
Created September 3, 2014 18:29
Encrypt/decrypt files with symmetric AES cipher-block chaining (CBC) mode.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Encrypt/decrypt files with symmetric AES cipher-block chaining (CBC) mode.
Usage:
File Encryption:
aescrypt.py [-f] infile [outfile]
@luxinyan
luxinyan / reportlab_barcode.py
Created April 23, 2014 07:14
Generate barcode with reportlab.
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm
#I"ll be generating code39 barcodes, others are available
from reportlab.graphics.barcode import code39
# generate a canvas (A4 in this case, size doesn"t really matter)
c=canvas.Canvas("barcode_example.pdf",pagesize=A4)
# create a barcode object
# (is not displayed yet)
@tito
tito / bluetooth.py
Created November 12, 2013 15:28
Bluetooth example on Android using Python / Pyjnius
'''
Bluetooth/Pyjnius example
=========================
This was used to send some bytes to an arduino via bluetooth.
The app must have BLUETOOTH and BLUETOOTH_ADMIN permissions (well, i didn't
tested without BLUETOOTH_ADMIN, maybe it works.)
Connect your device to your phone, via the bluetooth menu. After the
pairing is done, you'll be able to use it in the app.
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active May 4, 2024 21:33
A badass list of frontend development resources I collected over time.
@miguelgrinberg
miguelgrinberg / rest-server.py
Last active March 29, 2024 09:05
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask_httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@arunkjn
arunkjn / index.html
Last active July 31, 2020 08:48
Multiple polygons with d3.js
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: auto;
position: relative;
width: 960px;
}