Skip to content

Instantly share code, notes, and snippets.

@danzimm
danzimm / Output.txt
Created May 17, 2017 15:33
Example output of caffe2 receiving a given signal in c++
SIGABRT(6), Thread 3493194:
[0] ???+0x51aad878(0x7f7a51aad878) in /home/danzimm/oss/caffe2/build/caffe2/libCaffe2_CPU.so
[1] ???+0x51aadbbe(0x7f7a51aadbbe) in /home/danzimm/oss/caffe2/build/caffe2/libCaffe2_CPU.so
[2] ???+0x51aade72(0x7f7a51aade72) in /home/danzimm/oss/caffe2/build/caffe2/libCaffe2_CPU.so
[3] ???+0x510ca370(0x7f7a510ca370) in /lib64/libpthread.so.0
[4] raise+0x2b(0x7f7a510ca23b) in /lib64/libpthread.so.0
[5] ???+0x404fcf(0x404fcf) in caffe2/binaries/fatal_signal_test
[6] ???+0x40562d(0x40562d) in caffe2/binaries/fatal_signal_test
[7] fatalSignalTest_SIGABRT8_Test::TestBody()+0x73(0x405773) in caffe2/binaries/fatal_signal_test
[8] void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*)+0x33(0x7f7a5021b203) in /home/danzimm/oss/caffe2/build/third_party/googletest/googlemock/gtest/libgtest.so
@danzimm
danzimm / cowsay.py
Created April 17, 2017 05:30
Weechat cowsay plugin
import os
import subprocess
import weechat
rawCowfiles = subprocess.check_output("cowsay -l", shell=True)
cowfiles = [f for line in filter(lambda line: not line.startswith("Cow files in"), rawCowfiles.splitlines()) for f in line.split()]
ordCowfiles = "||".join(cowfiles)
weechat.prnt("", "Available cowfiles: " + str(cowfiles))
@danzimm
danzimm / msgSendGen.swift
Created February 16, 2017 22:53
Generate msgSend wrappers for swift, written in swift
#!/usr/bin/env swift
import Foundation
extension Int {
var tabs: String {
return Array(count: self, repeatedValue: " ").joinWithSeparator("")
}
}
@danzimm
danzimm / currygen.swift
Created February 16, 2017 22:52
Generate curry functions for swift, written in swift
#!/usr/bin/env swift
import Foundation
infix operator <*> {
associativity left
precedence 120
}
func <*> <T: CollectionType, U: CollectionType, V where T.Generator.Element == ((U.Generator.Element) -> V)>(left: T, right: U) -> [V] {
@danzimm
danzimm / crash.c
Created January 2, 2017 00:17
Jump to a random x86_64 interrupt
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
void usage(const char* name) {
printf("Usage: %s [int code]\n", name);
exit(1);
}
void doInterrupt(uint8_t code) {
@danzimm
danzimm / hash_extension.cpp
Created October 12, 2016 16:25
std::hash extensions
template<typename T, typename U>
struct std::hash<std::pair<T, U>> {
std::size_t operator()(std::pair<T, U> const& value) const {
std::size_t thash = std::hash<T>{}(value.first);
std::size_t uhash = std::hash<U>{}(value.second);
// See boost::hash_combine for this
return uhash ^ ( thash << 1 );
}
};
@danzimm
danzimm / helpers.hpp
Last active September 25, 2016 17:15
Objective-C++ object type helpers
template<typename T>
struct remove_ownership {
using type = T;
};
template<typename T>
struct remove_ownership<__strong T> {
using type = T;
};
@danzimm
danzimm / Whoa.swift
Last active August 29, 2015 14:24
PlaygroundFun
func +(a: NSAttributedString, b: NSAttributedString) -> NSAttributedString {
let muty = NSMutableAttributedString(attributedString: a)
muty.appendAttributedString(b)
return muty
}
extension String: CustomPlaygroundQuickLookable {
public func customPlaygroundQuickLook() -> PlaygroundQuickLook {
let colors: [UIColor] = [
.redColor(), .orangeColor(), .yellowColor(),
'use strict';
/**
* MAC OSX ONLY
*/
// npm install request async
try{
var request = require('request');
var async = require('async');
var Notification = require('node-notifier');
@danzimm
danzimm / im.danz.dot-clipboard.plist
Created September 1, 2014 20:41
Drop something like this in ~/Library/LaunchAgents and you get dot-clipboard forevah ;D
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>im.danz.dot-clipboard</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/node</string>
<string>/usr/local/bin/dot-clipboard</string>