すごいHaskellたのしく学ぼう!をScalaでやってみたメモ
目次
| (function($) { | |
| $.fn.selectErea = function(config){ | |
| config = $.extend({ | |
| selectEreaId: 'selectErea', | |
| baseLayerId: 'baseLayer', | |
| prefix: '__op_', | |
| brClass: 'br', | |
| groupClass: 'group', | |
| headClass: 'head', | |
| height: 'auto', |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
| </head> | |
| <body> | |
| <script> | |
| var radarChart = function(){ | |
| var w = 200, |
| /* | |
| * IntStreamのrangeメソッド | |
| */ | |
| IntStream.range(1, 20); | |
| // [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19] | |
| /* | |
| * rangeClosedメソッド。最後が含まれる | |
| */ | |
| IntStream.rangeClosed(1, 20); |
| /** | |
| * InstantとDuration | |
| */ | |
| // java.time.Instant はエポックを起点とし、1日を86400秒として計測されたある時点を表す | |
| Instant base = Instant.now(); // 2015-03-03T08:05:41.758Z | |
| Instant after = base.plusSeconds(10).plusMillis(100).minusMillis(10); // 2015-03-03T08:05:51.848Z | |
| Instant.now().getEpochSecond(); // 1451088582L | |
| // java.time.Duration は2つのInstantの間隔 | |
| Duration duration = Duration.between(base, after); //PT10.09S |
| @Configuration | |
| public class DatabaseConfig { | |
| @Bean | |
| public DataSource ds1() { | |
| org.apache.tomcat.jdbc.pool.DataSource ds = new org.apache.tomcat.jdbc.pool.DataSource(); | |
| ds.setDriverClassName("driverName"); | |
| ds.setUrl("url"); | |
| ds.setUsername("username"); | |
| ds.setPassword("password"); |
| public class Main { | |
| public static void main(String[] args) { | |
| System.out.println(flatMapRoutine()); | |
| System.out.println(nonFlatMapRoutine()); | |
| } | |
| private static Optional<Pole> flatMapRoutine() { | |
| return new Pole(0, 0).landLeft(1) | |
| .flatMap(x -> x.landRight(4)) | |
| .flatMap(x -> x.landLeft(-1)) |
| case class User(id: Int, email: String, name: String, age: Option[Int], address: Option[String]) | |
| def selectUsers: DBIO[Seq[User]] = sql""" | |
| SELECT | |
| id, | |
| email, | |
| name, | |
| age, | |
| address | |
| FROM |
| # coding: utf-8 | |
| import sys | |
| import datetime | |
| import re | |
| import requests | |
| import twitter | |
| from datetime import datetime | |
| GITHUB_USER = "hoge" |
| unmap "t" | |
| map "ctrl+f" scrollPageDown | |
| map "ctrl+b" scrollPageUp | |
| map "[ t" previousTab | |
| map "] t" nextTab | |
| map "[ T" firstTab | |
| map "] T" lastTab |