Skip to content

Instantly share code, notes, and snippets.

@sansumbrella
sansumbrella / create-sparsebundle.sh
Created November 1, 2012 22:49
Sparse bundle creation for time machine on NAS.
# creates a sparsebundle disk image with a 128MB band size
MACHINE_NAME=your-machine-name
echo $MACHINE_NAME
hdiutil create -size 900g -type SPARSEBUNDLE -nospotlight -volname "Backup of $MACHINE_NAME" -fs "Case-sensitive Journaled HFS+" -imagekey sparse-band-size=262144 -verbose ./$MACHINE_NAME.sparsebundle
@sansumbrella
sansumbrella / query-sparsebundle-band-size.sh
Created November 4, 2012 17:10
Query band size of a sparsebundle (also accessible in Info.plist of bundle)
# find out how big the sparse-band-size is in a mounted volume
hdiutil info -verbose | grep band-size
# default Time Machine sparsbundle virtual-band-size = 16384 (8MB)
# create-sparsebundle's virtual-band-size = 262144 (128MB)
@sansumbrella
sansumbrella / user-config.jam
Created November 12, 2012 04:43
Boost config for building with Clang and libc++ support
# --------------------
# Clang configuration.
# --------------------
using clang : osx
: xcrun clang -arch i386 -arch x86_64 -stdlib=libc++ -std=c++11
;
using clang : ios
: xcrun clang -arch armv7 -arch armv7s -stdlib=libc++ -std=c++11 -miphoneos-version-min=5.0 -isysroot
@sansumbrella
sansumbrella / remove_if.cpp
Created November 26, 2012 15:21 — forked from cporter/remove_if.cpp
remove_if and vector
// -*- compile-command: "clang++ -std=gnu++0x -stdlib=libc++ -o remove_if remove_if.cpp" -*-
#include <iostream>
#include <vector>
using std::cout;
using std::endl;
int main (int, char **) {
std::vector<int> ints = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
cout << "Range-based for loop:" << endl;
@sansumbrella
sansumbrella / simpleserver.sh
Created November 26, 2012 22:31
Python simple server
python -m SimpleHTTPServer 8080
// debounce a callback function with delay being the longest acceptable time before seeing an effect
function debounce (fn, delay) {
var timeout = null;
return function () {
if( timeout !== null ){ clearTimeout( timeout ); }
timeout = setTimeout( fn, delay );
}
}
// example use:
@sansumbrella
sansumbrella / OrientationProjectApp.cpp
Last active December 12, 2015 05:09
Rotating UI elements while maintaining physical location. Compile as Objective-C++ against the AppRewrite branch of Cinder.
#include "cinder/app/AppNative.h"
#include "cinder/gl/gl.h"
#include "cinder/Timeline.h"
#include "cinder/Rand.h"
#import <UIKit/UIView.h>
#import <UIKit/UIApplication.h>
using namespace ci;
using namespace ci::app;
using namespace std;
@sansumbrella
sansumbrella / Facade.h
Created May 17, 2013 22:03
C++ facade for Objective-C class
// In your .h file:
#ifdef __OBJC__
@class ImplementationClass;
#else
class ImplementationClass;
#endif
class Facade
{
public:
@sansumbrella
sansumbrella / serve-me-up.py
Last active December 20, 2015 23:29
Script to start a local server in the current directory. Basically a fancy SimpleHTTPServer, in that it's accessible by other devices on your LAN and it prints out the server address on startup.
#! /usr/bin/python
# Server config: http://stackoverflow.com/questions/4139170/bind-httserver-to-local-ipport-so-that-others-in-lan-can-see-it
# IP address: http://stackoverflow.com/questions/166506/finding-local-ip-addresses-using-pythons-stdlib
import socket
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
# Announce the IP address and port we will serve on
port = 8000
print("Serving on %s:%s") % (socket.gethostbyname(socket.getfqdn()), port)
@sansumbrella
sansumbrella / circular.cpp
Last active December 19, 2021 19:20
Sample showing use of forward declarations to handle circular dependencies. Also note the use of weak_ptr to break circular references (which would leak).
#include <iostream>
#include <memory>
using namespace std;
/**
Demonstration of circular dependencies broken with forward declarations.
Compile like so:
clang++ -std=c++11 -stdlib=libc++ circular.cpp -o build/circular && build/circular
*/