Skip to content

Instantly share code, notes, and snippets.

@allen501pc
allen501pc / DBCount.java
Created June 9, 2011 10:14
Question of MySQL connection for Hadoop
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;
import java.io.DataInput;
@allen501pc
allen501pc / Multi-Threads_Jobs_in_Hadoop.java
Created July 2, 2011 09:14
Multi-Threads Jobs in Hadoop
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;
import java.io.DataInput;
@allen501pc
allen501pc / Cal.cpp
Created September 5, 2011 08:22
教育部專用計算程式
#include <iostream>
using namespace std;
/* 總金額 */
#define _SUM_OF_DOLLARS 20800
/* Dollars of Item 1. */
#define _ITEM_1 170
/* Dollars of Item 2. */
#define _ITEM_2 870
int main(int argc, char * argv[])
@allen501pc
allen501pc / CountWord.cpp
Created September 27, 2011 15:11
Count Words and Sort It!
/*
* Program Description:
* Count the input data character frequence, and store the characters which are composed with 'A-Z' or 'a-z'.
* And output the character and respective frequency. Note that the characters 'A-Z' and 'a-z' are the same.
* For example,
* Input:
* This is a text for Q2.
* My cellphone number is 123-456-789.
* E-mail: [email protected]
Output:
@allen501pc
allen501pc / Q3.cpp
Created September 27, 2011 19:54
找最長的回文子字串,並顯示出其長度
/*
Ex: Given
10
1 2 3 4 5 8 4 3 2 1
Note that the first line is the counts of numbers in the second lines.
Then, we can find that the max_seq = '1 2 3 4 5 4 3 2 1', whose length = 9.
*/
#include <iostream>
@allen501pc
allen501pc / find_substring_from_stream.cpp
Created October 31, 2011 10:20
Find string from stream
/* Program: Find the character substring location of the input character string.
* Author: Jyun-Yao Huang ([email protected])
* License: Free
*/
#include <iostream>
#include <bitset>
#include <string>
#include <set>
#include <vector>
@allen501pc
allen501pc / PHP_Mailer_基本範例.php
Created December 29, 2011 06:41
PHPMailer 基本範例 (含發送附件檔)
<?php
include("class.phpmailer.php"); // 匯入PHPMailer library
$mail= new PHPMailer(); //建立新物件
$mail->IsSMTP(); //設定使用SMTP方式寄信
$mail->SMTPAuth = true; //設定SMTP需要驗證
$mail->SMTPSecure = "ssl"; // Gmail的SMTP主機需要使用SSL連線
$mail->Host = "smtp.gmail.com"; //Gamil的SMTP主機
$mail->Port = 465; //Gamil的SMTP主機的SMTP埠位為465埠。
$mail->CharSet = "utf-8"; //設定郵件編碼,預設UTF-8
@allen501pc
allen501pc / 在MVC3上包JSON物件_送給Controller的方法.js
Created December 29, 2011 06:53
在MVC 3上包JSON物件,送給Controller的方法
$.ajax({
type: "POST", /* 選擇傳輸方式 */
url: "/person/create", /*選擇要處理的controller/action */
dataType: "json", /*選擇資料類型,以本篇文章,資料類型為json */
contentType: "application/json; charset=utf-8", /* 選擇傳輸的encoding以及媒體類型 */
data: jsonData, /* data欄位填入json包好的資料就行了!以這個為例,jsonData是該篇文章的一個物件 */
success: function (result){ /* 成功了要做什麼動作? */
console.log(result); //log to the console to see whether it worked
},
error: function (error){ /* 失敗了要做什麼動作? */
@allen501pc
allen501pc / ASP.NET- 從web.config中取得檔案上傳下載目錄設定.cs
Created December 29, 2011 10:05
ASP.NET- 從web.config中取得檔案上傳下載目錄設定
/* 要使用 ConfigurationManager,需引入System.Configuration 這個namespace */
using System.Configuration;
/* 程式碼區 */
[HttpPost]
public ActionResult Upload(HttpPostedFileBase file)
{
//檢查是否有檔案上傳,有的話存檔
if (file !=null && file.ContentLength > 0)
@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)
{