Skip to content

Instantly share code, notes, and snippets.

View mysteriouspants's full-sized avatar
:shipit:
Help! I'm trapped in a fixed-width str

Christopher R. Miller mysteriouspants

:shipit:
Help! I'm trapped in a fixed-width str
View GitHub Profile
@mysteriouspants
mysteriouspants / hex-parser.c
Created February 16, 2012 17:28
Why parse hex when you don't have to?
#include <stdio.h>
int main(int argc, char *argv[]) {
const char* c = "1A FF";
int a, b;
sscanf(c, "%2x %2x", &a, &b);
printf("a: %3d b: %3d\n", a, b);
printf("a: %3x b: %3x\n", a, b);
@mysteriouspants
mysteriouspants / Rakefile
Created February 15, 2012 22:11
Some weird random stuffs.
# encoding: utf-8
# a rakefile for working with Markdown-based prose.
#
# quotes: Change dumb quotes to smart quotes, and then back again.
# info: Various metrics for vanity's sake. "How many words and
# characters are in each file, & total" and other such nonsense.
# (Note that this chops off the very last file, which I generally
# use as the 'stuff I'm about to write' scratchpad - I don't want
# metrics on that!
#
@mysteriouspants
mysteriouspants / Rakefile
Created January 31, 2012 17:23
ARMED AND FULLY OPERATIONAL RAKEFILE!!!!
require 'rake/clean'
CC = 'clang'
CXX = 'clang++'
LD = CC
PRODUCTS = {
# executable => source file with the main method
'example_main' => 'example_main.m',
'default_description_example' => 'default_description_example.m'
@mysteriouspants
mysteriouspants / descriptionwithlocalebug.m
Created January 27, 2012 16:10
descriptionWithLocale:indent: Bug
#import <Foundation/Foundation.h>
@interface C0 : NSObject
@end
@interface C1 : NSObject
@end
@interface C2 : NSObject
@end
int main(int argc, char *argv[]) {
@mysteriouspants
mysteriouspants / allClassesConformingToProtocol.h
Created January 20, 2012 21:28
All Classes Conforming to Protocol
#import <Foundation/Foundation.h>
NSArray* allClassesConformingToProtocol(Protocol* p); // fwd dec; makes compiler stfu
@mysteriouspants
mysteriouspants / players_sketch.cpp
Created January 13, 2012 21:27
Just some randomness. Probably doesn't even compile.
#include <iostream>
#include <vector>
Class Player;
using namespace std;
int main(int argc, char *argv[]) {
int32_t min_players = 2;
int32_t max_players = 6;
@mysteriouspants
mysteriouspants / test.cpp
Created December 21, 2011 22:03
Testing Pointers Stuff
// see http://alexcampbell.github.com//blog/2011/12/19/my-poor-attempt-at-classes/#comment-391786776
#include <iostream>
#include <vector>
#include <cassert>
class C1;
class C2;
class C1 {
public:
@mysteriouspants
mysteriouspants / layout.scss
Created December 21, 2011 19:10
Fix for nested lists in Octopress
ul ul, ol ol { margin-bottom: 0px !important; } // hack for soapy-spaghetti
// see the big 'ole list at http://chrismiller.at/blog/2011/12/21/soapy-spaghetti/
// and notice how the sub-lists don't have the bottom margin
// as a side note, it'd be cool if someone knew how to do this without the evil
// !important bit, but it was a quick hack and worked for me.
// if the margin below nested lists is intentional, that's totally cool, too!
@mysteriouspants
mysteriouspants / ex.m
Created December 9, 2011 21:11
Madness.
@interface Sender : NSObject
@property (weak) id delegate;
@property (assign) SEL selector;
- (void)doSth;
@end
@interface Receiver : NSObject
@property (strong) Sender* whatever;
@property (copy) void(^blockStuff)();
- (void)assumeThisIsRun;
<h3>Upload a New Image</h3>
<%= form_for Image.new(:project => @project) do |f| %>
<%= f.hidden_field :project_id %>
<div class="sevenhundred">
<div class="first column threeforty">
<%= f.text_field :name, :class => 'form-text', :placeholder => 'Image Name', :size => '45' %>
</div>
<div class="last column threeforty">
<%= f.file_field :image %>
</div>