Skip to content

Instantly share code, notes, and snippets.

View Lukse's full-sized avatar

Saulius Lukse Lukse

View GitHub Profile
@Lukse
Lukse / gist:5194355
Created March 19, 2013 07:41
Flash Carambola via sysupgrade
scp test@192.168.0.105:/home/test/carambola/bin/ramips/openwrt-ramips-rt305x-carambola-squashfs-sysupgrade.bin /tmp
sysupgrade -v -n /tmp/openwrt-ramips-rt305x-carambola-squashfs-sysupgrade.bin
@Lukse
Lukse / dropbox_action.sh
Last active December 18, 2015 00:49
Control remote Linux computer using DropBox (adapted for Carambola)
#!/bin/bash
# Prepare
# Install dropbox_iploader.sh script from https://github.com/andreafabrizi/Dropbox-Uploader
# Add [* * * * * /usr/bin/dropbox_action.sh] to crontab
# Usage
# Create file /remote/input.txt un your dropbox folder
# Put single line in this file to run in remote Caramola (without new line)
# Read result after minute or so in output.txt file
@Lukse
Lukse / execution_folders.py
Last active August 29, 2015 14:01
Get execution directory
import os
def execution_directory():
exec_place = os.getcwd()
script_place = os.path.dirname(os.path.realpath(__file__))
arguments_place = str(sys.argv[0])
arguments_place = ("\\").join(arguments_place.split('\\')[0:-1])
return exec_place, script_place, arguments_place
print execution_folders()
import os
import fnmatch
def recursive_glob(treeroot, pattern):
results = []
for base, dirs, files in os.walk(treeroot):
goodfiles = fnmatch.filter(files, pattern)
results.extend(os.path.join(base, f) for f in goodfiles)
return results
@Lukse
Lukse / gist:8634d9544c67ee0d8c18
Created May 29, 2014 06:07
Count number of times value appears in particular column in MySQL
-- Duomenys:
-- zigmas
-- zigmas
-- petras
-- Rezultatai:
-- zigmas 2
-- petras 1
select name, count(*) as n FROM orders order by n GROUP BY name
def dict2obj(d):
if isinstance(d, list):
d = [dict2obj(x) for x in d]
if not isinstance(d, dict):
return d
class C(object):
pass
o = C()
for k in d:
o.__dict__[k] = dict2obj(d[k])
@Lukse
Lukse / detect.py
Last active October 22, 2018 07:13
Advanced OpenCV 3 python hole detection
import cv2
import sys
import numpy as np
camera = cv2.VideoCapture("video.avi")
# Setup BlobDetector
detector = cv2.SimpleBlobDetector_create()
params = cv2.SimpleBlobDetector_Params()
@Lukse
Lukse / animated_gif.py
Last active July 25, 2016 06:32
Making animated GIF’s
from moviepy.editor import *
start = 0.0
end = 10.0
width = 500
fps = 20
speedx = 2
file_in = "video.avi"
file_out = "img.gif"
@Lukse
Lukse / detect_blur.py
Created July 25, 2016 16:09
OpenCV 3 Python blur detection
import cv2
from tqdm import trange
cap = cv2.VideoCapture('10.avi')
f = open('results.txt', 'w')
frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
for i in trange(frame_count, unit=' frames', leave=False, dynamic_ncols=True, desc='Calculating blur ratio'):
@Lukse
Lukse / pyqt_opencv.py
Last active January 20, 2021 07:54
OpenCV USB camera object in PyQT
# -*- coding: utf-8 -*-
__author__ = "Saulius Lukse"
__copyright__ = "Copyright 2016, kurokesu.com"
__version__ = "0.1"
__license__ = "GPL"
from PyQt4 import QtCore, QtGui, uic
import sys