This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int fd; | |
| char * mapped_memory; | |
| /** | |
| * Open a file and map it to memory, | |
| * once it is mapped to memory we can close | |
| * the file because we have access. | |
| */ | |
| fd = open(argv[1], O_RDWR | O_CREAT); | |
| mapped_memory = mmap(NULL, MAX, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int pfds[2]; | |
| int SIZE = 30; | |
| char buf[SIZE]; | |
| char * msg = "This is a pipe example!"; | |
| /** Generates two pipe file descriptors **/ | |
| pipe(pfds); | |
| /** writer **/ | |
| if (!fork()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Creates fifo */ | |
| mkfifo(argv[1], S_IRWXU | S_IRWXG | S_IRWXO); | |
| int fifo = open(argv[1], O_RDONLY); | |
| /* Duplicate the file 'fifo', so that file descriptor 0 points to it. | |
| * Note that 0 is the file descriptor of stdin. */ | |
| dup2(fifo, 0); | |
| char line[1024]; | |
| int i = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "image" | |
| "image/color" | |
| "image/draw" | |
| "image/png" | |
| "code.google.com/p/draw2d/draw2d" | |
| "log" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Producer-Comsumer example, written in C++ May 4, 2014 | |
| * Compiled on OSX 10.9, using: | |
| * g++ -std=c++11 producer_consumer.cpp | |
| **/ | |
| #include <iostream> | |
| #include <thread> | |
| #include <mutex> | |
| #include <condition_variable> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Semaphore example, written in C++ May 4, 2014 | |
| * Compiled on OSX 10.9, using: | |
| * g++ -std=c++11 semaphore.cpp | |
| **/ | |
| #include <iostream> | |
| #include <thread> | |
| #include <mutex> | |
| #include <condition_variable> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def func1(x, y): | |
| return x*x + x*y + y*y | |
| def func2(y, x): | |
| return x**3 + y**3 + y*x**2 + y**2 + 2 | |
| def monte(func, n, ymin, ymax, xmin, xmax): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* version 2.4 of openCV */ | |
| using namespace cv; | |
| /** | |
| * Takes in a RGB image and outputs | |
| * a Lab space image. | |
| **/ | |
| Mat BGR2LAB(Mat const &imgRGB){ | |
| Mat imgLab; | |
| cvtColor(imgRGB, imgLab, CV_RGB2Lab); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Description: | |
| * Finds the gradient between two images, searches the Red channel in RGB | |
| * | |
| * @param: img - image to find gradient on | |
| * @param: prune - the cut off for the pruning (difference between two steps | |
| * @param: step - How many pixels apart to check | |
| * @Return: Mat grad - the image with gradients colored | |
| **/ | |
| Mat findGradient(Mat &img, unsigned int prune, unsigned int step){ |