Skip to content

Instantly share code, notes, and snippets.

@danzimm
danzimm / bit.s
Created June 3, 2012 01:46
get your intel processor branding string whoop whoop
.globl start
.cstring
l:
.ascii "%s\n\0"
.text
start:
push %rbp
mov %rsp, %rbp
sub $0x30, %rsp
@danzimm
danzimm / mach_list_services.c
Last active August 29, 2015 13:58
List the mach services on your computer, or at least all the ones up the default bootstrap chain!
#include <stdio.h>
#include <mach/mach.h>
#include <bootstrap_priv.h>
#include <stdlib.h>
void error(int a, int r, const char *str) {
const char *err = bootstrap_strerror(r);
fprintf(stderr, "%s (%#02x) %s\n", str, r, err);
exit(a);
}
@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>
'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 / 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(),
@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 / 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 / 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 / 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 / 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("")
}
}