Skip to content

Instantly share code, notes, and snippets.

View mlashcorp's full-sized avatar

José Côrte-Real mlashcorp

View GitHub Profile
@mlashcorp
mlashcorp / big-o.md
Created November 5, 2022 05:50 — forked from PJUllrich/big-o.md
Big-O Time Complexities for Elixir Data Structures

Big-O Time Complexities for Elixir data structures

Map [1]

Operation Time Complexity
Access O(log n)
Search O(log n)
Insertion O(n) for <= 32 elements, O(log n) for > 32 elements [2]
Deletion O(n) for <= 32 elements, O(log n) for > 32 elements
######################################################################
##
## Feature Broker
##
######################################################################
class FeatureBroker:
def __init__(self, allowReplace=False):
self.providers = {}
self.allowReplace = allowReplace
@mlashcorp
mlashcorp / gist:6234668
Created August 14, 2013 19:30
Python: discover ip address of interface that has internet accessibility (in case there are many)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("gmail.com",80))
print(s.getsockname()[0])
s.close()
@mlashcorp
mlashcorp / gist:4462330
Created January 5, 2013 16:24
Android accelerometer polling, just the creation and update portions. Updated the class to implement SensorEventListener, since SensorListener is deprecated
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sm = (SensorManager) getSystemService(SENSOR_SERVICE);
accell = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
setContentView(R.layout.activity_main);
xacc = (TextView) findViewById(R.id.xvalue);
yacc = (TextView) findViewById(R.id.yvalue);
zacc = (TextView) findViewById(R.id.zvalue);
@mlashcorp
mlashcorp / eq_hist.cpp
Created January 19, 2012 19:06
equalize color image histogram
std::vector<cv::Mat> planes;
cv::cvtColor(mat, sharp_mat, CV_BGR2HSV);
cv::split(sharp_mat, planes);
cv::equalizeHist(planes[2], planes[2]);
cv::merge(planes, sharp_mat);
cv::cvtColor(sharp_mat, mat, CV_HSV2BGR);
@mlashcorp
mlashcorp / unsharp_mask.cpp
Created January 19, 2012 16:52
opencv documentation description of unsharp mask algorithm
// sharpen image using "unsharp mask" algorithm
Mat blurred; double sigma = 1, threshold = 5, amount = 1;
GaussianBlur(img, blurred, Size(), sigma, sigma);
Mat lowConstrastMask = abs(img - blurred) < threshold;
Mat sharpened = img*(1+amount) + blurred*(-amount);
img.copyTo(sharpened, lowContrastMask);
@mlashcorp
mlashcorp / version-string
Created August 29, 2011 10:24
Implements a version string with svn revision preprocessor macro
#define VERSION "1.2.0 - development - COMMIT: $Revision: 17 $"
@mlashcorp
mlashcorp / svn-propset
Created August 29, 2011 10:22
svn propset
svn propset svn:keywords 'Id Revision' target-source-file
@mlashcorp
mlashcorp / generate_barcode.sh
Created April 14, 2011 09:57
Basic example of how to generate a code 128 barcode
barcode -b 0401001702201100 -e 128 -u mm -g 50x20 -o teste
@mlashcorp
mlashcorp / burn_data.py
Created March 24, 2011 14:06
Method to interact with cdrecord
import subprocess
def burn_data(self,PATH):
dir,file = (os.path.split(PATH))
#unmount disc just in case (shouldn't be necessary for a blank disk)
p0 = Popen(["umount","/media/CDROM"],stdout=subprocess.PIPE, stderr=subprocess.PIPE)
#wait for unmount
p0.wait()
#create the isofs raw image to write to cd
p1 = Popen(["mkisofs","-R","-o","image.raw",PATH],stdout=subprocess.PIPE, stderr=subprocess.PIPE)