Bash 使用scp复制文件

scp user@host:/directory/SourceFile TargetFile

PHP 为wordpress角色添加功能

function update_caps()
    {
    $role = get_role( 'editor' );

    $caps_to_add =  array(
        'delete_users',
        'create_users',
        'list_users',
        'remove_users',
        'add_users',
        'promote_users',
    );



    foreach( $caps_to_add as $cap )
        $role->add_cap( $cap );

    }

PHP 如何在没有oAuth的情况下使用php和Curl更改Twitter的状态

function twitterSetStatus($user,$pwd,$status) {
	if (!function_exists("curl_init")) die("twitterSetStatus needs CURL module, please install CURL on your php.");
	$ch = curl_init();

	// -------------------------------------------------------
	// get login form and parse it
	curl_setopt($ch, CURLOPT_URL, "https://mobile.twitter.com/session/new");
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_FAILONERROR, 1);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 5);
	curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
	curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3 ");
	$page = curl_exec($ch);
	$page = stristr($page, "<div class='signup-body'>");
	preg_match("/form action=\"(.*?)\"/", $page, $action);
	preg_match("/input name=\"authenticity_token\" type=\"hidden\" value=\"(.*?)\"/", $page, $authenticity_token);

	// -------------------------------------------------------
	// make login and get home page
	$strpost = "authenticity_token=".urlencode($authenticity_token[1])."&username=".urlencode($user)."&password=".urlencode($pwd);
	curl_setopt($ch, CURLOPT_URL, $action[1]);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $strpost);
	$page = curl_exec($ch);
	// check if login was ok
	preg_match("/\<div class=\"warning\"\>(.*?)\<\/div\>/", $page, $warning);
	if (isset($warning[1])) return $warning[1];
	$page = stristr($page,"<div class='tweetbox'>");
	preg_match("/form action=\"(.*?)\"/", $page, $action);
	preg_match("/input name=\"authenticity_token\" type=\"hidden\" value=\"(.*?)\"/", $page, $authenticity_token);

	// -------------------------------------------------------
	// send status update
	$strpost = "authenticity_token=".urlencode($authenticity_token[1]);
	$tweet['display_coordinates']='';
	$tweet['in_reply_to_status_id']='';
	$tweet['lat']='';
	$tweet['long']='';
	$tweet['place_id']='';
	$tweet['text']=$status;
	$ar = array("authenticity_token" => $authenticity_token[1], "tweet"=>$tweet);
	$data = http_build_query($ar);
	curl_setopt($ch, CURLOPT_URL, $action[1]);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	$page = curl_exec($ch);

	return true;
}

C# 删除非ASCII字符

s = Regex.Replace(s, @"[^\u0000-\u007F]", "");

PHP 在Cakephp中显示一个Model模式

pr( $this->User->schema() );

ActionScript 3 简单的TextFormat Manager AS3

package com.leongaban.Snipplr.Model
{
	import flash.text.Font;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	import flash.text.TextFieldAutoSize;
	import flash.text.*;
	
	public class Fonts
	{
		public static var data:Object   = {};
		public static var customFormat1 = new TextFormat();
		public static var customFormat2 = new TextFormat();
		
		customFormat1.font      = "Arial";
		customFormat1.size      = 14;
		customFormat1.bold      = true;
		customFormat1.color     = 0x000000;
		customFormat1.align     = TextFormatAlign.LEFT;
		
		customFormat2.font     = "Arial";
		customFormat2.size     = 11;
		customFormat2.bold     = false;
		customFormat2.color    = 0x000000;
		customFormat2.align    = TextFormatAlign.LEFT;
	}
}


// How to use in other Classes:

/*videoTitle.defaultTextFormat = Fonts.customFormat1;
videoTitle.border = false;
videoTitle.embedFonts = false;
videoTitle.selectable = false;
videoTitle.mouseEnabled = false;
videoTitle.x = 5;
videoTitle.y = 8;
videoTitle.width = titleSize;
videoTitle.height = 30;
videoTitle.text = titleString;

addChild(videoTitle);*/

JavaScript JS检测是否加载了img

/*
 * Special event for image load events
 * Needed because some browsers does not trigger the event on cached images.

 * MIT License
 * Paul Irish     | @paul_irish | www.paulirish.com
 * Andree Hansson | @peolanha   | www.andreehansson.se
 * 2010.
 *
 * Usage:
 * $(images).bind('load', function (e) {
 *   // Do stuff on load
 * });
 * 
 * Note that you can bind the 'error' event on data uri images, this will trigger when
 * data uri images isn't supported.
 * 
 * Tested in:
 * FF 3+
 * IE 6-8
 * Chromium 5-6
 * Opera 9-10
 */
(function ($) {
	$.event.special.load = {
		add: function (hollaback) {
			if ( this.nodeType === 1 && this.tagName.toLowerCase() === 'img' && this.src !== '' ) {
				// Image is already complete, fire the hollaback (fixes browser issues were cached
				// images isn't triggering the load event)
				if ( this.complete || this.readyState === 4 ) {
					hollaback.handler.apply(this);
				}

				// Check if data URI images is supported, fire 'error' event if not
				else if ( this.readyState === 'uninitialized' && this.src.indexOf('data:') === 0 ) {
					$(this).trigger('error');
				}
				
				else {
					$(this).bind('load', hollaback.handler);
				}
			}
		}
	};
}(jQuery));

Objective C 将两个NSURL组合在一起

combinedURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",firstUrl,secondUrl]];

Objective C iPhone SDK:检查文件存在

// check file exists..
BOOL isDirectory = NO;
if ( [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory: &isDirectory ] ) {
// use the file
} else {
// file not there
}

Apache 将所有外部流量重定向到临时页面

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_HOST} !^123\.45\.67\.89
RewriteCond %{REQUEST_URI} !/alternate_page\.html$
RewriteRule \.html$ /alternate_page.html [R=302,L]