Skip to content

Instantly share code, notes, and snippets.

curl https://aur.archlinux.org/cgit/aur.git/snapshot/lcov.tar.gz | tar zxf -
cd lcov
makepkg -csi
@cjmeyer
cjmeyer / boost-build
Last active December 20, 2015 20:49
building boost with mingw
# boost 1.46.1, from msys
$ bootstrap.bat --with-toolset=mingw
$ mv project-config.jam project-config.jam.old
$ sed s/mingw/gcc/g project-config.jam.old > project-config.jam
$ bjam.exe --prefix=C:/boost/boost-1.46.1 -j8
$ bjam.exe install
# boost 1.54.0, from cmd.exe
> boostrap.bat mingw
> b2.exe --prefix=C:\Libs\boost toolset=gcc -j8
@cjmeyer
cjmeyer / Singleton.hpp
Last active December 17, 2015 22:29
C++ singleton implementation with static initialization support.
/**
*
*/
#ifndef _SINGLETON_H
#define _SINGLETON_H
namespace lib {
namespace detail {
template <typename T>
@cjmeyer
cjmeyer / gist:5479581
Last active December 16, 2015 18:39
Sublime Text 2: Insert text and maintain viewport
# The code below only manages vertical position and assumes the text is
# being inserted before the current cursor (of which there is only one
# and no text is highlited). This can be expanded to manage the
# horizontal position and multi-selected text if needed using the same
# principals as used below.
v = sublime.active_window().active_view()
pos = v.sel()[0][0]
y0 = v.viewport_position()[1]
@cjmeyer
cjmeyer / build-openocd.sh
Last active May 22, 2016 13:15
Bash: Build OpenOCD with JLink support
#! /usr/bin/sh
#
# Build script to cross-compile OpenOCD with MinGW on Mint Linux (FTDI, JLINK, TI-ICDI, OSBDM).
#
# 7zip
# curl
# git
# MinGW-W64
# libtool
# Automake
@cjmeyer
cjmeyer / gist:4348271
Created December 20, 2012 20:29
VHDL: Resolved BFM control/command channel.
ype bfm_uctrl_vector_t is
array (integer range <>) of bfm_uctrl_t;
function resolve_bfm_ctrl (
s : bfm_uctrl_vector_t ) return bfm_uctrl_t;
subtype bfm_ctrl_t is
resolve_bfm_ctrl bfm_uctrl_t;
procedure do_req (
@cjmeyer
cjmeyer / vhdl_fifo.vhd
Created December 20, 2012 15:16
VHDL: Behavioral dynamically expanding queue.
type axi_data is record
val : std_logic;
end record;
type axi_data_array is array (natural range <>) of axi_data;
type axi_data_store is access axi_data_array;
type axi_data_q is record
data : axi_data_store;
count : natural;
head : natural;
@cjmeyer
cjmeyer / app.py
Created December 12, 2012 19:37
Python: Easy_install from script.
from setuptools.command import easy_install
def install_with_easyinstall(package):
easy_install.main(["-U", package]).
install_with_easyinstall('py2app')
import pkg_resources
easy_install.main( ['mymodule'] )
pkg_resources.require('mymodule')
@cjmeyer
cjmeyer / snake_case.rb
Created December 12, 2012 15:32
Ruby: Convert camelCase/PascalCase to snake_case.
def snake_case
return downcase if match(/\A[A-Z]+\z/)
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
gsub(/([a-z])([A-Z])/, '\1_\2').
downcase
end
"FooBar".snake_case #=> "foo_bar"
"HeadlineCNNNews".snake_case #=> "headline_cnn_news"
"CNN".snake_case #=> "cnn"
@cjmeyer
cjmeyer / build-openocd.sh
Created December 10, 2012 15:26
Bash: OpenOCD build script (Cygwin/MinGW).
#! /usr/bin/sh
OPENOCD_VERSION=0.5.0
D2XXLIB_SRC="CDM%202.08.24%20WHQL%20Certified"
D2XXLIB=CDM_20824
OPENOCD=openocd-${OPENOCD_VERSION}
PREFIX=/opt/${OPENOCD}
PATH_DIR=/opt/openocd