Skip to content

Instantly share code, notes, and snippets.

@marchelbling
marchelbling / named_pipes.md
Created March 12, 2015 06:50
Introduction to Named Pipes

From http://www.linuxjournal.com/article/2156

A very useful Linux feature is named pipes which enable different processes to communicate.

Introduction to named pipes

One of the fundamental features that makes Linux and other Unices useful is the “pipe”. Pipes allow separate processes to communicate without having been designed explicitly to work together. This allows tools quite narrow in their function to be combined in complex ways.

A simple example of using a pipe is the command:

@marchelbling
marchelbling / essentials.md
Last active August 29, 2015 14:16
CS essentials

Data structures

list

heap

stack

queue

@marchelbling
marchelbling / README.md
Last active April 1, 2022 06:35
C++ json writer

why?

This code implements a naive JSON writer in C++ complying with RFC 4627. I wrote this as I believe it is a very good example of a real life problem involving lots of C++ constructs. This sample only supports writing JSON and does not support heterogenous ‘object’ serialization and extension are left as an exercice. See Writing json in C++ for some details.

what?

  • json_stream: a std::ofstream wrapper fulfilling RFC 4627 constraints;
  • utf8_json: some code to decode/“json encode” std::string UTF-8 buffers
  • json_test.cpp: a very simple program testing the code
@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"
@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 / 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 / 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 / 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 / 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
  • 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