Skip to content

Instantly share code, notes, and snippets.

View connors511's full-sized avatar

Matthias Larsen connors511

  • Gentofte, Denmark
View GitHub Profile
for (i = 0; i < LENGTH(iImage->Pixels); i++)
{
pixel = pos = 0;
for (row = -(m - 1)/2.0; row <= (m - 1)/2.0; row++)
{
for (col = -(m - 1)/2.0; col <= (m - 1)/2.0; col++)
{
pos = i + row * iImage->Width + col;
if (pos >= 0 && pos <= lastPixel) // Check for top and bottom
BOOL filter_2DConvolution(IMAGE* iImage, IMAGE* oImage, int F[3][3]) {
int i, row, col; // counters
int m = 3;
int normalization = 0;
int pixel, pos;
int lastPixel = iImage->Width * iImage->Height - 1;
printf("Filter:\n %d %d %d\n %d %d %d\n %d %d %d\n",
F[0][0], F[0][1], F[0][2],
F[1][0], F[1][1], F[1][2],
#ifdef DEBUG
printf("Image compression: RLE8\n");
printf("Bit offset: %d\n", bmfh.BfOffBits);
#endif
i = 0;
while(1) {
fread(&pixels, sizeof(BYTE), 1, fp);
fread(&color, sizeof(BYTE), 1, fp);
if ( pixels != 0x00 ) // escape char?
#ifdef DEBUG
printf("Image compression: RLE8\n");
printf("Bit offset: %d\n", bmfh.BfOffBits);
#endif
i = 0;
while(1) {
fread(&pixels, sizeof(BYTE), 1, fp);
fread(&color, sizeof(BYTE), 1, fp);
if ( pixels != 0x00 ) // escape char?
BOOL bmp_open(char* file, IMAGE* image) {
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER bmih;
unsigned int rowSize, i, totalPixels = 0;
BYTE blue, green, red;
/* note: "rb" means open for binary read */
FILE* fp = fopen(file, "rb");
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define LENGTH(x) (sizeof(x)/sizeof(*(x)))
//static int[] numbers = { 49, 82, 96, 21, 81, 38, 7, 79, 32, 39, 94, 74, 70, 45, 8, 25, 86, 48, 85, 14, 6, 18, 48, 76, 2, 79, 17, 68, 62, 20 };
//static int[] numbers = { 7678, 3701, 2012, 7339, 6890, 1413, 2878, 3109, 2520, 579, 5047, 1562, 2986, 7638, 5555 };
//static int[] numbers = { 3, 1, 4, 3 };
typedef struct {
public class Number : IComparable
{
public Number num1;
public int num2;
public int base1;
public int base2;
public int val;
public Number(Number num1, int num2)
{
@connors511
connors511 / gist:2790193
Created May 25, 2012 19:53
scraper.php
<?php
/**
*
* @author Matthias
*/
abstract class Scraper
{
// Name of the scraper
@connors511
connors511 / gist:2790194
Created May 25, 2012 19:54
scraper_imdb
<?php
/**
* Some methods might fail due to pcre.backtrack_limit when using preg_match_all
*/
class Scraper_Imdb extends Scraper
{
protected $_urls = array(
'main' => 'http://www.imdb.com/title/%s/combined',
/** Controller_Base **/
public function set_pagination($url, $segment, $total_items, $per_page = 20)
{
Pagination::set_config(array(
'pagination_url' => $url,
'uri_segment' => $segment,
'total_items' => $total_items,
'per_page' => $per_page,
'template' => array(
'wrapper_start' => '<ul class="pager">',