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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
@pazdera
pazdera / gist:1040939
Created June 22, 2011 19:35
Python main template
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
""" Main program """
# Code goes over here.
return 0
if __name__ == "__main__":
main()
@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:1086117
Created July 16, 2011 07:56
Example of using getopt(1) utility in bash
#!/bin/bash
# Example of using getopt(1) utility 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:1098119
Created July 21, 2011 20:25
Singleton example in C++
/*
* Example of a singleton 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,
@pazdera
pazdera / gist:1098129
Created July 21, 2011 20:29
Singleton example in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of Singleton 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.
@pazdera
pazdera / gist:1099559
Created July 22, 2011 14:29
Factory Method design pattern example in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of `factory method' 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.