Skip to content

Instantly share code, notes, and snippets.

View notyy's full-sized avatar

大魔头 notyy

View GitHub Profile
@notyy
notyy / AbstractBase
Created July 27, 2013 13:19
implicit abstract class problem
package base;
import java.util.List;
public abstract class AbstractBase {
abstract protected List getChildren();
}
@notyy
notyy / gist:6093587
Created July 27, 2013 03:29
this implicit works for scala
package com.github.notyy.retroboard.util
import org.scalatest.FunSpec
import org.scalatest.matchers.ShouldMatchers
trait Base {
protected def getChildren: List[String]
}
object Base {
@notyy
notyy / gist:5790999
Created June 16, 2013 06:22
scaladay 2013 slide links
https://speakerdeck.com/ryanlecompte/confessions-of-a-ruby-developer-whose-heart-was-stolen-by-scala
Practical type mining in Scala ( Rose Toomey )
http://www.slideshare.net/prasinous/scaladays-2013-final
Real world akka recepies (Jamie Allen, Björn Antonsson and Patrik Nordwall)
http://www.slideshare.net/shinolajla/real-world-akka-recepies-v3
Scala IDE 3.0 - Present & Future ( Mirco Dotta )
@notyy
notyy / gist:3958354
Created October 26, 2012 11:52
implicit list as functor
trait Functor[A, T[_]] {
def fmap[B](f: A => B): T[B]
}
class ListFunctor[A](val list: List[A]) extends Functor[A, List] {
override def fmap[B](f: A => B): List[B] = list match {
case List() => List()
case (x :: xs) => f(x) :: xs.fmap(f)
}
}
@notyy
notyy / gist:3712639
Created September 13, 2012 07:39
how to remove
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
window.onload = doIt;
function doIt() {
var oDiv = document.getElementById("div1");
alert (oDiv);
//oDiv.removeAttribute("onclick");
}
@notyy
notyy / gist:3422084
Created August 22, 2012 03:33
extract user story
#!/bin/sh
exec scala -nc "$0" "$@"
!#
import scala.io._
val source = if(args.length>0) Source.fromFile(args(0)).getLines else Source.stdin.getLines
val pattern = """([a-zA-Z]+)-(\d+)""".r
source.flatMap(pattern.findFirstIn).toList.distinct.foreach(println)
@notyy
notyy / gist:3123499
Created July 16, 2012 15:59
scala_lecture,ruby comparation6
cond = "false"
if cond then true else false end
=> true
@notyy
notyy / gist:3122675
Created July 16, 2012 13:20
scala_lecture,ruby comparation5
def match_type param
if param.kind_of? Integer
puts "it's a Integer"
end
if param.kind_of? String
puts "its a String"
end
if param.kind_of? Array
puts "its an Array"
end
@notyy
notyy / gist:3119946
Created July 16, 2012 02:13
scala_lecture,ruby comparation3
def postProcess int_list
int_list.map{ |i| i - 2}.each{|l| puts l}
end
list = [1,2,3,4,5]
rs = list.map{ |i| i * 2 }.map{ |i| i + 3 }.reject{|j| j > 10}.map{ |i|i.to_s}
postProcess(rs)
@notyy
notyy / gist:3120022
Created July 16, 2012 02:29
scala_lecture,ruby comparation4
def postProcess int_list
int_list.map{ |i| i * 2}.each{|l| puts l}
end
list = [1,2,3,4,5]
rs = list.map{ |i| i * 2 }.map{ |i| i + 3 }.reject{|j| j > 10}.map{ |i|i.to_s}
postProcess(rs)