- Scott Chacon on the Interwebs(リンク切れ)
- Scott Chacon on the Interwebs
- GitHub Flow - The best way to use Git and GitHub
31 Aug 2011
def screenshot | |
require 'capybara/util/save_and_open_page' | |
now = Time.now | |
p = "/#{now.strftime('%Y-%m-%d-%H-%M-%S')}-#{rand}" | |
Capybara.save_page body, "#{p}.html" | |
path = Rails.root.join("#{Capybara.save_and_open_page_path}" "#{p}.png").to_s | |
page.driver.render path | |
Launchy.open path | |
end |
import sbt._ | |
import Keys._ | |
import Build.data | |
object build extends Build { | |
lazy val runAll = TaskKey[Unit]("run-all") | |
lazy val standardSettings = Seq( | |
runAllIn(Compile) | |
) |
import scala.language.dynamics | |
import scala.util.DynamicVariable | |
sealed trait Node { | |
def toXml: String | |
} | |
case class ElementNode(name: String, attributes: Map[String, String], children: List[Node]) extends Node { | |
def toXml = { |
// This is the official Selenium documention endorsed method of waiting for elements. | |
// This method is ineffective because it still suffers from | |
// the stale element exception. | |
public static void clickByLocator ( final By locator ) { | |
WebElement myDynamicElement = ( new WebDriverWait(driver, 10)) | |
.until( ExpectedConditions.presenceOfElementLocated( locator ) ); | |
myDynamicElement.click(); | |
} |
import sbt._ | |
import Keys._ | |
object build extends Build{ | |
def github(org: String, name: String, hash: String): Project = Project( | |
name, file(name) | |
).settings( | |
baseSettings ++ seq( | |
sourceGenerators in Compile <+= (sourceManaged in Compile){ dir => task{ |
liberator.registerObserver( | |
'enter', | |
function () { | |
commands.get('sbm').options.push([['-t', '-twitter'], liberator.modules.commands.OPTION_NOARG]); | |
libly.$U.around( | |
commands.get('sbm'), | |
'action', | |
function (next, [args]) { | |
if (args['-t']) { |
# 私が考える安全なプログラムを書くために必要なこと | |
今も昔も「入力によって挙動が大幅に変わるAPI」が世の中には多数存在していて、プログラマが本来意図した挙動と異なる動作を引き起こしている。 | |
- ファイルを開こうとしたらコマンドを実行できてしまったり | |
- CSSセレクタを書いてるつもりがHTMLタグを生成してしまったり | |
- SELECT文を発行するつもりがDELETE文を発行できてしまったり | |
こういったときに | |
- 入力値検証をしないと危険になる |
def linkTo(label: String, url: String, options: (Symbol, Any)*) = Html( | |
options.foldLeft(<a href={url}>{label}</a>) { | |
case (elem, (k, v)) => | |
elem % new xml.UnprefixedAttribute(k.name, v.toString, elem.attributes) | |
}.toString | |
) |