Skip to content

Instantly share code, notes, and snippets.

View HamGuy's full-sized avatar
🎯
Focusing

HamGuy HamGuy

🎯
Focusing
View GitHub Profile
package com.yugy.v2ex.daily.sdk;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.PersistentCookieStore;
@HamGuy
HamGuy / BDHost.m
Last active August 29, 2015 14:10 — forked from amcgregor/BDHost.m
// From: http://www.bdunagan.com/2009/11/28/iphone-tip-no-nshost/
// MIT license
// Remember to add CFNetwork.framework to your project using Add=>Existing Frameworks.
#import "BDHost.h"
#import <CFNetwork/CFNetwork.h>
#import <netinet/in.h>
#import <netdb.h>
#import <ifaddrs.h>
@HamGuy
HamGuy / CATextLayer+NumberJump.m
Last active August 29, 2015 14:10
余额宝数字动画效果,基于https://github.com/PigRiver/NumberJumpDemo 简单修改
//
// CATextLayer+NumberJump.m
// HGCodeScanner
//
// Created by HamGuy on 12/8/14.
// Copyright (c) 2014 HamGuy. All rights reserved.
//
#import "CATextLayer+NumberJump.h"
#import "NJDBezierCurve.h"
import Foundation
extension String
{
var length: Int {
get {
return countElements(self)
}
}
// Playground - noun: a place where people can play
import Cocoa
extension NSRange {
init(location:Int, length:Int) {
self.location = location
self.length = length
}
/* = Add a "molly guard" to the publish button */
add_action( 'admin_print_footer_scripts', 'sr_publish_molly_guard' );
function sr_publish_molly_guard() {
echo <<<EOT
<script>
jQuery(document).ready(function($){
$('#publishing-action input[name="publish"]').click(function() {
if(confirm('Are you sure you want to publish this?')) {
return true;
#!/usr/bin/env ruby -w
class String
def starts_with?(prefix)
prefix.respond_to?(:to_str) && self[0, prefix.length] == prefix
end
end
HEADER_REGEX = /^#import\s+["<](.*)[">]/
@HamGuy
HamGuy / gist:f013882fb42243effbee
Last active August 29, 2015 14:16 — forked from irace/gist:5272146
A UISwitch that can’t be toggled through user interaction
@interface UntoggleableSwitch : UISwitch
@end
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
@interface NSCodingSearchBar : UISearchBar
// Default by the system is YES.
// https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UISearchBar.h
@property (nonatomic, assign, setter = setHasCentredPlaceholder:) BOOL hasCentredPlaceholder;
@end