Skip to content

Instantly share code, notes, and snippets.

@grk
grk / grapher.rb
Created March 24, 2009 22:18
Graphs with Sinatra and Scruffy
require 'rubygems'
require 'sinatra'
require 'scruffy'
require 'md5'
get '/' do
'This is Grapher.'
end
get '/graph/?' do
require 'thread'
class ReadWriteLock
def initialize
@critical_section = Mutex.new
@are_writers_finished = ConditionVariable.new
@are_readers_finished = ConditionVariable.new
@readers = 0
@writers = 0
@writer_locked = false
#ifndef __semaphore_t_h__
#define __semaphore_t_h__
#ifdef __APPLE__
#include <mach/mach_init.h>
#include <mach/task.h>
#include <mach/semaphore.h>
class semaph_t
@grk
grk / main.c
Created February 7, 2011 09:55
~/Work/uni/padp/lists(master*) $ ./test
[==========] Running 5 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 5 tests from linked_list_test
[ RUN ] linked_list_test.is_empty_initially
[ OK ] linked_list_test.is_empty_initially (0 ms)
[ RUN ] linked_list_test.add_element
[ OK ] linked_list_test.add_element (0 ms)
[ RUN ] linked_list_test.add_exisiting_element
[ OK ] linked_list_test.add_exisiting_element (0 ms)
/*
* Copyright 1993-2006 NVIDIA Corporation. All rights reserved.
*
* NOTICE TO USER:
*
* This source code is subject to NVIDIA ownership rights under U.S. and
* international Copyright laws.
*
* This software and the information contained herein is PROPRIETARY and
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
#ifndef __fine_linked_list_hpp__
#define __fine_linked_list_hpp__
#include "linked_list.hpp"
using namespace std;
template <typename T>
class fine_linked_list : public linked_list<T>
{
#ifndef __fine_linked_list_hpp__
#define __fine_linked_list_hpp__
#include "linked_list.hpp"
using namespace std;
template <typename T>
class fine_linked_list : public linked_list<T>
{
@grk
grk / github_projects.rb
Created May 7, 2011 10:30
Github repos in Jekyll
require 'octokit'
module Jekyll
class ProjectsIndex < Page
def initialize(site, base, projects_dir)
@site = site
@base = base
@dir = projects_dir
@name = 'index.html'
photos.each do |photo|
photo.position = params[:photo].index(photo.id.to_s)
end
@grk
grk / config_initializers_sass.rb
Created May 30, 2011 07:33
Sass load paths Rails 3.1
Sass::Engine::DEFAULT_OPTIONS[:load_paths].tap do |load_paths|
load_paths << "#{Rails.root}/app/assets/stylesheets"
load_paths << "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets"
load_paths << "#{Gem.loaded_specs['html5-boilerplate'].full_gem_path}/stylesheets"
load_paths << "#{Gem.loaded_specs['fancy-buttons'].full_gem_path}/lib/stylesheets"
end