Skip to content

Instantly share code, notes, and snippets.

//
// ImageSwitcher.h
//
// Created by syxc on 02/25/13.
// Copyright (c) 2013 Straw. All rights reserved.
//
@interface ImageSwitcher : UIView <UIScrollViewDelegate> {
CGRect viewSize;
UIScrollView *scrollView;
@syxc
syxc / UIColor+Hex.h
Last active December 14, 2015 21:18 — forked from ohsc/UIColor+Hex.h
//
// UIColor+Hex.h
//
//
// Created by Shen Chao on 11-12-31.
// Copyright (c) 2011年 Test. All rights reserved.
//
#import <UIKit/UIKit.h>
@syxc
syxc / DeviceCheck.h
Created April 16, 2013 07:00
How to check iPhone Device Version in iOS?
// via http://stackoverflow.com/a/13068238/1242183
#define HEIGHT_IPHONE_5 568
#define IS_IPHONE ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_5 ([[UIScreen mainScreen] bounds ].size.height == HEIGHT_IPHONE_5 )
// then just check whenever you needs..
if (IS_IPHONE_5) {
// Code for iPhone5
//
// UIImage+Network.h
// Fireside
//
// Created by Soroush Khanlou on 8/25/12.
//
//
#import <UIKit/UIKit.h>
@syxc
syxc / MessageDetailViewController.m
Created May 17, 2013 02:45
How to remove grey shadow on the top UIWebView when overscroll?
for (id subview in webView.subviews) {
if ([[subview class] isSubclassOfClass:[UIScrollView class]]) {
for (UIView *scrollSubview in [subview subviews]) {
if ([[scrollSubview class] isSubclassOfClass:[UIImageView class]]) {
scrollSubview.hidden = YES;
}
}
}
}
@syxc
syxc / zepto.fittext.js
Created May 17, 2013 10:13
Zepto.FitText.js
/*global jQuery */
/*!
* FitText.js 1.1
*
* Copyright 2011, Dave Rupert http://daverupert.com
* Released under the WTFPL license
* http://sam.zoy.org/wtfpl/
*
* Date: Thu May 05 14:23:00 2011 -0600
*/
class Backend(object):
def __init__(self):
engine = create_engine("mysql://{0}:{1}@{2}/{3}".format(options.mysql_user, options.mysql_pass, options.mysql_host, options.mysql_db)
, pool_size = options.mysql_poolsize
, pool_recycle = 3600
, echo=options.debug
, echo_pool=options.debug)
self._session = sessionmaker(bind=engine)
@classmethod
#!upstart
description "Sitename-state"
author "Ben Gourley"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn # restart when job dies
respawn limit 5 60 # give up restart after 5 respawns in 60 seconds
$(function () {
"use strict";
// for better performance - to avoid searching in DOM
var content = $('#content');
var input = $('#input');
var status = $('#status');
// my color assigned by the server
var myColor = false;
@syxc
syxc / AppUtil.m
Created June 18, 2013 09:37
How to get the size of a UITableView's content view?
#pragma mark - How to get the size of a UITableView's content view?
#define CGSizesMaxWidth(sz1, sz2) MAX((sz1).width, (sz2).width)
#define CGSizesAddHeights(sz1, sz2) (sz1).height + (sz2).height
+ (CGSize)sizeForTableView:(UITableView *)tableView
{
CGSize tableViewSize = CGSizeMake(0, 0);
NSInteger numberOfSections = [tableView numberOfSections];
for (NSInteger section = 0; section < numberOfSections; section++) {