Skip to content

Instantly share code, notes, and snippets.

# Written by Aaron Cohen -- 1/14/2013
# Brought to you by BitTorrent, Inc.
# "We're not just two guys in a basement in Sweden." TM
#
# This work is licensed under a Creative Commons Attribution 3.0 Unported License.
# See: http://creativecommons.org/licenses/by/3.0/
import sys
import re
import socket
@gylns
gylns / client.py
Created July 28, 2018 23:19 — forked from EyalAr/client.py
Demo code for my post about python's blocking stream reading functions.
from subprocess import Popen, PIPE
from time import sleep
# run the shell as a subprocess:
p = Popen(['python', 'shell.py'],
stdin = PIPE, stdout = PIPE, stderr = PIPE, shell = False)
# issue command:
p.stdin.write('command\n')
# let the shell output the result:
sleep(0.1)
#include "mser.hpp"
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <vector>
#include <iostream>
using namespace std;
using namespace cv;
vector<Point> selectPoints(const String &video_name, const Mat &frame)
#!/bin/bash
sudo apt-get install isc-dhcp-server -y
set interfaces
set addresses
set ip
# Find network interfaces
function find_interfaces()
{
local ip_result=$(ip link | awk '{print $2}')
ip_result=($ip_result)
// from http://stackoverflow.com/questions/800383/what-is-the-difference-between-mutex-and-critical-section
// a performance testing between mutex and CRITICAL_SECTION on windows
HANDLE mutex = CreateMutex(NULL, FALSE, NULL);
CRITICAL_SECTION critSec;
InitializeCriticalSection(&critSec);
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
LARGE_INTEGER start, end;
@gylns
gylns / grub.md
Last active October 17, 2016 08:18

livecd

probe -u root
set timeout=10
set default=0

menuentry "Run Ubuntu Live ISO" {
 set isofile=/ISO/ubuntu-16.04-desktop-amd64.iso
 loopback loop ${isofile}
// from mathfuncs_core.cpp of opencv
void fastAtan2(const float *Y, const float *X, float *angle, int len, bool angleInDegrees )
{
int i = 0;
float scale = angleInDegrees ? 1 : (float)(CV_PI/180);
for( ; i < len; i++ )
{
float x = X[i], y = Y[i];
float ax = std::abs(x), ay = std::abs(y);
{
"type": "resolver",
"ns": "nonymous",
"author": "gyl",
"prefix": "batch downloader for wiley ebooks",
"match": "^http://onlinelibrary\\.wiley\\.com/.*/pdf$",
"static": true,
"finder": "src=\"([^\"]*\\.pdf[^\"]*)\"",
"builder": "{1}"
}
{
"type": "resolver",
"ns": "nonymous",
"author": "gyl",
"prefix": "batch downloader for International Press",
"match": "^http://intlpress\\.com/.*/body\\.html",
"static": true,
"finder": "href=\"(.+pdf)\"",
"builder": "{1}"
}
//sorting points by clockwise using cross product
//see <http://stackoverflow.com/questions/6989100/sort-points-in-clockwise-order>
bool less(point a, point b)
{
if (a.x - center.x >= 0 && b.x - center.x < 0)
return true;
if (a.x - center.x < 0 && b.x - center.x >= 0)
return false;
if (a.x - center.x == 0 && b.x - center.x == 0) {
if (a.y - center.y >= 0 || b.y - center.y >= 0)