Skip to content

Instantly share code, notes, and snippets.

View icyleaf's full-sized avatar
🍺
Diving into beer

icyleaf icyleaf

🍺
Diving into beer
View GitHub Profile
@icyleaf
icyleaf / remote.php
Created March 31, 2010 03:16
HTTP Request/Response Library
<?php
/**
* Provides remote server communications options using [curl][ref-curl].
*
* [ref-curl]: http://php.net/curl
*
* @author icyleaf <icyleaf.cn@gmail.com>
* @link http://icyleaf.com
* @version 0.3.1
* @license http://www.opensource.org/licenses/bsd-license.php
@icyleaf
icyleaf / kohana-3-rest-server-sample.php
Created April 23, 2010 07:40
RESTful by Kohana v3.0.x + Sprig
<?php defined('SYSPATH') or die('No direct script access.');
/**
* People API - Example Code
*
* @author icyleaf <icyleaf.cn@gmail.com>
* @link http://icyleaf.com
* @version 0.1
*/
class Controller_API_People extends Controller_REST {
@icyleaf
icyleaf / imgly.php
Created May 6, 2010 03:44
img.ly api package for kohana v3
<?php
/**
* img.ly class for Kohana v3.0.x
*
* @author icyleaf <icyleaf.cn@gmail.com>
* @link http://icyleaf.com
* @version 0.1
* @license http://www.opensource.org/licenses/bsd-license.php
*/
class imgly {
@icyleaf
icyleaf / Validate.php
Created June 10, 2010 08:26
Validate a Chinese ID
class Validate {
/**
* Validate a Chinese ID (18 digit ONLY).
* @param int ID
* @return boolean
*/
public static function chinese_id($id)
{
$id_length = strlen($id);
if ($id_length == 18)
@icyleaf
icyleaf / consumer_key.php
Created June 18, 2010 07:26
consumer_key
<?php
function new_consumer_key()
{
// in case /dev/urandom is reusing entropy from its pool, let's add a bit more entropy
$entropy = uniqid(mt_rand(), true);
$hash = sha1($entropy); // sha1 gives us a 40-byte hash
// The first 30 bytes should be plenty for the consumer_key
// We use the last 10 for the shared secret
return array(
@icyleaf
icyleaf / text.php
Created July 5, 2010 10:41
Parse HTML entries for allowed tags
<?php
/**
* Parse HTML entries for allowed tags
*
* @author icyleaf <icyleaf.cn@gmail.com>
* @version 0.1
*/
class Text extends Kohana_Text{
//don't parse anything in these tags
public static $literals = array('code', 'pre');
@icyleaf
icyleaf / post-receive.sh
Created September 6, 2010 07:55
git autodeploy script when it matches the string "[deploy]"
#!/bin/sh
#
# git autodeploy script when it matches the string "[deploy]"
#
# @author icyleaf <icyleaf.cn@gmail.com>
# @link http://icyleaf.com
# @version 0.1
#
# Usage:
# 1. put this into the post-receive hook file itself below
@icyleaf
icyleaf / download_alpaca.sh
Created January 9, 2011 03:24
This script is a helper that it will help you download Alpaca and initial structure to current path.
#!/bin/bash
#
# This script is a helper that it will help you download Alpaca and initial structure to current path.
# To install elsewhere you can just clone https://github.com/icyleaf/alpaca anywhere you like.
#
# AUTHOR icyleaf <icyleaf.cn@gmail.com>
# VERSION 0.1
#
echo "Clone the alpaca project from Github"
#!/bin/sh
# Change this line to the URI path of the xcode DMG file.
# XCode 3.2.5
#XCODE_PATH="/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg"
# XCode 4
#XCODE_PATH="/Developer_Tools/xcode_4_and_ios_sdk_4.3__final/xcode_4_and_ios_sdk_4.3__final.dmg"
@icyleaf
icyleaf / AndroidManifest.xml
Last active December 20, 2016 07:03
Android package based UMeng analytics
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<application ...>
<activity ...>
<meta-data android:name="UMENG_APPKEY" android:value="UMENG-API-KEY" />
<meta-data android:name="UMENG_CHANNEL" android:value="Development" />
</application>
<uses-permission android:name="android.permission.INTERNET" />