Skip to content

Instantly share code, notes, and snippets.

Eyal Arubas EyalAr

Block or report user

Report or block EyalAr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@EyalAr
EyalAr / count_words_in_selection.py
Last active Aug 4, 2019
Count words in selection - plugin for Sublime Text 3. Full blog post: http://eyalarubas.com/count-words-in-sublime-text-3.html
View count_words_in_selection.py
import sublime, sublime_plugin, re
class CountWordsInSelectionCommand(sublime_plugin.EventListener):
def on_selection_modified(self, view):
'''
listen to event 'on_selection_modified' and count words in all selected
regions when invoked.
'''
@EyalAr
EyalAr / hello_world_opencv.cpp
Created Oct 23, 2012
Hello World in OpenCV
View hello_world_opencv.cpp
#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;
int main(int argc, char** argv) {
//create a gui window:
namedWindow("Output",1);
@EyalAr
EyalAr / client.py
Created Dec 11, 2013
Demo code for my post about python's blocking stream reading functions.
View client.py
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)
@EyalAr
EyalAr / registerS3ProtocolStreamWrapper.php
Last active Jan 29, 2019
Registering and using S3 protocol with AWS S3 stream wrapper for PHP
View registerS3ProtocolStreamWrapper.php
<?php
define('AWS_KEY','YOUR_AWS_KEY_HERE');
define('AWS_SECRET','YOUR_AWS_SECRET_HERE');
require_once('AWSSDKforPHP/sdk.class.php');
require_once('AWSSDKforPHP/extensions/s3streamwrapper.class.php');
$s3 = new AmazonS3(array(
'key' => AWS_KEY,
@EyalAr
EyalAr / gist:3018471
Created Jun 29, 2012
An explanation + examples about Java generics and bounded wildcards.
View gist:3018471
/**
* Java Generics, Wildcards and Bounded Wildcards.
*
* ...Can be confusing. Here's a small explanation + examples.
*/
import java.util.LinkedList;
import java.util.List;
/**
@EyalAr
EyalAr / ExtractEigenfaces.m
Last active Aug 17, 2017
Matlab script which extracts to files the eigenfaces of a set of face images.
View ExtractEigenfaces.m
% Extract the eigen-faces of a set of face images.
start_index = 1;
end_index = 10;
base_name = '';
extension = '.jpg';
in_dir = 'in';
out_dir = 'ef';
images = [];
@EyalAr
EyalAr / InitPersonRecognizer.cpp
Last active Dec 1, 2016
Code snippets for my OpenCV face recognition tutorial, in which I show how to build an application which recognizes a specific person in a video. Full code at: https://bitbucket.org/EyalAr/person-recognizer
View InitPersonRecognizer.cpp
#define PERSON_LABEL = 10 //some arbitrary label
//LBPH face recognizer parameters:
#define RADIUS 1
#define NEIGHBORS 8
#define GRID_X 8
#define GRID_Y 8
#define THRESHOLD 130.0
//create a LBPH face recognizer model:
@EyalAr
EyalAr / CsvWriter.hpp
Last active Dec 15, 2015
Code samples for my face detection and recognition with OpenCV tutorial. http://blog.eyalarubas.com/2013/03/14/face-detection-and-recognition-theory-and-practice/
View CsvWriter.hpp
class CsvWriter {
public:
CsvWriter(const string &csvPath);
virtual ~CsvWriter();
void nextLine();
void addEntry(const string &s);
private:
ofstream _fs;
bool _isFirstEntry;
};
@EyalAr
EyalAr / README.md
Last active Aug 29, 2015
Benchmarks of various nested loops control flow mechanisms in Javascript
View README.md

MDN recommends NOT to use labels in Javascript, and instead use exceptions or functions. But turns out labels are the fastest, closely followed by named functions.

Test case: Run two nested loops. The inner loop needs to continue the outer loop upon some condition.

Tests:

  1. Using named loops with labels.
@EyalAr
EyalAr / README.md
Last active Aug 29, 2015
TroopJS data-weave inside template bug - multiple widget instances are created for elements
View README.md

To run:

  1. Clone this gist
  2. bower install
  3. Serve index.html
  4. Open developer tools inspector
  5. First <li> element has 4 widget instances attached; second had 3, etc.
You can’t perform that action at this time.