Skip to content

Instantly share code, notes, and snippets.

@jpmec
jpmec / gist:a405dd202d083066a842
Created February 11, 2016 04:43
Example of how to use Exvc with Comeonin
defmodule Mix.Tasks.Compile.Comeonin do
@shortdoc "Compiles Comeonin"
def run(_) do
File.rm_rf!("priv")
File.mkdir("priv")
{exec, args} = case :os.type do
{:win32, _} ->
Exvc.vc_env() |> System.put_env
{"nmake", ["/F", "Makefile.win", "priv\\bcrypt_nif.dll"]}
@jpmec
jpmec / itemwalk.py
Created June 27, 2014 05:24
itemwalk
class itemwalk(object):
def __init__(self, obj):
self.objs = [(obj, [])]
self.obj = None
self.path = None
self.keys = []
@jpmec
jpmec / fibonacci.cpp
Created August 25, 2013 15:52
Compute the n-th Fibonacci number.
#include <iostream>
using namespace std;
/// Output the n-th Fibonacci number.
/// http://en.wikipedia.org/wiki/Fibonacci_number
///
int main(int argc, char* argv[])
{
@jpmec
jpmec / runlenc.cpp
Last active December 21, 2015 15:19
A simple run length encoding program.
#include <iostream>
using namespace std;
/// Simple run-length encoding program.
///
/// Example usage:
@jpmec
jpmec / find_sum_pairs.cpp
Last active December 21, 2015 13:49
Given a file name of a file containing an array of unsorted integers A and integer N, find all pairs of numbers within A which add up to N.
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;
@jpmec
jpmec / anagram.cpp
Last active December 21, 2015 13:49
Given the name of a file that contains a list of words and a single word, print the words from the file that are anagrams of the given single word.
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
@jpmec
jpmec / test_cpp_virtual_destructor.cpp
Created July 27, 2013 00:14
A simple example demonstrating C++ virtual destructors and the pitfalls if they are not used.
/** An example of a virtual destructor.
*
* Compile with:
* g++ -Wall test_cpp_virtual_destructor.cpp -o test_cpp_virtual_destructor
*/
#include <iostream>
@jpmec
jpmec / test_cpp_print_before_main.cpp
Created July 26, 2013 17:40
A simple example demonstrating how to print "Hello World" before the main() function is called.
/** Example showing how to print "Hello World" before main().
* Expected output:
* Hello World
* Hello from main()
*
* Compile with:
* g++ -Wall test_cpp_print_before_main.cpp -o test_cpp_print_before_main
*/
@jpmec
jpmec / test_cpp_mutable.cpp
Created July 26, 2013 16:06
Test the C++ keyword mutable
/** A set of tests for the C++ keyword mutable.
*
* Compile with:
* g++ -Wall test_cpp_mutable.cpp -o test_cpp_mutable
*/
#include <iostream>
#include <cassert>