Skip to content

Instantly share code, notes, and snippets.

#import "NSWorkspace+OpenFileOnLine.h"
NSString *kSublimeText2Identifier = @"com.sublimetext.2";
NSString *kSublimeText3Identifier = @"com.sublimetext.3";
NSString *kMacVimIdentifier = @"org.vim.MacVim";
NSString *kTextmateIdentifier = @"com.macromates.textmate";
NSString *kTextmate2Identifier = @"com.macromates.textmate.preview";
NSString *kBBEditIdentifier = @"com.barebones.bbedit";
- (void)viewDidLoad
{
[super viewDidLoad];
NSUInteger const mmWidth = 10;
CGSize const boundsSize = { mmWidth*10, 50 };
UIGraphicsBeginImageContextWithOptions(boundsSize, NO, 0);
self.view.contentMode = UIViewContentModeTop;
[[UIColor blackColor] setFill];
UIRectFill((CGRect) {
import "AppKit"
@NSString {
- trimmed `self stringByTrimmingCharactersInSet: NSCharacterSet whitespaceAndNewlineCharacterSet`
}
@NSBlock {
- applicationDidFinishLaunching: app `self call`
}
@NSApplication {
@fjolnir
fjolnir / vll
Last active August 29, 2015 13:56
layout ::= rules.
rules ::= rule.
rules ::= rules rule.
rule ::= orientation superview connection view connection superview
view ::= LBRACKET className selectors predicateList RBRACKET
LBRACE layout RBRACE.
selectors ::= selector.
|-(>=20)-[UILabel#labelA (==100)] - 10 - [UILabel#labelB maximumLines=0]-|
- (void)_setVolumeBezelVisible:(BOOL const)aVisible
{
mach_port_t (*springBoardServerPort)() = dlsym(RTLD_DEFAULT, "SBSSpringBoardServerPort");
void (*setSystemVolumeHUDEnabled)(mach_port_t, const char *audioCategory, Boolean) =
dlsym(RTLD_DEFAULT, "SBSetSystemVolumeHUDEnabled");
if(!springBoardServerPort || !setSystemVolumeHUDEnabled)
return;
mach_port_t sbPort = springBoardServerPort();
if(!sbPort)
uint16_t itoa(int16_t num, unsigned char *buf, uint16_t maxlen)
{
int ofs = maxlen;
unsigned char *head = buf;
int16_t abs_num = abs(num);
do {
*head++ = "0123456789"[abs_num % 10];
abs_num /= 10;
} while(abs_num != 0);
if(num < 0) *head++ = '-';
#ifdef DEBUG
#include "usart.h"
#include "hardware.h"
#include "interrupt.h"
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <stdarg.h>
@fjolnir
fjolnir / uint128.c
Last active August 29, 2015 14:00
in progress mini 128bit unsigned integer; totally unoptimized
#include "uint128.h"
#include "assert.h"
#include <string.h>
#include <stdio.h>
static inline void uint128_set_bit(uint128_t a, uint8_t idx)
{
assert(idx < 128);
a[idx/8] |= 1 << (7 - idx%8);
}
use std::libc;
use std::cast::transmute;
type Id = libc::uintptr_t;
type Sel = libc::uintptr_t;
#[link(name = "objc")]
extern {
fn sel_registerName(sel: &str) -> Sel;
fn objc_msgSend(object: Id, sel: Sel, ...) -> libc::uintptr_t;