Skip to content

Instantly share code, notes, and snippets.

@drautb
drautb / read_all_bytes.cpp
Created May 13, 2013 20:24
C++: Read all bytes from a file
/**
* Read all bytes from a file.
*
* Taken from http://codereview.stackexchange.com/questions/22901/reading-all-bytes-from-a-file
*
* Alternate form: static void ReadAllBytes(char const* filename, std::vector<char>& result)
*/
#include <vector>
#include <fstream>
@drautb
drautb / wxwidgets-event-handler.sublime-snippet
Created May 18, 2013 22:55
C/C++: wxWidgets Event Handler
<snippet>
<content><![CDATA[
void ${1:ClassName}::${2:HandlerName}(wxCommandEvent& WXUNUSED(event))
{
${3:// Handler code}
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>wxh</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@drautb
drautb / wxNoLabelCheckBox.h
Last active December 17, 2015 11:59
C++: wxWidgets Checkbox Without Label
/**
* TAKEN FROM: http://olecam.online.fr/wxNoLabelCheckBox/
*/
/////////////////////////////////////////////////////////////////////////////
// Name: wxNoLabelCheckBox.h
// Purpose:
// Author: Olivier Le Cam
// Modified by: Ben Draut, changed to inherit from wxPanel (Jul 2013)
// Created: 25/03/2008 19:01:21
@drautb
drautb / wxNoLabelCheckBox.cpp
Last active December 17, 2015 11:59
C++: wxWidgets Checkbox Without Label
/**
* TAKEN FROM: http://olecam.online.fr/wxNoLabelCheckBox/
*/
/////////////////////////////////////////////////////////////////////////////
// Name: wxNoLabelCheckBox.cpp
// Purpose:
// Author: Olivier Le Cam
// Modified by: Ben Draut, chaned to inherit from wxPanel (Jul 2013)
// Created: 25/03/2008 19:01:23
@drautb
drautb / install-dev-tools.sh
Created May 20, 2013 21:19
Bash: Install Development Tools
#!/bin/bash
# Quick script to install common dev tools.
# Ubuntu 13.04
# 5/20/13
# Quick Launcher (Ctrl+Space)
yes | sudo apt-get install synapse
# Git
@drautb
drautb / CMake: Variable Dump
Created July 3, 2013 20:11
This snippet will dump all CMake variables to the build output
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
@drautb
drautb / PointerStringSwap.cpp
Created August 7, 2013 20:38
Quick demo for converting pointers to strings, swapping them, and converting them back to pointers.
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
int* p1 = new int(10);
int* p2 = new int(20);
@drautb
drautb / Mathjax.sublime-snippet
Created September 11, 2013 20:21
Short JavaScript Snippet to set up a mardown file with Mathjax
<snippet>
<content><![CDATA[
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['\$','\$']]}});</script>
<script type="text/javascript"src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>amj</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.html.markdown</scope>
</snippet>
@drautb
drautb / curried-map.rkt
Last active December 30, 2015 04:09
A curried version of Racket's map function.
#lang plai
(define nums '(0 1 2 3 4))
(test (map add1 nums) '(1 2 3 4 5))
(define (my-map f l)
(cond
[(empty? l) l]
[else (cons (f (first l))
(define curried-map-def '(rec (cm (fun (f)
(fun (l)
(bif (tempty? l)
l
(tcons (f (tfirst l))
((cm f) (trest l)))))))
cm))
(test/pred (infer-type (parse curried-map-def))
(type=? (t-fun