Skip to content

Instantly share code, notes, and snippets.

@ssbozy
ssbozy / flashtext_regex_timing_keyword_replace.py
Created November 25, 2017 18:52 — forked from vi3k6i5/flashtext_regex_timing_keyword_replace.py
Benchmarking timing performance Keyword Replace between regex and flashtext
#!/bin/python
from flashtext.keyword import KeywordProcessor
import random
import string
import re
import time
def get_word_of_length(str_length):
# generate a random word of given length
@ssbozy
ssbozy / CircularBuffer.py
Created December 1, 2017 15:18
Circular Buffer
class CircularBuffer(object):
def __init__(self, buffersize):
self.buffer = []
self.buffersize = buffersize
self.capacity = len(self.buffer)
def __repr__(self):
return '<CircularBuffer({0})>'.format(self.buffer)
# USAGE
# python detect_blur.py --images images
# import the necessary packages
from imutils import paths
import argparse
import cv2
def variance_of_laplacian(image):
# compute the Laplacian of the image and then return the focus

Keybase proof

I hereby claim:

  • I am ssbozy on github.
  • I am ssbozy (https://keybase.io/ssbozy) on keybase.
  • I have a public key ASASFJaNN_SP7cV1ie1XtSANnO3hU_spmXMlIWGj58l5cQo

To claim this, I am signing this object:

@ssbozy
ssbozy / schematest.py
Created March 22, 2018 18:29
python json-schema testing
import jsonschema
import sys
# A sample schema, like what we'd get from json.load()
schema = {
"type" : "object",
"properties" : {
"price" : {"type" : "number"},
"name" : {"type" : "string"},
"details":{
"\e[A": history-search-backward
"\e[B": history-search-forward
set completion-ignore-case on
set show-all-if-ambiguous on
TAB: menu-complete
@ssbozy
ssbozy / ubuntu update.txt
Created November 19, 2018 02:26
This is a test for ubuntu
sudo apt-get clean
sudo apt-get update
@ssbozy
ssbozy / py_aco_swatch_parser.py
Last active November 21, 2018 07:30
Dribble ACO File Parser in Python 2.7
import struct
class ColorSwatch():
def __init__(self, fp):
self.rawdata = struct.unpack(">5H",fp.read(10))
print self.rawdata
namelen, = struct.unpack(">I",fp.read(4))
cp = fp.read(2*namelen)
self.name = cp[0:-2].decode('utf-16-be')
self.typename = self.colorTypeName()
@ssbozy
ssbozy / dribbble_aco_parser.py
Created November 30, 2018 04:32
Dribbble ACO file parser
import struct
import requests
class ColorSwatch():
def __init__(self, fp):
self.rawdata = struct.unpack(">5H",fp.read(10))
namelen, = struct.unpack(">I",fp.read(4))
cp = fp.read(2*namelen)
self.name = cp[0:-2].decode('utf-16-be')
self.typename = self.colorTypeName()
@ssbozy
ssbozy / currency_change_calculator.py
Last active December 13, 2018 18:17
Currency Calculator
import sys
class CurrencyCalculator:
def __init__(self, check_cash):
self.check_cash = check_cash
# base_cash should be sorted list with highest currency denomination to lowest
self.base_cash = [100, 50, 20, 10, 5, 1]
self.result = self._breakdown()