Skip to content

Instantly share code, notes, and snippets.

@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 / 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 (allen501pc@gmail.com)
* License: Free
*/
#include <iostream>
#include <bitset>
#include <string>
#include <set>
#include <vector>
@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 / 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: allen501pc@gmail.com
Output:
@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 / 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 / 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 / core-site.xml
Created May 10, 2011 09:33
core-site.xml
<?xml version="1.0"?>
<!-- core-site.xml -->
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://namenode/</value>
<final>true</final>
</property>
</configuration>
@allen501pc
allen501pc / SortByTemperatureUsingHashPartitioner.java
Created May 3, 2011 15:00
SortByTemperatureUsingHashPartitioner
package SortData;
import java.io.IOException;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.SequenceFile.CompressionType;
import org.apache.hadoop.io.compress.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;
package SortData;
import java.io.IOException;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.io.*;
import org.apache.hadoop.io.SequenceFile.CompressionType;
import org.apache.hadoop.io.compress.GzipCodec;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;