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 / MUtility.m
Created February 17, 2011 14:28
MUtility.h
#import "MUtility.h"
@implementation MUtility
+ (int)randomNumber
{
srandom(time(NULL));
return random()%100 +1;
@marshluca
marshluca / authorize.php
Created February 17, 2011 09:15
腾讯微薄OAuth授权
<!-- 这里是OAuth入口 -->
<?php
@header('Content-Type:text/html;charset=utf-8');
session_start();
require_once('config.php'); //配置AppKey, AppSecret
require_once('oauth.php');
require_once('opent.php');
$o = new MBOpenTOAuth( MB_AKEY , MB_SKEY );
@marshluca
marshluca / find_locate_whereis_which_type.shell
Created February 16, 2011 10:27
linux的5个查找命令:find,locate,whereis,which,type
1. find
find是最常见和最强大的查找命令,你可以用它找到任何你想找的文件。
find的使用格式如下:
  $ find <指定目录> <指定条件> <指定动作>
  - <指定目录>: 所要搜索的目录及其所有子目录。默认为当前目录。
@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 / sql_statement_in_mysql.txt
Created February 16, 2011 10:04
MySQL中常用SQL
//主键
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
//增加一个新列
alter table t2 add d timestamp;
alter table infos add ex tinyint not null default '0';
//删除列
alter table t2 drop column c;
@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 / douban_comment.rb
Created February 16, 2011 07:35
豆瓣自动顶贴
require 'rubygems'
require 'mechanize'
def comment_douban_topic(url,text)
login_url = "http://www.douban.com/login"
agent = Mechanize.new
# agent.set_proxy("218.201.21.176","80")
agent.user_agent_alias = "Googlebot"
page = agent.get(login_url)
@marshluca
marshluca / sources.list
Created February 16, 2011 02:24
sources.list for ubuntu 8.10
deb http://debian.ustc.edu.cn/ubuntu/ jaunty main restricted universe multiverse
deb http://debian.ustc.edu.cn/ubuntu/ jaunty-security main restricted universe multiverse
deb http://debian.ustc.edu.cn/ubuntu/ jaunty-updates main restricted universe multiverse
deb http://debian.ustc.edu.cn/ubuntu/ jaunty-proposed main restricted universe multiverse
deb http://debian.ustc.edu.cn/ubuntu/ jaunty-backports main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ jaunty main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ jaunty-security main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ jaunty-updates main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ jaunty-proposed main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ jaunty-backports main restricted universe multiverse
@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