Skip to content

Instantly share code, notes, and snippets.

View HamGuy's full-sized avatar
🎯
Focusing

HamGuy HamGuy

🎯
Focusing
View GitHub Profile
@HamGuy
HamGuy / ValidateCard.m
Last active December 22, 2015 09:29
Check the credit card is valid or not with ISO 2894 http://en.wikipedia.org/wiki/Luhn_algorithm
-(BOOL) validateCardNumber:(NSString *)str
{
BOOL result = NO;
str = [self replaceString:str withString:@"" withPattern:@"[^\\d]"];
if(str!=nil && str.length>0)
{
int num=0;
int weight = (str.length % 2 == 0 )?2:1;
int total=0;
int tmp=0;
@HamGuy
HamGuy / SuspensionManager.cs
Created October 9, 2013 02:32
SuspensionManager Windows Metro app 挂起状态管理器
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.Storage;
using Windows.Storage.Streams;
@HamGuy
HamGuy / doxgen.rb
Last active December 25, 2015 13:49
XCode注释服务
#!/usr/bin/env ruby
#
# This script helps you make doxygen comments in Obj-C/C/C++ files in XCode
#
# Created by Fred McCann on 03/16/2010 - and Edwin.
# Adapted for ThisService by Martin Pichlmair 03/29/2011
# http://www.duckrowing.com
#
require 'fileutils'
require 'date'
require 'yaml'
require 'rexml/document'
require 'ya2yaml'
include REXML
doc = Document.new(File.new(ARGV[0]))
@HamGuy
HamGuy / nsdate.m
Last active December 30, 2015 08:19
这些时间从API解析下来的时间格式都为 yyyy-MM-dd HH:mm:ss(比如:2013-03-09 09:51:22),通过在API上获取文章时间后经过算法转换而得到,在客户端源码的Tool.m中+ (NSString *)intervalSinceNow: (NSString *) theDate 实现这一个方法: 如果信息发表在1小时之前显示分钟,一天之内的信息显示小时,10天之内按天显示,10天之外安所发表时间进行显示: source:http://blog.csdn.net/duxinfeng2010/article/details/8653411
+ (NSString *)intervalSinceNow: (NSString *) theDate
{
NSDateFormatter *date=[[NSDateFormatter alloc] init];
[date setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *d=[date dateFromString:theDate];
NSTimeInterval late=[d timeIntervalSince1970]*1;
NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0];
NSTimeInterval now=[dat timeIntervalSince1970]*1;
NSString *timeString=@"";
NSTimeInterval cha=now-late;
@HamGuy
HamGuy / win8backup.bat
Created January 2, 2014 01:37
Windows 8 备份激活
@echo off
title Windows 8 备份激活批处理 By 柳飘清枫
call :admintest
echo.
echo 此工具会备份/还原您电脑上的 Windows 8 激活信息
echo 还原之前需要把备份的 store 文件夹放到桌面上再运行此文件
echo.
choice /C 12 /N /M "继续请按 1,退出请按 2"
IF ERRORLEVEL 2 exit
IF ERRORLEVEL 1 goto :menu
// Copyright (c) Attack Pattern LLC. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
using System;
using System.Linq;
using System.Threading.Tasks;
using Windows.Devices.Enumeration.Pnp;
using Windows.System;
@HamGuy
HamGuy / appcrush.rb
Created February 24, 2014 15:52 — forked from zachwill/appcrush.rb
#!/usr/bin/ruby -rubygems
#
# Point appcrush at an .ipa file from the iTunes AppStore and it
# - expands the zip file
# - finds all the images
# - runs pngcrush with the revert-iphone-optimizations option on each image
#
# Requirements Xcode with iOS SDK 3.2 or higher
#
# Usage: appcrush '/Users/boctor/Music/iTunes/Mobile Applications/iBooks.ipa'
@HamGuy
HamGuy / git.md
Created April 2, 2014 03:23 — forked from suziewong/git.md

github的多人协作

  1. github上你可以用别人的现成的代码 直接 git clone 即可了

  2. 然后你也想改代码或者贡献代码咋办?

Fork

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation