Skip to content

Instantly share code, notes, and snippets.

View beanieboi's full-sized avatar

Ben Fritsch beanieboi

View GitHub Profile
@beanieboi
beanieboi / gist:4298395
Created December 15, 2012 19:25
pipofant.c
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/types.h>
@beanieboi
beanieboi / gist:4988048
Created February 19, 2013 17:37
asset deployment with ruby on rails and rsync only if they changed
before 'deploy:create_symlink', 'deploy:upload_assets'
before 'deploy:update_code', 'deploy:compress_assets'
after 'deploy:update_code', 'deploy:custom_symlink'
namespace :deploy do
desc "symlinks"
task :custom_symlink do
run "ln -nfs #{shared_path}/assets #{release_path}/public/assets"
end
clang++ -DETLOG -std=c++0x -pedantic -Wall -I./backtrace/ -g0 -O3 -std=c++11 -stdlib=libc++ -o backtrace/libs/backtrace/src/backtrace.o -c backtrace/libs/backtrace/src/backtrace.cpp
In file included from backtrace/libs/backtrace/src/backtrace.cpp:10:
./backtrace/boost/backtrace.hpp:62:21: error: implicit instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >'
std::string trace_line(unsigned frame_no) const
^
/usr/bin/../lib/c++/v1/iosfwd:187:27: note: template is declared here
class _LIBCPP_VISIBLE basic_string;
^
In file included from backtrace/libs/backtrace/src/backtrace.cpp:10:
./backtrace/boost/backtrace.hpp:65:24: error: implicit instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >'
@beanieboi
beanieboi / gist:10373044
Last active August 29, 2015 13:58
Librato Sign Ups
wrong:
divide([sum(s("prod.myapp.signups", "*"), sum(s("prod.myapp.cancels", "*")))])
fixed:
divide([sum(s("prod.myapp.signups", "*")), sum(s("prod.myapp.cancels", "*"))])
18/05/14 20:02:25,552 Tweetbot[421]: (
0 CoreFoundation 0x00007fff8ce2925c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8b75de75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8ce2910c +[NSException raise:format:] + 204
3 AppKit 0x00007fff943c8797 _NSBlockNumberForIndex + 85
4 AppKit 0x00007fff943cb3f1 -[NSLayoutManager textContainerForGlyphAtIndex:effectiveRange:] + 274
5 AppKit 0x00007fff9454d71c -[NSTextView drawsVerticallyForCharacterAtIndex:] + 198
6 AppKit 0x00007fff9454d63e -[NSTextInputContext drawsVerticallyForCharacterAtIndex:] + 41
7 AppKit 0x00007fff9454d5d6 -[NSTextInputContext remapsArrowKeysForVerticalOrientation] + 76
8 AppKit 0x00007fff9452dca9 -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCo

The Benchmark

Calculating -------------------------------------
       map + flatten      1927 i/100ms
            flat_map      2603 i/100ms
-------------------------------------------------
       map + flatten    19876.1 (±9.2%) i/s -     100204 in   5.086854s
            flat_map 74241008.8 (±18.8%) i/s -  312185599 in   4.754152s

Comparison:
@beanieboi
beanieboi / 1_proc_yield.md
Last active August 29, 2015 14:06
Benchmarking block.call vs yield
Calculating -------------------------------------
              &block     19651 i/100ms
               yield     25992 i/100ms
-------------------------------------------------
              &block   361821.1 (±31.2%) i/s -    1316617 in   5.001739s
               yield 11423477091.4 (±27.9%) i/s - 21463829712 in   3.010145s

Comparison:
 yield: 11423477091.4 i/s
@beanieboi
beanieboi / fetch_vs_or.md
Last active August 29, 2015 14:06
Benchmarking fetch vs [] in Ruby
Calculating -------------------------------------
hash containing key using fetch with block
                         56342 i/100ms
hash containing key using [] with ||
                         63758 i/100ms
-------------------------------------------------
hash containing key using fetch with block
                      1600812.5 (±25.4%) i/s -    6592014 in   5.013939s
hash containing key using [] with ||
@beanieboi
beanieboi / gist:c1ce1eedec6236aceeba
Created October 18, 2014 01:07
segfault lxc-snapshot in LXC 1.0.5 on Ubuntu Trusty
lxc-snapshot --name=railsonfire -r snap0
Segmentation fault (core dumped)
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7bb8851 in lxcapi_snapshot_restore (c=0x55555575a3b0, snapname=0x7fffffffe8f9 "snap0", newname=0x0) at lxccontainer.c:3089
3089 bdev = bdev_init(c->lxc_conf->rootfs.path, c->lxc_conf->rootfs.mount, NULL);