Skip to content

Instantly share code, notes, and snippets.

@jcromartie
jcromartie / core.clj
Created August 8, 2012 16:16 — forked from rickysaltzer/core.clj
random state and words generator
(ns honeycomb.core
(:gen-class)
(:require [clojure.string :as string]
[clojure.java.io :as io]))
;; this is basically an iterative approach, which avoids building up lazy sequences. there
;; would be almost no overhead here in terms of memory or objects
(defn -main-simple
"Prints n random rows from given filenames. All command-line arguments are strings."
// snip some code that compiles with no errors
// the whole file compiles if I remove the category implementation below:
@implementation NSString (colors)
- (UIColor *)colorValue
{
// snip some other code
}
CGFloat height = self.view.bounds.size.height - self.toolbar.bounds.size.height;
self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, height)];
self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
- (void)viewDidLoad
{
[super viewDidLoad];
UISearchBar *bar = self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];
[bar sizeToFit];
bar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
bar.tintColor = [UIColor colorWithWhite:(121.0/255.0) alpha:1.0];
[self.view addSubview:bar];
@jcromartie
jcromartie / tables.js
Created June 14, 2012 17:01
Backbone views done right done right?
var TableViewRow = Backbone.View.extend({
tagName: "tr",
template: _.template("<td><%= firstName %></td><td><%= lastName %></td>"),
render: function() {
this.$el.html(this.template(this.model.toJSON()));
return this;
}
});
@jcromartie
jcromartie / Example.m
Created June 8, 2012 16:20
NSArray+BlockPartitioning
NSCalendar *cal = [NSCalendar autoupdatingCurrentCalendar];
self.postsByDate = [self.posts arrayByPartitioningWithBlock:^(RSSFeedItem *obj) {
NSDate *day;
NSTimeInterval tip;
[cal rangeOfUnit:NSDayCalendarUnit startDate:&day interval:&tip forDate:obj.pubDate];
return day;
}];
@jcromartie
jcromartie / tabula_recta.rb
Created June 7, 2012 21:26
password table v1
#!/usr/bin/ruby
# Generate a password table with a given seed ("master" password... sort of)
s=ARGV[0] and srand(s.hash)
x_axis = %w(a b c d e f g h i j k l m n o p q r s t u v)
y_axis = %w(ab cd ef gh ij kl mn op qr st uv)
pw_chars = x_axis + %w(0 1 2 3 4 5 6 7 8 9 ! @ $ % ^ &)
@jcromartie
jcromartie / index.html
Created June 4, 2012 15:51 — forked from benjchristensen/index.html
Dynamic Stacked Bar Chart using d3.js
<html>
<head>
<title>Dynamic Stacked Bar Chart using d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style>
rect.a {
fill: green;
}
rect.b {
fill: orange;
@jcromartie
jcromartie / findNS.js
Created May 31, 2012 20:11
$.fn.findNS
(function($) {
// an extension to jQuery to allow "find" with XML namespaces
$.fn.findNS = function(ns, selector) {
var prefix = ns + ":";
return this.find(selector).filter(function(idx, el) {
return el.nodeName.indexOf(prefix) == 0;
});
}
})(jQuery);
(function ($) {
//demo data
var contacts = [
{ name: "Contact 1", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "[email protected]", type: "family" },
{ name: "Contact 2", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "[email protected]", type: "family" },
{ name: "Contact 3", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "[email protected]", type: "friend" },
{ name: "Contact 4", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "[email protected]", type: "colleague" },
{ name: "Contact 5", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "[email protected]", type: "family" },
{ name: "Contact 6", address: "1, a street, a town, a city, AB12 3CD", tel: "0123456789", email: "[email protected]", type: "colleague" },