Skip to content

Instantly share code, notes, and snippets.

View vmrob's full-sized avatar

Victor Robertson vmrob

  • Cruise Automation
  • San Francisco
View GitHub Profile
@vmrob
vmrob / math-se-612346.c
Last active August 29, 2015 14:00
Brute force test for Math StackExchange question 612346: http://math.stackexchange.com/questions/612346/
// This program is a quick brute force test of the question described at
// http://math.stackexchange.com/questions/612346/find-all-positive-integers-n-s-t-3n-5n-is-divisible-by-n2-1
// Copyright (C) 2014 Victor Robertson
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
@vmrob
vmrob / convert.sh
Created June 18, 2014 22:03
Converts a video to a gif
#!/bin/bash -e
# Converts a video to a gif
if [ "$#" -ne 2 ]; then
echo "usage: ${0##*/} [input video] [output gif]"
exit 1
fi
VIDEO=$1
@vmrob
vmrob / test.cpp
Created August 14, 2014 20:01
test
#include <iostream>
#include <thread>
#include <vector>
#include <random>
#define NUM_THREADS 10
#define GOAL 2147000000 // 2147483647 is max
typedef int32_t random_type;
@vmrob
vmrob / mem_function_traits.cpp
Last active June 13, 2020 01:35
Member Function Traits
#include <utility>
#include <functional>
#include <type_traits>
#include <typeinfo>
#include <iostream>
namespace meta {
// detects callable objects, not functions
@vmrob
vmrob / padding.cpp
Created January 26, 2015 19:08
Arbitrary byte padding with C++ TMP
#include <type_traits>
template <typename T, size_t Amount, typename = void>
struct PaddedValImpl {
PaddedValImpl(T&& t) : val(std::forward<T>(t)) {}
T val;
};
template <typename T, size_t Amount>
struct PaddedValImpl <T, Amount
@vmrob
vmrob / generate-gitdag.sh
Created May 13, 2015 03:45
Script to convert a pdf to png
#!/bin/bash -e
Root=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [[ $1 == "" ]] ; then
echo "usage: generate-gitdag.sh input.tex [density (default 300)]"
exit;
fi
Density=300
@vmrob
vmrob / cache.cpp
Last active August 29, 2015 14:28
Testing some policy-based design
#include <unordered_map>
#include <type_traits>
#include <string>
#include <queue>
#include <unordered_set>
#include <utility>
class PolicyBase {
public:
template <typename CacheType>
@vmrob
vmrob / needy.jam
Last active September 22, 2015 02:55
needy b2
#################
# Needy toolset
#################
import type ;
import feature ;
import toolset ;
import generators ;
type.register NEEDSFILE : json ;
@vmrob
vmrob / channel.cpp
Last active March 29, 2021 23:40
Go channels in C++
#include <future>
#include <iostream>
#include <thread>
#include <queue>
template <typename T>
class concurrent_queue {
private:
std::queue<T> _queue;
std::mutex _mutex;
@vmrob
vmrob / spindump.txt
Created November 4, 2015 01:28
Spindump during a potential deadlock with zfs on os x
Date/Time: 2015-11-03 11:20:25 -0700
OS Version: 10.10.5 (Build 14F27)
Architecture: x86_64h
Report Version: 21
Duration: 9.99s
Steps: 1000 (10ms sampling interval)
Hardware model: MacBookPro11,3
Active cpus: 8