Skip to content

Instantly share code, notes, and snippets.

View pj4533's full-sized avatar

PJ Gray pj4533

View GitHub Profile
@pj4533
pj4533 / UIBarButtonItem+ETBlockActions.h
Created September 20, 2012 14:16
Respond to button events with blocks
#import <UIKit/UIKit.h>
@interface UIBarButtonItem (ETBlockActions)
- (id) initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style eventHandler:(void(^)(void))handler;
@end
@pj4533
pj4533 / gist:5108112
Last active December 14, 2015 15:29
Example AFHTTPClient request
[client getPath:path parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
// put a breakpoint for curlme here
NSLog("awesome stuff: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog("fail bro");
}];
@pj4533
pj4533 / lldbinit
Created March 7, 2013 13:46
lldbinit
command regex curlme 's/(.+)/po [TTTURLRequestFormatter cURLCommandFromURLRequest:%1]/'
import UIKit
class Foo: NSObject {
struct Shared {
static var Instance: Foo = Foo()
}
}
@pj4533
pj4533 / example_image_search.swift
Created March 22, 2018 13:39
Example reverse google image search to discogs lookup
func searchUsingImage(image: UIImage) {
if let imageData: NSData = UIImageJPEGRepresentation(image, 0.7) {
SVProgressHUD.showWithStatus("Searching...")
Alamofire.upload(
.POST,
"https://images.google.com/searchbyimage/upload",
multipartFormData: { multipartFormData in
multipartFormData.appendBodyPart(data: imageData, name: "encoded_image")
},
@pj4533
pj4533 / travis_build.sh
Created May 8, 2018 12:53
Quick script to parse the travis YAML and build
#!/usr/bin/env ruby
require 'travis/yaml'
require 'open3'
content = File.read('.travis.yml')
Travis::Yaml.parse! content do |config|
cmd = "#{config[:script]}"
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
@pj4533
pj4533 / travis_status.sh
Created May 9, 2018 12:49
Quick script to get status of a travis repo from the SVG link on the command line
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
html_data = open(ARGV[0]).read
@test = Nokogiri::HTML(html_data)
status_string = @test.xpath('//text').map.each.each { |i| i.inner_text }.last
color_code = 31 # red
@pj4533
pj4533 / lldbjson
Created May 22, 2018 12:47
lldb JSON helpers
command regex jo 's/(.+)/po print(String(data: try! JSONSerialization.data(withJSONObject: %1, options: .prettyPrinted), encoding: .utf8 )!)/'
command regex jobj 's/(.+)/po [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:%1 options:nil error:nil] encoding:nil]/'
@pj4533
pj4533 / create_table.sql
Created April 8, 2019 17:04
Table structure for New York state Board of Elections data
CREATE TABLE `state_boe` (
`LASTNAME` varchar(255) DEFAULT NULL,
`FIRSTNAME` varchar(255) DEFAULT NULL,
`MIDDLENAME` varchar(255) DEFAULT NULL,
`NAMESUFFIX` varchar(255) DEFAULT NULL,
`RADDNUMBER` varchar(255) DEFAULT NULL,
`RHALFCODE` varchar(255) DEFAULT NULL,
`RAPARTMENT` varchar(255) DEFAULT NULL,
`RPREDIRECTION` varchar(255) DEFAULT NULL,
`RSTREETNAME` varchar(255) DEFAULT NULL,
SELECT
`state_boe_012219`.`COUNTYVRNUMBER`,
`state_boe_012219`.`VOTER_HISTORY`
FROM `state_boe_012219`
WHERE (`state_boe_012219`.`STATUS` = 'ACTIVE')