Skip to content

Instantly share code, notes, and snippets.

@cdzombak
cdzombak / README.md
Created September 28, 2010 21:43
recursive ksort function for PHP
@cdzombak
cdzombak / README.md
Created September 28, 2010 21:45
Redirect visitors to a domain without affecting OpenID

You may want to redirect (HTTP 301) visitors from a site which acts as an OpenID endpoint. Of course, you don't want to break everything which relies on that OpenID endpoint.

There is no definitive way to tell whether the client is an OpenID client or a human visitor, but you can look for certain criteria which are usually signs that the client isn't a standard Web browser.

This set of .htaccess rules should accomplish this in most cases. I've put this together based on a few examples online plus my own testing with a few OpenID clients.

@cdzombak
cdzombak / README.md
Created May 9, 2011 03:44
check whether an element is currently visible (JS)

This is a small Javascript function which tells you whether an HTML element is currently visible - that is, whether or not it's been scrolled out of view on the page.

This function requires jQuery.

package com.cguild.stopon500;
import java.util.concurrent.atomic.AtomicInteger;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
@cdzombak
cdzombak / gist:1452149
Created December 9, 2011 16:08
Git intro links
* http://eagain.net/articles/git-for-computer-scientists/
* http://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide
* http://gitref.org/
* http://gitready.com/
* http://progit.org/book/
* http://book.git-scm.com/
* http://schacon.github.com/git/user-manual.html
* http://www-cs-students.stanford.edu/~blynn/gitmagic/
And a few tutorial/cheat sheet style references:
@cdzombak
cdzombak / hideyokids.txt
Created March 22, 2012 18:50
Cougar on North Campus
Delivered-To: chris@chrisdzombak.net
Received: by 10.223.116.142 with SMTP id m14csp86053faq;
Thu, 22 Mar 2012 10:56:13 -0700 (PDT)
Received: by 10.50.192.202 with SMTP id hi10mr2747102igc.3.1332438972973;
Thu, 22 Mar 2012 10:56:12 -0700 (PDT)
Return-Path: <targetemail@umich.edu>
Received: from gremlins.mr.itd.umich.edu (gremlins.mr.itd.umich.edu. [141.211.14.24])
by mx.google.com with ESMTP id cf2si2712340igb.24.2012.03.22.10.56.12;
Thu, 22 Mar 2012 10:56:12 -0700 (PDT)
@cdzombak
cdzombak / if.m
Created June 19, 2012 15:19
switch vs if with pointers (if C allowed switch on ptrs)
// `item` is a UINavigationItem*
if (item == self.welcomeNavItem) {
return NO;
}
else if (item == self.emailNavItem) {
[self transitionToWelcomeScreen:YES];
return YES;
}
else if (item == self.passwordNavItem) {
@cdzombak
cdzombak / gist:3860927
Last active October 11, 2015 12:47 — forked from andrewsardone/gist:3859525
enum types in C/Objective-C
// unpredictable backing type for this enum
typedef enum {
CDZTypePhone,
CDZTypeEmail
} CDZType;
// vs.
enum {
CDZTypePhone,
@cdzombak
cdzombak / CDZTableViewSplitDelegate.h
Created January 4, 2013 17:16
Separate concerns. `UIScrollViewDelegate` deals with a container, while `UITableViewDelegate` deals with content. It's often useful to have two different objects manage these concerns, but Cocoa Touch makes it difficult since `UITableViewDelegate` conforms to `UIScrollViewDelegate` and `UITableView` has only one delegate property. `CDZTableViewS…
#import <Foundation/Foundation.h>
@interface CDZTableViewSplitDelegate : NSObject <UIScrollViewDelegate, UITableViewDelegate>
@property (nonatomic, weak) id<UITableViewDelegate> tvDelegate;
@property (nonatomic, weak) id<UIScrollViewDelegate> svDelegate;
- (id)initWithScrollViewDelegate:(id<UIScrollViewDelegate>)scrollViewDelegate tableViewDelegate:(id<UITableViewDelegate>)tableViewDelegate;
@end
@cdzombak
cdzombak / gist:5058153
Created February 28, 2013 16:52
name.com shadiness
> dig NS chrisdzombak.net
; <<>> DiG 9.8.3-P1 <<>> NS chrisdzombak.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29020
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;chrisdzombak.net. IN NS