Skip to content

Instantly share code, notes, and snippets.

View jcromartie's full-sized avatar

John Cromartie jcromartie

View GitHub Profile
- (IBAction)btnConvert:(id)sender {
NSString *urlString = urlField.text;
answerData = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
html = [[NSString alloc] initWithData:answerData encoding:NSUTF8StringEncoding];
NSLog(@"Source: %@", html);
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"ansMap\\[\\d+\\] = '(\\w+)'" options:0 error:NULL];
[regex enumerateMatchesInString:html options:0 range:NSMakeRange(0, [html length]) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
<div class="page-header">
<h1>>Navy Feeds</h1>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>Name></th>
<th>URL</th>
<th>Tags</th>
<th>Actions</th>
@jcromartie
jcromartie / power.sh
Last active December 15, 2015 05:09 — forked from anonymous/power.sh
#!/bin/bash
# Please supply your own audio file...
audiofile="$1"
if [[ ! -f "$audiofile" ]]
then
echo "USAGE: $(basename ${0}) audio_file"
exit 1
@jcromartie
jcromartie / atom.cljs
Last active December 14, 2015 20:19 — forked from newsomc/atom.cljs
(defn make-ghost
[color]
{:get-tick 0, :eatable nil, :color nil, :eaten nil, :specs color, :position nil, :due nil, :map nil, :direction nil})
(def ghost-specs ["#00FFDE" "#FF0000" "#FFB8DE" "#FFB847"])
(def game-state (atom {:state nil
:audio []
:ghosts (mapv make-ghost ghost-specs)
:eaten-count 0
- (id)initWithImage:(UIImage *)image
{
self = [super init];
if (self) {
[self setClipsToBounds:YES];
[self setAutoresizesSubviews:YES];
[self setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
CGImageRef originalImage = [image CGImage];
_image = image;
@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."
@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 / sudoku.clj
Created November 21, 2011 03:52 — forked from jkk/sudoku.clj
;;;; Translation of Peter Norvig's sudoku solver to idiomatic Clojure
;;;; See http://norvig.com/sudoku.html
;;;;
;;;; Throughout this program we have:
;;;; r is a row, e.g. :a
;;;; c is a column, e.g. 3
;;;; s is a square, e.g. [:a 3]
;;;; d is a digit, e.g. 9
;;;; u is a unit, e.g. [[:a 1] [:b 1] [:c 1] ... [:i 1]]
;;;; grid is a grid, e.g. 81 non-blank chars, e.g. starting with ".18...7..."
(defn bytes2hex [^bytes bytes]
(.toString
(let [alpha "0123456789ABCDEF"]
(areduce bytes idx ret (StringBuilder.)
(doto ret
(.append (.charAt alpha (int (bit-shift-right (aget bytes idx) 4))))
(.append (.charAt alpha (int (bit-and (aget bytes idx) 0xf)))))))))
(def byte-table
(delay ;don't generate the byte array unless needed