This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* FYSMysql.php Created on 2012-3-3 | |
* By Jason Lee | |
* | |
* 后面可以考虑抽象成模型,每个表对应一个Model子类,自动探测表结构,把错误检查放在Model中 | |
* | |
*/ | |
class FYSMysql { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
''' | |
Localization The Objective-C Code | |
@"..." --> NSLocalizedString(@"...", nil) | |
Jason Lee 2012-03-01 | |
''' | |
import os, sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view from its nib. | |
NSString *tweetText = [_tweet valueForKey:@"text"]; | |
NSString *userName = [_tweet valueForKeyPath:@"user.name"]; | |
NSString *userDescription = [_tweet valueForKeyPath:@"user.description"]; | |
NSNumber *friends = [_tweet valueForKeyPath:@"user.friends_count"]; | |
NSNumber *followers = [_tweet valueForKeyPath:@"user.followers_count"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//请实现下面的函数,输入参数baseStr是一个(可以更改的)字符串,请将其中所有连续出现的多个空格都替换成一个空格,单一空格需保留。 | |
//请直接使用baseStr的空间,如需开辟新的存储空间,不能超过o(N)(注意是小o,N是字符串的长度)。返回值是替换后的字符串的长度。 | |
//样例代码为C#,但可以使用任何语言。如需使用任何库函数,必须同时给出库函数的实现。 | |
class Program | |
{ | |
public static int RemoveMultipleSpaces(char[] baseStr) | |
{ | |
if (baseStr == null) | |
{ | |
throw new ArgumentNullException("baseStr"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Please write an sequence list implements the interface with the required | |
// time complexity described in the comments. The users can add the same | |
// element as many times as they want, but it doesn't support the null item. | |
// You can use any types in .NET BCL but cannot use any 3rd party libraries. | |
// PS: You don't need to consider the multi-threaded environment. | |
interface IMyList<T> : IEnumerable<T> | |
{ | |
// O(1) | |
// Add an item at the beginning of the list. | |
void AddFirst(T item); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Some sample code for a horizontal paged UIScrollView with a gap between each image (which looks nicer). Note - not using contentInset, we want each page to fill the iPhone screen and the gap only to be visible when scrolling (like Photos.app). | |
Taking the iPhone status bar into account - our viewport is 320x460 | |
Our UIScrollView is therefore set in Interface Builder to 340x460 with a -10 X offset (so it's larger than the viewport but still centred) | |
Then we do the following... | |
*/ | |
// Our image filenames |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSObject+PropertyListing.h | |
// PropertyFun | |
// | |
// Created by Andrew Sardone on 8/27/10. | |
// | |
#import <Foundation/Foundation.h> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - | |
#define DEFAULT_LOG_FILENAME @"log.log" | |
- (void)log:(NSString *)log | |
{ | |
#ifdef DEBUG | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *baseDir = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; | |
NSString *logPath = [baseDir stringByAppendingPathComponent:DEFAULT_LOG_FILENAME]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - | |
- (void)drawTestLine | |
{ | |
// test code : draw line between Beijing and Hangzhou | |
CLLocation *location0 = [[CLLocation alloc] initWithLatitude:39.954245 longitude:116.312455]; | |
CLLocation *location1 = [[CLLocation alloc] initWithLatitude:30.247871 longitude:120.127683]; | |
NSArray *array = [NSArray arrayWithObjects:location0, location1, nil]; | |
[self drawLineWithLocationArray:array]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import random | |
global compareCount | |
def swap(arr, l, r): | |
temp = arr[l] | |
arr[l] = arr[r] |
OlderNewer