Skip to content

Instantly share code, notes, and snippets.

class ImagecommitController < ApplicationController
before_filter :find_svn_modify
def index
@result = "SVN仓库没有改变!" and return unless @is_modify
end
def commit
unless @is_modify
@xhan
xhan / PlayMidiDemoViewController.h.m
Created October 5, 2009 15:17
a demo to show how to enable iPhone play MIDI
//
// PlayMidiDemoViewController.h
// PlayMidiDemo
//
// Created by xhan on 9/9/09.
// Copyright In-Blue 2009. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "fmod.hpp"
@xhan
xhan / Base64Encoding Function
Created October 13, 2009 02:58
apps in iphone send email with images
- (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength data:(NSData *)imgData {
static const char *encodingTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const unsigned char *bytes = [imgData bytes];
NSMutableString *result = [NSMutableString stringWithCapacity:[imgData length]];
unsigned long ixtext = 0;
unsigned long lentext = [imgData length];
long ctremaining = 0;
unsigned char inbuf[3], outbuf[4];
short i = 0;
@xhan
xhan / imagecommit_controller.rb
Created October 22, 2009 05:58
redmine image svn system
class ImagecommitController < ApplicationController
before_filter :find_svn_modify
def index
@result = "SVN仓库没有改变!" and return unless @is_modify
end
def commit
unless @is_modify
@xhan
xhan / SlideShowLayer.h.m
Created November 19, 2009 06:44
SlideShow on Cocos2d-iphone
/*
* SlideShowLayer by Will Larson and Luke Hatcher. 10/29/2008.
* Released under MIT License.
* Please check out from repository for full license detail.
*
* Nothing too exiting happening here.
* Apologies that it is not in Obj2.0
* syntax, but I'm still ambivalent about
* the ambiguousness of properties.
*/
@xhan
xhan / 2 triggers' relationship.cs
Created May 6, 2010 17:06
2 triggers' relationship -> unity3d
public enum TriggerState
{
Init,
Running,
Finished
}
public class MixerTriggerScript : MonoBehaviour {
public PieJuiceTriggerScript anotherTrigger;
public TriggerState state = TriggerState.Init;
@xhan
xhan / README.mdown
Created September 19, 2010 08:06
a script to automatic do follow action to sepcify users for baidu's microblog service "百度说吧" , check the readme file before use!

#README

#description ** do something evil as you want to **

steps not one by one

  • login with your account via any web brower
  • use some tools to get your cookies
  • pastie the cookies string into scripts
@xhan
xhan / gist:730001
Created December 6, 2010 08:01
Update Adium status
tell application "Adium"
go available with message "test again" -- or away or invisible
end tell
@xhan
xhan / NSDropContainer.h
Created May 7, 2011 14:39
NSDropContainer
//
// NSDropContainer.h
#import <Cocoa/Cocoa.h>
@protocol NSDropContainerDelegate;
@interface NSDropContainer : NSBox {
id<NSDropContainerDelegate> _delegate;
@xhan
xhan / .profile
Created May 24, 2012 06:43
cd to current Xcode's project folder in Terminal
function cdxcode()
{
path="`osascript ~/Codes/scripts/cdxcode.scpt 2>/dev/null`"
if [ -n "$path" ]; then
echo "cd to $path"
cd "$path"
else
echo "no Xcode Project finded"
fi
}