Skip to content

Instantly share code, notes, and snippets.

@abrahamvegh
abrahamvegh / CSTextCell.m
Created April 28, 2011 17:34 — forked from asmallteapot/CSTextCell.m
Trying to figure out how I’m doing cell recycling wrong.
#import <UIKit/UIKit.h>
// Including the .h and .m file together for simplicity’s sake.
// yes, this is a horrific abuse of ObjC
@interface CSTextCell : UITableViewCell {
}
+ (id)generate:(UITableView *)tableView at:(NSIndexPath *)indexPath text:(NSString *)text;
+ (NSString *)cellID;
@abrahamvegh
abrahamvegh / iPad2-White-WiFi-Target-Availability.sh
Created April 22, 2011 06:17
I swear I don’t know how this even works.
#!/bin/sh
while [ 1 ]
do
clear
echo "iPad 2 Wi-Fi White 16GB: "
# This magic courtesy of Garrett Murray: http://log.maniacalrage.net/post/4030658171/tip-how-to-get-an-ipad-2-at-target-today-i
# Thanks Garrett! I have barely an idea of how this works, but it is truly brilliant! :)
curl -s --data "_dyncharset=ISO-8859-1&asin=&dpci=057-10-1839&zipcode=YOUR_ZIP_CODE_GOES_HERE_BUB&city=&state=" http://sites.target.com/site/en/spot/mobile_fiats_results.jsp?_DARGS=/site/en/spot/mobile_fiats.jsp | grep -A 2 strong | sed -e 's/<p><strong>//' -e 's/<\/strong><br\/>//' -e 's/<br \/>//' -e 's/<\/p>//' -e 's/--//' -e 's/^[ \t]*//;s/[ \t]*$//' > ipad2-white.results
@abrahamvegh
abrahamvegh / view-on-favstar.js
Created April 17, 2011 05:54
Redirects you from a tweet on Twitter.com to the same tweet on Favstar.FM
javascript:(function(){if%20%28window.location.host%20%3D%3D%20%27twitter.com%27%29%7Ba%20%3D%20location.hash%3Bif%20%28a%20%3D%3D%20%27%27%29%7Ba%20%3D%20location.pathname%3B%7Da%20%3D%20a.split%28%27/%27%29%3Bb%20%3D%20a%5Ba.length%20-%201%5D%3Blocation.href%20%3D%20%27http%3A//favstar.fm/t/%27%20+%20b%3B%7D})();
@abrahamvegh
abrahamvegh / UITextFieldDelegateObject.m
Created January 16, 2011 02:00
If there’s a better way to do this, I’ll eat my code.
- (BOOL) textField: (UITextField *) textField shouldChangeCharactersInRange: (NSRange) range replacementString: (NSString *) string
{
([(textField == self.serverField ? self.emailField : self.serverField).text length] > 0 &&
[(textField == self.passwordField ? self.emailField : self.passwordField).text length] > 0 &&
[[textField.text stringByReplacingCharactersInRange: range withString: string] length] > 0
) ? (self.navigationItem.rightBarButtonItem.enabled = YES) : (self.navigationItem.rightBarButtonItem.enabled = NO) ;
return YES;
}
@abrahamvegh
abrahamvegh / NavigationDelegate.h
Created January 2, 2011 18:57
Method name WTF-ery
- (void) navigationController: (UINavigationController *) navigationController shouldStartActivityForViewController: (UIViewController *) viewController;
- (void) navigationController: (UINavigationController *) navigationController shouldStartActivityForViewController: (UIViewController *) viewController withMessage: (NSString *) message;
- (void) navigationController: (UINavigationController *) navigationController shouldStopActivityForViewController: (UIViewController *) viewController;
MyObject *obj = [[MyObject alloc] init];
obj.property = @"OK";
[obj doSomething];
NSLog(@"%@", obj);
<?php
function isset_and_is($a,$b,$c){$d=&$GLOBALS['_'.strtoupper($a)];return isset($d[$b])&&$d[$b]==$c;}
1. How do you put a giraffe into a refrigerator?
Stop and think about it and decide on your answer before you scroll down.
The correct answer is: Open the refrigerator, put in the giraffe, and close the door. This question tests whether you tend to do simple things in an overly complicated way.
2. How do you put an elephant into a refrigerator?
Did you say, Open the refrigerator, put in the elephant, and close the refrigerator?
<?php
/**
* Quick-and-dirty password generator, fully-commented edition ;)
*
* Author: Abraham Vegh <[email protected]>
*/
// Our password generator, with a default length of eight
function random_password ($length = 8)
{