Skip to content

Instantly share code, notes, and snippets.

@allen501pc
allen501pc / POP3NCHU.php
Created June 18, 2012 04:11
POP3 Authentication for NCHU.
<?php
/* Program: Authenticate E-Mail for NCHU by POP3
* Author: Jyun-Yao Huang (Allen, allen501pc@gmail.com)
* Date: 18th June, 2012
*/
list($user,$domain) = @explode("@",$_POST['email']);
//list($user,$domain) = @explode("@","your @mail.nchu.edu.tw here");
$answer="";
@allen501pc
allen501pc / URLEncryptor.php
Created May 5, 2012 07:27
[PHP] Url encryptor
<?php
/* Function: ImageURLEncryption
* Parameters:
* $Url : the url or text that you want to encrypt.
* $Code: the magic code which masks the url.
*/
function ImageURLEncryption($Url,$Code)
{
$SecretCode = md5($Code);
@allen501pc
allen501pc / demo_picture.php
Created May 5, 2012 07:52
Show the encrypted url picture.
<?php
$EncUrl = ImageURLEncryption("http://l.yimg.com/f/i/tw/hp/mh/09purple.gif","picture");
/* 例如我要隱藏上面的圖片URL,透過Mask = "picture",來加密,因此$EncUrl輸出結果為
aEB0RjpML1guTmkMZxdjDG0WZhtpFnQUL1BwHG1bLwA5RHVEcA9lGmdeZg==
*/
/* 以下藉由demo_picture.php 來展示圖檔 */
$Type = @$_GET['type'];
$ResourceID = @$_GET['resource_id'];
@allen501pc
allen501pc / Invert List.cpp
Created April 18, 2012 11:24
反轉議程委員表,把它轉換為 Name, Review No 1~Review No. n.
/* Author: Allen (allen501pc@gamil.com)
* Date: 2012/04/18 18:30
* Goal: 反轉委員表,把它轉換為 Name, Review No 1~Review No. n.
*/
#include <iostream>
#include <fstream>
#include <string>
#include <iterator>
#include <map>
@allen501pc
allen501pc / 用template傳遞不固定Size之陣列給Function.cpp
Created December 31, 2011 08:31
用template傳遞不固定Size之陣列給Function
#include <iostream>
using namespace std;
/*
* @Function:
template<typename T,size_t N>
void fnChange(T (&arr)[N])
* @Brief: Let each element of array increase by one.
* @Input: 1D array
* @Output: The array whose elements all increase by 1
@allen501pc
allen501pc / 函數傳遞固定大小的陣列.cpp
Created December 31, 2011 08:27
函數傳遞固定大小的陣列
/*
* @Function: void fnPrintArray(int arr[10])
* @Brief: Print the array content.
* @Input: int arr[10]
* @Output: array content.
*/
void fnPrintArray(int arr[10])
{
for(size_t i=0;i<10;++i)
{
@allen501pc
allen501pc / C++ Read Configuration.cpp
Created December 31, 2011 08:42
C++ Read Configuration
ConfigFile cf("config.txt");
std::string foo;
std::string water;
double four;
foo = cf.Value("section_1","foo" );
water = cf.Value("section_2","water");
four = cf.Value("section_2","four" );
@allen501pc
allen501pc / 在template中使用typename.cpp
Created December 31, 2011 08:38
在template中使用typename
template<typename T>
class A{
public:
T m_A;
void funcTest()
{
map<T , int> mapTempTable; /* 這部分沒問題, OK! */
/* 編譯器會出錯!
要改成 typename map<T, int>::iterator it; */
map<T, int>::iterator it;
@allen501pc
allen501pc / 用2維陣列template傳遞不定大小陣列Array.cpp
Created December 31, 2011 08:34
用2維陣列template傳遞不定大小陣列Array
#include <iostream>
using namespace std;
/*
* @Function:
template<typename T,size_t M,size_t N>
void fnPrint2DArray(T (&arr)[M][N])
* @Brief: Print the content of 2D Array.
* @Input: 2D array.
* @Output: None.
*/
@allen501pc
allen501pc / 函數傳遞Array Reference.cpp
Created December 31, 2011 08:29
函數傳遞Array Reference
/*
* @Function: void fnPrintArray(int arr[10])
* @Brief: Print the array content , and the input is by reference.
* @Input: int arr[10]
* @Output: array content.
*/
void fnPrintArray(int (&arr)[10])
{
for(size_t i=0;i<10;++i)
{