Skip to content

Instantly share code, notes, and snippets.

@Swind
Swind / Example2.scala
Created April 26, 2011 08:12
用Java取得Google Tasks資訊(1) - Example 1
val TAKSKS_URL = "https://mail.google.com/tasks/r/d"
def getTasksQuery(authToken:String)={
//好用又邪惡的隱式轉換
implicit def tuplesToNameValuePair(s:Tuple2[String,String]) = new BasicNameValuePair(s._1,s._2)
val actionID = 1
val post = new HttpPost(TAKSKS_URL)
post.addHeader("AT","1")
post.addHeader("Cookie","GTL="+authToken)
@Swind
Swind / gist:946259
Created April 28, 2011 12:33
[Google][Task][JSon] Google Tasks - Get All List&Task - Post
{
"action_list" :
[
{
"action_id" : "1",
"action_type" : "get_all",
"get_deleted" : false,
"list_id" : "可以針對List ID取得資料,若不指定會取全部"
}
],
@Swind
Swind / test.scala
Created May 26, 2011 06:37
[Scala][Web] 伊莉文章的Parser
package rainy.maid.server.seeker
import java.util.ArrayList
import rainy.maid.server.domain.EneyPost
import scala.xml.NodeSeq
import scala.xml.{ XML, Node }
import de.hars.scalaxml._
import java.text.SimpleDateFormat
class eneySeeker(root: String, url: String) {
var nextPage = url
@Swind
Swind / gist:1035014
Created June 20, 2011 01:59
Android主專案的Ant build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="OpenSudoku" default="help">
<property file="local.properties" />
<property file="build.properties" />
<property file="default.properties" />
@Swind
Swind / build.sbt
Created July 23, 2011 00:59
sbt 0.11.0 build.sbt example
// Set the project name to the string 'My Project'
name := "SBTProject"
// The := method used in Name and Version is one of two fundamental methods.
// The other method is <<=
// All other initialization methods are implemented in terms of these.
version := "1.0"
//Add Repository Path
resolvers += "db4o-repo" at "http://source.db4o.com/maven"
@Swind
Swind / WebKitInABrowser.scala
Created September 13, 2011 00:11
[Scala][SWT][GUI] SWT使用WebKit核心的範例
package example.swt
import org.eclipse.swt.widgets.{Shell, Display}
import org.eclipse.swt.layout.FillLayout
import org.eclipse.swt.browser.Browser
import org.eclipse.swt.SWT
/**
* Date: 2011/9/2
* Time: 上午 8:20
@Swind
Swind / HttpDownloader.scala
Created September 16, 2011 01:10
[Scala][IO] 下載檔案
package example.http
import java.io._
import java.net.{HttpURLConnection, URL}
/**
* Date: 2011/9/16
* Time: 上午 8:37
*/
@Swind
Swind / gist:1266995
Created October 6, 2011 09:49
[Scala][DB] Db4o Example
package tw.teremolo.example
import com.db4o.Db4oEmbedded
import scala.collection.JavaConverters._
/**
* Date: 2011/10/6
* Time: 下午 5:21
*/
object Hello_db4o {
@Swind
Swind / FindPrimse.scala
Created February 14, 2012 08:30
[Scala][Algorithm] 用Scala找質數的範例
object FindPrimse {
def main(args: Array[String]) {
val result = fillPrimeList(10000)
result foreach println
}
def fillPrimeList(max: Int, list: List[Int] = List(3, 2)): List[Int] = {
if (list.head < max)
fillPrimeList(max, findNextPrime(list, list.head + 2) :: list)
@Swind
Swind / unzip.scala
Last active April 22, 2018 08:09
[Unzip in Scala] #Scala #zip
import java.util.zip.ZipFile
import java.io.FileInputStream
import java.io.FileOutputStream
import scala.collection.JavaConversions._
import java.util.zip.ZipEntry
import java.io.InputStream
import java.io.OutputStream
import java.io.File
class ZipArchive {