Skip to content

Instantly share code, notes, and snippets.

View ericsk's full-sized avatar

Eric ShangKuan ericsk

View GitHub Profile
@ericsk
ericsk / video.html
Created March 10, 2014 01:16
WebVTT Sample
<video src="sample.mp4" controls>
<track kind="subtitles" src="sub_enUS.vtt" srclang="en-us" label="English (US)" default>
<track kind="subtitles" src="sub_zhTW.vtt" srclang="zh-tw" label="正體中文">
</video>
@ericsk
ericsk / web.config
Created January 13, 2014 09:13
將 Lavarel 應用程式部署至 IIS/Windows Azure 時需要的 rewrite rule。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
@ericsk
ericsk / index.php
Created December 30, 2013 15:04
使用 WindowsAzureSessionHandler 的方法
require 'ericsk/WindowsAzure/WindowsAzureTableSessionHandler.php';
use ericsk\WindowsAzure\WindowsAzureTableSessionHandler;
$sessionHandler = new WindowsAzureTableSessionHandler(
'YOUR_TABLE_STORAGE_ACCOUNT_NAME',
'YOUR_TABLE_STORAGE_ACCOUNT_KEY'
);
session_set_save_handler($session_handler, TRUE);
@ericsk
ericsk / windowsazuresessionhandler.php
Last active January 1, 2016 18:19
WindowsAzureSessionHandler 的 gc 方法
/**
* Callback function for session handler. It's invoked while the session garbage collection starts.
*
* @param $lifeTime Specify the expiry time for cleaning outdated sessions.
*
* @return boolean If the gc operation success.
*/
public function gc($lifeTime) {
// search the entities that need to be deleted.
$filter = 'PartitionKey eq\'' . $this->_sessionContainerPartition . '\' and expires lt ' . (time() - $lifeTime);
@ericsk
ericsk / windowsazuresessionhandler.php
Created December 30, 2013 15:02
WindowsAzureSessionHandler 的 destroy 方法
/**
* Callback function for session handler. It's invoked while the session is being destroyed.
*
* @param $sessionId The session ID.
*
* @return boolean If the destroy process success.
*/
public function destroy($sessionId) {
try {
$this->_tableRestProxy->deleteEntity($this->_sessionContainer, $this->_sessionContainerParition, $sessionId);
@ericsk
ericsk / windowsazuresessionhandler.php
Created December 30, 2013 15:02
WindowsAzureSessionHandler 的 Read 方法
/**
* Callback function for session handler. It's invoked while the session data is being read.
*
* @param $sessionId The session ID.
*
* @return string The session data. It will retrun empty string if the session doesn't exist.
*/
public function read($sessionId) {
try {
// try to retrieve the session content first to see if it exists
@ericsk
ericsk / windowsazuresessionhandler.php
Created December 30, 2013 15:01
WindowsAzureSessionHandler 的 Write 方法
/**
* Callback function for session handler. It's invoked while the session data is being written.
*
* @param $sessionId The session ID.
* @param $sessionData The data to be written in session.
*
* @return boolean If the write operation success.
*/
public function write($sessionId, $sessionData) {
// serialize and encode the session data.
@ericsk
ericsk / windowsazuresessionhandler.php
Created December 30, 2013 15:00
WindowsAzureSessionHandler 的 Open/Close 方法
/**
* Callback function for session handler. It's invoked while the session is being opened.
*
* @param $savePath The path to store the session.
* @param $sessionName The name of the session.
*
* @return boolean If the open operation success.
*/
public function open($savePath, $sessionName) {
try {
@ericsk
ericsk / windowsazuresessionhandler.php
Created December 30, 2013 14:59
WindowsAzureSessionHandler 的建構與解構函式
/**
* Session handler constructor.
*
* @param $storageAccountName The Windows Azure Table Services account name.
* @param $storageAccountKey The Windows Azure Table Service account key.
* @param $sessionContainer The name of the table for storing session data.
* @param $sessionContainerParition The name of the partition for storing session data.
*/
public function __construct($storageAccountName, $storageAccountKey, $sessionContainer = 'phpsessions', $sessionContainerPartition = 'sessions') {
// create the conneciton string for creating the table service rest proxy intance.
@ericsk
ericsk / windowsazuresessionhandler.php
Created December 30, 2013 14:58
用 Windows Azure Table Storgae 實作 PHP Session
class WindowsAzureTableSessionHandler implements SessionHandlerInterface {
...
public function __construct($storageAccountName, $storageAccountKey,
$sessionContainer = 'phpsessions', $sessionContainerPartition = 'sessions') { ... }
public function __destruct() { ... }
public function open($savePath, $sessionName) { ... }