Skip to content

Instantly share code, notes, and snippets.

View y-yoshinoya's full-sized avatar

Yuki Yoshinoya y-yoshinoya

View GitHub Profile
@jc00ke
jc00ke / capybara-helpers.rb
Created January 28, 2012 07:47
Capybara helpers
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
@Gab-km
Gab-km / github-flow.ja.md
Last active April 23, 2025 04:19 — forked from juno/github-flow.ja.md
GitHub Flow (Japanese translation)
@gseitz
gseitz / build.scala
Created February 19, 2013 22:52
SBT task for running all main classes
import sbt._
import Keys._
import Build.data
object build extends Build {
lazy val runAll = TaskKey[Unit]("run-all")
lazy val standardSettings = Seq(
runAllIn(Compile)
)
@hexx
hexx / htmldsl.scala
Created March 1, 2013 18:51
HtmlDSL using Dynamic
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 = {
@djangofan
djangofan / endorsedmethod.java
Last active January 6, 2023 22:05
Exercise on safely waiting for unstable web elements with WebDriver.
// 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();
}
@xuwei-k
xuwei-k / build.scala
Created April 10, 2013 03:36
source generators from github
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{
@ebith
ebith / add_twitter_option.js
Created June 17, 2013 23:39
direct_bookmark.jsにツイッター連携付きのはてなブックマークを行うオプションを追加する(要はてブ拡張)
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']) {

redcaretとgithub-markdownの違い

  • 両者のソースは割りと似ている(github-markdownがredcarpetを元にしたのか、あるいは両者のもとになったC実装があるとかかな)

オプションについて

github-markdownは、redcapetの提供するオプションの一部をデフォルトで有効化します。 (ちなみに有効化するオプションを選ぶAPIはない模様。用途を考えるとそれで正しいが)

★がついているのが有効化されるもの。gfmモード(.render_gfmメソッド)の場合のみ、★★も有効化される。

# 私が考える安全なプログラムを書くために必要なこと
今も昔も「入力によって挙動が大幅に変わるAPI」が世の中には多数存在していて、プログラマが本来意図した挙動と異なる動作を引き起こしている。
- ファイルを開こうとしたらコマンドを実行できてしまったり
- CSSセレクタを書いてるつもりがHTMLタグを生成してしまったり
- SELECT文を発行するつもりがDELETE文を発行できてしまったり
こういったときに
- 入力値検証をしないと危険になる
@a-ono
a-ono / gist:8642560
Created January 27, 2014 02:47
play2 linkTo
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
)