Skip to content

Instantly share code, notes, and snippets.

@pfultz2
pfultz2 / download.py
Created February 23, 2016 19:54
Download with progress bar
from tqdm import tqdm
import requests
url = "http://download.thinkbroadband.com/10MB.zip"
response = requests.get(url, stream=True)
with open("10MB", "wb") as handle:
for data in tqdm(response.iter_content()):
handle.write(data)
@pfultz2
pfultz2 / build_cross_gcc
Created February 10, 2016 20:13 — forked from preshing/build_cross_gcc
A shell script to download packages for, configure, build and install a GCC cross-compiler.
#! /bin/bash
set -e
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap 'echo FAILED COMMAND: $previous_command' EXIT
#-------------------------------------------------------------------------------------------
# This script will download packages for, configure, build and install a GCC cross-compiler.
# Customize the variables (INSTALL_PATH, TARGET, etc.) to your liking before running.
# If you get an error and need to resume the script from some point in the middle,
# just delete/comment the preceding lines before running it again.
#define MEMBER_LIFT_CLASS(m) \
struct member_##m { \
template<class T, class... Ts> \
auto operator()(T&& x, Ts&&... xs) const -> decltype(x.m(std::forward<Ts>(xs)...)) \
{ return x.m(std::forward<Ts>(xs)...); } \
};
@pfultz2
pfultz2 / colorize
Created July 17, 2015 22:53
Colorize gcc output
#!/bin/bash
while read x ; do echo $x ; done \
| sed -e "s/.*error:.*/\x1b[1;36m&\x1b[0m/" \
-e "s/.*warning:.*/\x1b[1;36m&\x1b[0m/" \
-e "s/^\(.*\)\(required from\)/\x1b[1;36m\1\x1b[0mnote: \2/" \
-e "s/^\(.*\)\(In instantiation of\)/\x1b[1;36m\1\x1b[0mnote: \2/" \
-e "s/^\(.*\)\(In member\)/\x1b[1;36m\1\x1b[0mnote: \2/" \
| sed -e "s/error:/\x1b[1;31m&\x1b[1;36m/" \
-e "s/warning:/\x1b[1;35m&\x1b[1;36m/" \
-e "s/note:/\x1b[1;30m&\x1b[0m/"
@pfultz2
pfultz2 / calc.cpp
Last active August 29, 2015 14:23
Hana Caclulator
#include <boost/hana.hpp>
#include <iostream>
#include <string>
#include <type_traits>
#include <utility>
#include <memory>
#include <cassert>
using namespace boost::hana;
using namespace boost::hana::literals;
@pfultz2
pfultz2 / Makefile.osx.diff
Last active August 29, 2015 14:19
Rubberband patch
diff --git a/Makefile.osx b/Makefile.osx
index 2318559..95199f9 100644
--- a/Makefile.osx
+++ b/Makefile.osx
@@ -1,35 +1,46 @@
+PREFIX := /usr/local
+MACOS_SDK_PATH :=
CXX := g++
CC := gcc
--- Makefile.in.orig 2012-10-28 05:30:09.000000000 -0500
+++ Makefile.in 2013-12-10 12:36:34.000000000 -0600
@@ -1,6 +1,8 @@
+PREFIX := @prefix@
CXX := @CXX@
-CXXFLAGS := -DHAVE_LIBSAMPLERATE -DHAVE_FFTW3 -DFFTW_DOUBLE_ONLY -DNO_THREAD_CHECKS -DUSE_PTHREADS -DNO_TIMING -DNDEBUG @CXXFLAGS@ @SRC_CFLAGS@ @SNDFILE_CFLAGS@ @FFTW_CFLAGS@ @Vamp_CFLAGS@ -Irubberband -I. -Isrc $(OPTFLAGS)
+CC := @CC@
+CXXFLAGS := -DHAVE_LIBSAMPLERATE -DHAVE_FFTW3 -DFFTW_DOUBLE_ONLY -DNO_THREAD_CHECKS -DUSE_PTHREADS -DNO_TIMING -DNDEBUG -Irubberband -I. -Isrc @CXXFLAGS@ @SRC_CFLAGS@ @SNDFILE_CFLAGS@ @FFTW_CFLAGS@ @Vamp_CFLAGS@ $(OPTFLAGS)
CFLAGS := @CFLAGS@ $(OPTFLAGS)
#include <vector>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <tuple>
#include <fit/always.h>
#include <fit/capture.h>
#include <fit/identity.h>
#include <fit/fix.h>
#include <iostream>
#include <vector>
#include <list>
#include <tick/builder.h>
#include <tick/requires.h>
#include <fit/lambda.h>
#include <fit/function.h>
#include <fit/conditional.h>
#include <fit/reveal.h>
@pfultz2
pfultz2 / reveal2.cpp
Created February 1, 2015 05:37
Transporting substitution failures for "advance" function
#include <iostream>
#include <vector>
#include <list>
#define REQUIRES(...) typename std::enable_if<(__VA_ARGS__), int>::type = 0
#define REQUIRE_OF(...) template<class Id> using apply = typename std::enable_if<(Id()(__VA_ARGS__)), int>::type
template<class T>
struct always_void