Skip to content

Instantly share code, notes, and snippets.

View itarato's full-sized avatar

Peter Arato itarato

  • Montreal, Canada
  • 14:33 (UTC -03:00)
View GitHub Profile
@itarato
itarato / mod_timing.c
Last active April 3, 2017 03:03
An Apache2 module to log request times.
#include "httpd.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_request.h"
#include <time.h>
#include <syslog.h>
/**
* Definitions.
@itarato
itarato / ttymindmap.rb
Created March 7, 2017 04:18
Command line mindmap app
# Usage:
# - Start new mindmap:
# `ruby ttymindmap.rb`
# - Open Freemind format MM mindmap:
# `ruby ttymindmap.rb <PATH-TO-MM-FILE>`
#
# Press `h` key when running for help.
require 'nokogiri'
@itarato
itarato / maze.rb
Created February 1, 2017 19:18
Maze generator
EMPTY = 0x0
UP = 0x1
RIGHT = 0x2
DOWN = 0x4
LEFT = 0x8
# Maze generator class.
class Generator
def initialize(w, h)
@itarato
itarato / json_concurrent.rs
Created January 14, 2017 20:03
Example of a concurrent (simplified) JSON parser
use std::collections::HashMap;
use std::thread::{self, sleep};
use std::time;
use std::sync::{mpsc, Arc};
macro_rules! char_token {
($c:expr, $t:ident) => ({
let mut value = String::new();
value.push($c);
Some(Token{ttype: TokenType::$t, value:value})
@itarato
itarato / chip8.py
Created December 31, 2016 04:12
Chip8 emulator.
"""
Chip8 emulator.
"""
import array
import random
import pygame
# 4K.
@itarato
itarato / threaded_qs.java
Created December 15, 2016 17:03
Multithreaded quick sort - attempt
package com.company;
class QuickSortThreaded {
private int[] l;
QuickSortThreaded(int[] l) {
this.l = l;
long start = System.nanoTime();
new Sorter(l, 0, l.length - 1).sort(0, l.length - 1);
@itarato
itarato / wake_queue.go
Created December 9, 2016 08:14
Queue that can handle pop wait.
package main
import (
"fmt"
"sync"
"time"
)
type ElemType int32
@itarato
itarato / debug_dom_class.js
Created September 15, 2016 11:46
DOM subtree class toggling debugger
(function () {
'use strict';
console.log('Debug has started.');
var $base = jQuery('<SELECTOR>');
var list = traverse($base[0]);
var classes = [];
var element = null;
@itarato
itarato / bigint.cpp
Created September 15, 2016 05:11
Simple C++ big integer class
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
#define GROUP_DEC_SIZE 4
class BigInt {
private:
@itarato
itarato / game_of_life.cpp
Created September 1, 2016 18:03
Game of life
#include <iostream>
#include <chrono>
#include <thread>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
#define W 120