Skip to content

Instantly share code, notes, and snippets.

View ymnk's full-sized avatar

Atsuhiko Yamanaka ymnk

View GitHub Profile
import java.net.{Authenticator, PasswordAuthentication}
import java.net.{URL, HttpURLConnection}
import scala.xml.{XML, Node}
import scala.collection.mutable.Map
class FriendOrFollow (screen_name:String) {
private val friends_url = "http://twitter.com/statuses/friends/%s.xml"
lazy val friends:Map[String, Node] =
getMap(friends_url.replace("%s", screen_name))
import scala.xml.Node
import scala.collection.immutable.Set
import scala.util.Sorting
/**
* This program will demonstrate how to use scala.util.Sorting.
*/
object SortingDemo {
def main(arg:Array[String])={
/*
Copyright (c) 2008 ymnk, JCraft,Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
import scala.tools.nsc.{Interpreter, Settings, Global}
import scala.tools.nsc.util.{Position,NoPosition, ShowPickled}
import scala.reflect.generic.{PickleFormat, PickleBuffer}
import scala.tools.nsc.symtab.classfile.{ClassfileParser}
import scala.tools.nsc.io.AbstractFile
import java.io.{OutputStream, PrintStream, ByteArrayOutputStream}
object DumpGenericsSignature {
class MyParser extends ClassfileParser{
/*
Copyright (c) 2008 ymnk, JCraft,Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
@ymnk
ymnk / pdr.scala
Created November 13, 2008 06:24 — forked from anonymous/pdr.scala
package pdr;
import javax.swing._;
import java.awt._
import java.awt.geom._;
import java.awt.image._
import java.io._
import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.HashMap
import java.math.{BigDecimal => BD, MathContext}
import BD.{ZERO, ONE}
/**
* This program will calculate Pi with John Machin[1]'s formula[2].
* This is just a translation from Mr. Kishida's Java implementation[3] to
* Scala one.
*
* [1] http://en.wikipedia.org/wiki/John_Machin
* [2] http://upload.wikimedia.org/math/f/1/5/f15dc3d39c473c4bd718e3a98145da0d.png
import java.math.{BigDecimal => BD, MathContext}
import BD.{ZERO, ONE}
/**
* This program will calculate Pi with John Machin[1]'s formula[2].
* This is just a translation from Mr. Kishida's Java implementation[3] to
* Scala one.
*
* [1] http://en.wikipedia.org/wiki/John_Machin
* [2] http://upload.wikimedia.org/math/f/1/5/f15dc3d39c473c4bd718e3a98145da0d.png
/*
* ftdop2.scala
* Functional Top Down Operator Precedence
*/
package ftdop2
import scala.util.matching.Regex
import scala.collection.mutable.HashMap
object main {
def main(argv:Array[String]) {
class ARCFour{
private var x:Int = _
private var y:Int = _
private val state = new Array[Int](256)
def decrypt(src:Array[Byte], off:Int, length:Int):Array[Byte]={
encrypt(src, off, length)
}
def decrypt(src:Array[Byte], soff:Int,