Skip to content

Instantly share code, notes, and snippets.

View fernandomv3's full-sized avatar

Fernando Moreno Valles fernandomv3

View GitHub Profile
@fernandomv3
fernandomv3 / code39.py
Last active June 20, 2017 19:06
Generate Code39 Barcodes with Python3 & Pillow
#!/usr/bin/env python
from PIL import Image, ImageFont, ImageDraw
def code39(filepath=".", text="", size=200, orientation="horizontal", printText=False, sizeFactor=8):
code_dict = {"0":"111221211","1":"211211112","2":"112211112","3":"212211111","4":"111221112","5":"211221111","6":"112221111","7":"111211212","8":"211211211","9":"112211211","A":"211112112","B":"112112112","C":"212112111","D":"111122112","E":"211122111","F":"112122111","G":"111112212","H":"211112211","I":"112112211","J":"111122211","K":"211111122","L":"112111122","M":"212111121","N":"111121122","O":"211121121","P":"112121121","Q":"111111222","R":"211111221","S":"112111221","T":"111121221","U":"221111112","V":"122111112","W":"222111111","X":"121121112","Y":"221121111","Z":"122121111","-":"121111212",".":"221111211"," ":"122111211","$":"121212111","/":"121211121","+":"121112121","%":"111212121","*":"121121211"}
upper_text = text.upper()
code_string = ''.join([code_dict[c] + "1" for c in upper_text])
code_string = "1211212111" + code_stri
@fernandomv3
fernandomv3 / split_csv.py
Last active April 19, 2016 13:27
Split a CSV file in almost uniform line numbers
#!/usr/bin/env python
from __future__ import print_function, division
import sys
import math
def main(argv):
if len(argv) < 3:
print("Usage: split_csv.py filename N")
print("filename: File to be split")
@fernandomv3
fernandomv3 / UUID.hpp
Last active February 11, 2021 23:43
C++ UUID generator
#ifndef UUID_H
#define UUID_H
#include <string>
#include <cstdlib>
//*Adapted from https://gist.github.com/ne-sachirou/882192
//*std::rand() can be replaced with other algorithms as Xorshift for better perfomance
//*Random seed must be initialized by user