Skip to content

Instantly share code, notes, and snippets.

View vipul-sharma20's full-sized avatar
💭
doin werrk

Vipul vipul-sharma20

💭
doin werrk
View GitHub Profile
@vipul-sharma20
vipul-sharma20 / tesseract.py
Last active January 31, 2017 20:33
very minimal tesseract's python wrapper (requires Python 3.6+)
# Segmentation modes
OSD = 0 # OSD only
AUTOMATIC_OSD = 1 # Automatic page segmentation with OSD
AUTOMATIC_NO_OSD = 2 # Automatic page segmentation, but no OSD, or OCR
DEFAULT = 3 # Fully automatic page segmentation, but no OSD. (Default)
BLOCK_VERTICAL_VARIABLE = 4 # Assume a single column of text of variable sizes.
BLOCK_VERTICAL_UNIFORM = 5 # Assume a single uniform block of vertically aligned text.
BLOCK_SINGLE = 6 # Assume a single uniform block of text.
SINGLE_LINE = 7 # Treat the image as a single text line.
SINGLE_WORD = 8 # Treat the image as a single word.
@vipul-sharma20
vipul-sharma20 / bluetooth-a2dp
Last active September 17, 2017 14:15 — forked from ragusa87/bluetooth-a2dp
Enable bluetooth A2DP on Raspberry-PI via pulseaudio.To install, edit /etc/udev/rules.d/99-input.rules and add the line:SUBSYSTEM=="bluetooth", RUN+="/usr/lib/udev/bluetooth"Then save this script as /usr/lib/udev/bluetooth and set it executable.Bluetooth devices must be linked first.
#!/bin/bash
# This script is called by udev when you link a bluetooth device with your computer
# It's called to add or remove the device from pulseaudio
#
#
# Output to this file
LOGFILE="/var/log/bluetooth_dev"
# Name of the local sink in this computer
def p_decorate(func):
def func_wrapper(name):
return "<p>{0}</p>".format(func(name))
return func_wrapper
@p_decorate
def get_text(name):
return "lorem ipsum, {0} dolor sit amet".format(name)
print get_text("Vipul")
# borrowed this example from http://thecodeship.com/patterns/guide-to-python-function-decorators/
def get_text(name):
return "lorem ipsum, {0} dolor sit amet".format(name)
def p_decorate(func):
def func_wrapper(name):
return "<p>{0}</p>".format(func(name))
return func_wrapper
my_get_text = p_decorate(get_text)
@vipul-sharma20
vipul-sharma20 / nested.py
Created March 26, 2016 05:12
Python's nest
def wrapper():
wrapper_a = 10
def inner():
print wrapper_a
return inner
wrapper()
"""
Output:
10
@vipul-sharma20
vipul-sharma20 / python_objects.py
Last active March 25, 2016 16:27
Objects everywhere
>>> a = 10
>>> a.__class__
<type 'int'>
>>>
>>>
>>> '10'.__class__
<type 'str'>
>>>
>>>
>>>True.__class__