Skip to content

Instantly share code, notes, and snippets.

View markrickert's full-sized avatar

Mark Rickert markrickert

View GitHub Profile
@markrickert
markrickert / SSZipArchiveUsage.m
Created September 14, 2011 14:32
SSZipArchive Usage
[SSZipArchive unzipFileAtPath:(NSString *)
toDestination:(NSString *)destinationFolderPath];
@markrickert
markrickert / ImageViewMadness.m
Last active September 27, 2015 05:08
Setting an ImageView from the web
imageView.image = [UIImage imageWithData:
[UIData dataWithContentsOfURL:
[NSURL urlWithString:
[NSString stringWithFormat:@"http://my.imageurl.com/imagepath/%@", imageName]
]
]
];
@markrickert
markrickert / SDWebImageUsage.m
Created September 14, 2011 14:38
SDWebImage Usage
[imageView setImageWithURL:(NSURL *)url];
@markrickert
markrickert / SBJSONUsage.m
Created September 14, 2011 14:38
SBJSON Usage
NSDictionary *myJsonDict = [parser objectWithString:myJSONString];
@markrickert
markrickert / iOSPeelAwayExample.m
Created September 14, 2011 14:42
iOS Peel-Away Example
- (IBAction) pressedPeelIt:(UIButton *)sender
{
//Disable the button so they can't press it
self.peelIt.enabled = NO;
[self.textHere resignFirstResponder];
//Create a new UIView and set the background color to be a UIColor with pattern image of a screen capture
UIView *imgView = [[UIView alloc] init];
[self.view addSubview:imgView];
@markrickert
markrickert / SafeZendTransactionsMysql.php
Created September 14, 2011 14:49
Safely Handling Mysql Transactions in Zend
<?php
// the below code assumes you have the private/protected
// variable $this->_db set to your database adapter.
// begin the transaction
$this->_db->beginTransaction();
try {
// mock insert into a user table
$result = $this->_db->insert('users', array(
@markrickert
markrickert / StateDropdownAutocomplete.js
Created September 14, 2011 14:53
State Dropdown With Autocompletion
$(function() {
// for storing states
var states = [];
// cache some elems
var $states = $('#state');
var $stateList = $('#state-list');
// hide the dropdown and pull values
$states.hide().find('option').each(function() {
@markrickert
markrickert / ZendCleanURL.php
Created September 14, 2011 14:56
Clean URL Generator for Zend
<?php
/**
* Generates a uristub of maximum specified length.
*
* @access protected
* @param string $tableName The name of the table to query
* @param string $tableField The table column to check
* @param string $uristub The initial input string (page title) to clean
* @param int $length The maximum allowable length for the clean url
* @param mixed $iteration The current iteration, when duplicates found
@markrickert
markrickert / MigrateWordpress.sql
Created September 14, 2011 15:00
Wordpress Migration SQL Script
#Update the crucial options
UPDATE wp_options
SET option_value = 'http://newdomain.com'
WHERE option_name in ('siteurl', 'home');
#Make sure search engines can access the deployed site
UPDATE wp_options
SET option_value = 1
WHERE option_name = 'blog_public';
#Set the GUIDs to have the correct domain
UPDATE wp_posts
@markrickert
markrickert / Highlander.js
Created September 14, 2011 15:01
There Can Be Only One...
function there_can_be_only_one_highlander(the_one) {
var state_speed = 500,
immortals = ['#welcome-box', '#guest-box', '#login-box', '#register-box'],
to_kill = [],
key = null;
for (key in immortals) {
if (immortals[key] !== the_one) {
if (typeof immortals[key] === 'string') {
to_kill.push(immortals[key]);