Skip to content

Instantly share code, notes, and snippets.

@marchelbling
marchelbling / constness.cpp
Created August 17, 2012 10:57
Dummy code to check that a const object attributes are const
#include <iostream>
class A
{
public:
A (int a = 0) : m_a (a)
{ }
~A ()
@marchelbling
marchelbling / stringcompress.cpp
Created August 17, 2012 11:31
simple string compressor
//examples:
// compress("AABBBCCCCCAADDDD") == "2A3B5C2A4D"
// compress("PPPQRRRSTTQQS") == "3PQ3RS2T2QS"
// compress("uvw") == "uvw"
#include<sstream>
#include<string>
void _format(std::ostringstream& out, size_t counter, char current)
{
@marchelbling
marchelbling / objectcoercion.cpp
Created August 17, 2012 11:34
Object coercion flow in C++
#include <iostream>
class B;
class A
{
public:
A ()
{ std::cout << "A::A ()" << std::endl; }
  • addpart: Informs the Linux kernel of new partition
  • agetty: Alternative Linux getty; handles tty, login, shell
  • arch: print machine architecture
  • blkid: Locate/print block device attributes
  • blockdev: Call block device ioctls from the command line
  • cal: Displays a calendar
  • cfdisk: Curses based disk partition table manipulator
  • chcpu: Configure CPUs
  • chfn: Change your finger information
  • chkdupexe: Find duplicate executables
@marchelbling
marchelbling / spec1.rb
Created October 4, 2012 19:58 — forked from cheeyeo/spec1.rb
Example on how to mock out an API call using RSpec and EM:Http
before :each do
@url = 'http://sns.us-east-1.amazonaws.com:80/?Action=ListTopics&Signature=ItTAjeexIPC43pHMZLCL7utnpK8j8AbTUZ3KGUSMzNc%3D&AWSAccessKeyId=123456&Timestamp=123&SignatureVersion=2&SignatureMethod=HmacSHA256'
EventMachine::MockHttpRequest.reset_registry!
EventMachine::MockHttpRequest.reset_counts!
EventMachine::MockHttpRequest.pass_through_requests = false #set to false to not hit the actual API endpoint
end
it 'should be able to access the API endpoint' do
@marchelbling
marchelbling / debug_build.sh
Created September 25, 2013 13:23
script to build osg
#!/bin/bash
CXXFLAGS="-pipe" cmake ../ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_INSTALL_PREFIX=`pwd`/build -DCMAKE_DEBUG_POSTFIX='' -DBUILD_OSG_ANIMATIONTEST=NO -DOSG_WINDOWING_SYSTEM=Cocoa -DBUILD_OSG_EXAMPLES=NO -DwxWidgets_CONFIG_EXECUTABLE=wxWidgets_CONFIG_EXECUTABLE-NOTFOUND -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
make
source debug_env.sh
@marchelbling
marchelbling / README.md
Last active February 13, 2020 01:00
git hooks

Git hooks for better pivotal integration:

  • pre-commit:
    • prevents commiting on a branch that is not suffixed by an issue number. Some special branches (develop, master) and hotfixes are not constrained
    • lints modified python files and exits upon non correctly formatted modules
    • other formats (js, scss) have pending code that is not currently called as the workflow for front code is not clear
  • prepare-commit-msg: prepend issue number to commit message if it's missing and if it is set in the branch name (see pre-commit hook)
  • post-checkout: [optional] automatically update submodules when checkouting a branch (requires to define the AUTO_SUBMODULE_UPDATE environment variable)

For easy setup:

@marchelbling
marchelbling / primitives_indices
Last active August 29, 2015 14:04
osg gdb scripts
set $id=0
set $numVertices = geom.getVertexArray()->getNumElements()
while $id < geom.getNumPrimitiveSets()
set $primitive = geom.getPrimitiveSet($id)
set $primitive_size = $primitive->getNumIndices()
printf "processing primitive n.%d (mode: %d, type: %d, size: %d)", $id, $primitive->getMode(), $primitive->getType(), $primitive_size
set $ii = 0
while $ii < $primitive_size
if $primitive->index($ii) >= $numVertices
printf "primitive %d has wrong index (%d >= %d) at index %d", $id, $primitive->index($ii), $numVertices, $ii
@marchelbling
marchelbling / Profiler
Last active April 11, 2017 07:23
Simple (intrusive) OSG profiler
#ifndef PROFILER
#define PROFILER
#include <map>
#include <string>
#include <utility>
#include <fstream>
#include <iomanip>
#include <osg/Timer>
@marchelbling
marchelbling / panda.rb
Last active August 29, 2015 14:10 — forked from bsag/panda.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'commander/import'
program :version, '0.1'
program :description, 'Converts markdown documents into a variety of default formats using Pandoc'
CMD = "pandoc"
BIB = "$HOME/Dropbox/Documents/bibtex/all-refs.bib"