Skip to content

Instantly share code, notes, and snippets.

@pazdera
pazdera / getopt.c
Created November 25, 2010 23:52
Getopt example from manual
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
int flags, opt;
int nsecs, tfnd;
nsecs = 0;
PATH="$PATH":/home/astro/bin
export PATH
@pazdera
pazdera / gist:1086088
Created July 16, 2011 06:57
Bash getopts example
#!/bin/bash
# Example of using bash-builtin getopts to parse script arguments
# Copyright (C) 2011 Radek Pazdera
# This program 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 3 of the License, or
# (at your option) any later version.
@pazdera
pazdera / gist:1097711
Created July 21, 2011 17:32
Class example in Python (compared to C++)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Class example in Python (compared to C++)
class Class:
__privateMember = 1
_protectedMember = 2
publicMember = 3
@pazdera
pazdera / gist:1146033
Created August 15, 2011 10:56
References for Wordpress.com
<!-- Reference -->
<sup>[<a href="#sources">1</a>]</sup>
<!-- Sources -->
<h2 id="sources">Sources</h2>
<ol>
<li>ref</li>
</ol>
@pazdera
pazdera / limits.c
Created February 15, 2012 21:09
Size of some integer types
/* Integer types -- sizes */
#include <stdio.h>
#include <stdint.h>
int main(void)
{
printf("int bytes: %d\n", sizeof(int));
printf("uint32_t bytes: %d\n", sizeof(uint32_t));
@pazdera
pazdera / dirstat.c
Created October 14, 2012 21:35
getdents + stat
/* getdents() + stat() scenario
*
* This program is based on an example from linux man page getdents(2)
*/
#define _GNU_SOURCE
#include <dirent.h> /* Defines DT_* constants */
#include <fcntl.h>
#include <stdio.h>
@pazdera
pazdera / yardoc-cheatsheet.rb
Last active November 5, 2016 02:35
Basic Yard Syntax (contributions welcome)
# Quick summary of the function
#
# {ObjectName#method Optional Title}
# {Class::CONSTANT Optional Title}
# {#method_inside_current_namespace}
#
# @see #method
#
# @param one [Fixnum] First parameter
# @param two [Fixnum] Second parameter
#!/usr/bin/env python
# -*- coding: utf-8 -*-
@pazdera
pazdera / abstract_factory_example.cpp
Created July 24, 2011 11:53
Example of `abstract factory' design pattern in C++
/*
* Example of `abstract factory' design pattern.
* Copyright (C) 2011 Radek Pazdera
* This program 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 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,