Skip to content

Instantly share code, notes, and snippets.

View marshluca's full-sized avatar
🏠
Working from home

Lucas Zhang marshluca

🏠
Working from home
View GitHub Profile
@pokeb
pokeb / gist:150447
Created July 20, 2009 17:03
An example showing how to manage a queue with ASIHTTPRequest
//
// MyController.h
//
// Created by Ben Copsey on 20/07/2009.
// Copyright 2009 All-Seeing Interactive. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GHUnit/GHUnit.h>
@class ASINetworkQueue;
# Reincarnation for classes
class Class
def reincarnate
buried = Object.__send__(:remove_const, self.name)
Object.const_set(self.name, Class.new(buried))
end
end
class Abc
@marshluca
marshluca / define_class_dynamiclly.rb
Created February 23, 2010 05:54
动态定义class,连接database, 打印ddl
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:database => "myapp",
:username => "root",
:password => "root",
:encoding => "utf8")
@marshluca
marshluca / BonFire.m
Created March 9, 2010 10:40
iPhone中用图片流制作动画
- (void)viewDidLoad {
[super viewDidLoad];
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:self.view.frame];
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"campFire01.gif"],
[UIImage imageNamed:@"campFire02.gif"],
[UIImage imageNamed:@"campFire03.gif"],
[UIImage imageNamed:@"campFire04.gif"],
[UIImage imageNamed:@"campFire05.gif"],
@marshluca
marshluca / renren_api.rb
Created June 4, 2010 08:05
使用json,net/http解析人人API
require "net/http"
require "json"
USER = 'marshluca@163.com'
PASS = '123456'
API_URL = "http://api.renren.com/restserver.do"
def base_params
{
"api_key" => "f2570a570d56439784bfb69dbda699d1",
@marshluca
marshluca / new_tweet.m
Created July 31, 2010 02:22
Post like the new tweet view in twitter for iPhone
#import "PostViewController.h"
#import "WoyiAppDelegate.h"
#import "ImagePickerController.h"
@implementation PostViewController
#pragma mark -
#pragma mark Initialization
@toastdriven
toastdriven / rebuild_environment.sh
Last active December 3, 2019 19:12
Rebuild Environment
brew install git
brew update
brew install readline
brew link readline
brew install python
brew install postgres
brew install tmux
brew install pip
brew install nginx
brew install libevent
@marshluca
marshluca / compute.rb
Created August 8, 2010 12:54
pass ball in ruby
# ruby
def compute(current,remain)
result = 0
if remain == 0
result = current == 'a' ? 1 : 0
else
for n in ['a','b','c','d']
result += compute(n,remain-1) if n != current
end
@marshluca
marshluca / ruby_constant.rb
Created August 12, 2010 01:52
constant in Rails
Loading development environment (Rails 2.3.8)
>> Rails.env
=> "development"
>> RAILS_ENV
=> "development"
>> RUBY_VERSION
=> "1.8.7"
@marshluca
marshluca / MongoDB.sh
Created August 13, 2010 04:09
MongoDB init script
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.