Skip to content

Instantly share code, notes, and snippets.

View vaclavbohac's full-sized avatar

Vaclav Bohac vaclavbohac

View GitHub Profile
@vaclavbohac
vaclavbohac / ExampleDataPanel.php
Created August 31, 2010 12:17
Primitive Nette Panel for installing sample data
<?php
class ExampleDataPanel extends Object implements IDebugPanel
{
protected static $registered;
public function getId()
{
@vaclavbohac
vaclavbohac / roman.py
Created September 14, 2010 11:29
Scripting languages homework
#!/usr/bin/env python
def to_roman(num):
# is input between 0 and 4000?
if not 0 < int(num) < 4000: return False
length = len(num)
res = ''
for s in num:
# get dictionary for current word length
@vaclavbohac
vaclavbohac / sizes.java
Created January 5, 2011 13:42
This program prints sizes in bytes of primitive types in java.
/**
* @author Vaclav Bohac
* This program shows size of memory allocated by
* JVM for primitive types.
*/
import java.lang.reflect.Field;
public class sizes {
@vaclavbohac
vaclavbohac / primes.js
Created January 22, 2011 14:06
Testing program for node.js
/**
* Simple testing program for node.js.
* Prints prime numbers up to 10000.
* @author Vaclav Bohac (c) 2011
*/
(function (sys) {
var i = 2,
isPrime = function () {
var j = 2
@vaclavbohac
vaclavbohac / liveoncouch.js
Created January 22, 2011 15:23
This script for nodejs tests if couchdb server is running.
/**
* Test if couchdb is live.
* possible@usage:~$ nodejs liveoncouch.js --hostname 192.168.0.32 --port 5982
* @author Vaclav Bohac (c) 2011
*/
(function (util, http) {
var getArguments = function () {
var ret = {
@vaclavbohac
vaclavbohac / scaf.sh
Created January 30, 2011 17:49
Stupid model scaffolding for Nette Framework.
#!/bin/bash
# Generate model class and SQL.
# This bash script gives you some functionality similiar to rails scaffolding.
# It creates:
# - a file with model class
# - a file with SQL to create table with that model
# - a rollback file with SQL to drop that table
# Created by Vaclav Bohac (c) 2011.
@vaclavbohac
vaclavbohac / yepnope-example.html
Created March 5, 2011 12:55
Example of asynchronous loading of JS app.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8"/>
<title>Testing of asynchronous loading</title>
<script src="js/yepnope.1.0.0-min.js"></script>
<script>
(function (global, doc) {
global.MyApp = {
@vaclavbohac
vaclavbohac / strict-inheritance.js
Created March 11, 2011 16:45
Trying to sort out ES5 Object.create & Strict mode in FF4.
(function (global, doc) {
"use strict";
var Person, Employee, Manager;
Person = {
firstName: null,
lastName: null
};
@vaclavbohac
vaclavbohac / gmaps.js
Created March 14, 2011 22:14
New version of the Gmaps client side script.
/**
* Copyright 2010 Bohac Vaclav
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@vaclavbohac
vaclavbohac / Semaphores.cpp
Created March 22, 2011 09:22
IPC critical sections with semaphores.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>