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
@marshluca
marshluca / 107_js.txt
Created February 16, 2011 10:07
107条javascript常用小技巧
1.document.write(""); 输出语句
2.JS中的注释为//
3.传统的HTML文档顺序是:document->html->(head,body)
4.一个浏览器窗口中的DOM顺序是:window->(navigator,screen,history,location,document)
5.得到表单中元素的名称和值:document.getElementById("表单中元素的ID号").name(或value)
6.一个小写转大写的JS: document.getElementById("output").value = document.getElementById("input").value.toUpperCase();
7.JS中的值类型:String,Number,Boolean,Null,Object,Function
8.JS中的字符型转换成数值型:parseInt(),parseFloat()
9.JS中的数字转换成字符型:(""+变量)
10.JS中的取字符串长度是:(length)
@marshluca
marshluca / compress_and_decompress.txt
Created February 16, 2011 10:01
linux各种解压缩命令
.gz
解压1:gunzip FileName.gz
解压2:gzip -d FileName.gz
压缩:gzip FileName
.tar.gz
解压:tar zxvf FileName.tar.gz
压缩:tar zcvf FileName.tar.gz DirName
---------------------------------------------
.bz2
@marshluca
marshluca / call_url_in_php
Created February 12, 2011 09:58
call url in php
1.apt-get install php5-curl
2./etc/init.d/apache2 restart
3.curl.php:
<?
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, 'http://www.baidu.com/');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
@marshluca
marshluca / wordress_permalink
Created February 12, 2011 02:00
/etc/apache2/sites-enabled/000-default
@marshluca
marshluca / mutiThread.m
Created February 10, 2011 07:47
友盟多线程推送机制
//
// UMeng.m
// Gallery
//
// Created by marshluca on 11-2-10.
// Copyright 2011 www.5yi.com. All rights reserved.
//
#import "UMeng.h"
#import "MBase.h"
@marshluca
marshluca / unicorn.rb
Created February 3, 2011 07:03
unicorn+nginx配置
# Sample verbose configuration file for Unicorn (not Rack)
#
# This configuration file documents many features of Unicorn
# that may not be needed for some applications. See
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
# for a much simpler configuration file.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
@marshluca
marshluca / NSInvocationOperation.m
Created January 26, 2011 08:19
使用NSInvocationOperation 处理多线程
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Load"
style:UIBarButtonItemStyleDone
target:self
action:@selector(loadData)];
NSMutableArray *_array = [[NSMutableArray alloc] initWithCapacity:10000];
self.array = _array;
select * from sqlite_master where type='index';
drop index vegetables_name;
create index vegetables_name on vegetables(name);
insert into vegetables values ("luobo", "green", "nice luobo");
create table vegetables (name char not null, color char not null default 'green', description char);
@marshluca
marshluca / FMDB.m
Created December 29, 2010 01:41
Handle SQLite in Objc
#import <Foundation/Foundation.h>
#import "FMDatabase.h"
#import "FMDatabaseAdditions.h"
#define FMDBQuickCheck(SomeBool) { if (!(SomeBool)) { NSLog(@"Failure on line %d", __LINE__); return 123; } }
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// delete the old db.
@marshluca
marshluca / UIImageWriteToSavedPhotosAlbum.m
Created December 20, 2010 05:47
save image to local album
- (void)saveImageToAlbum
{
UIImage *image = currentPage.imageView.image;
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
if (error == nil)