Skip to content

Instantly share code, notes, and snippets.

View kyanny's full-sized avatar

Kensuke Nagae kyanny

View GitHub Profile
# 私が考える安全なプログラムを書くために必要なこと
今も昔も「入力によって挙動が大幅に変わるAPI」が世の中には多数存在していて、プログラマが本来意図した挙動と異なる動作を引き起こしている。
- ファイルを開こうとしたらコマンドを実行できてしまったり
- CSSセレクタを書いてるつもりがHTMLタグを生成してしまったり
- SELECT文を発行するつもりがDELETE文を発行できてしまったり
こういったときに
- 入力値検証をしないと危険になる
@imaya
imaya / gist:7938720
Created December 13, 2013 01:49
退職エントリ

入社から退職に至るまでの経緯

この記事は退職 Advent Calendar 13 日目の記事です。 本日が最終出社となりましたので、入社から退社までを振り返り整理しようと思い、この文章を書いています。

はじめに

自分語りなので興味ない人はさっさと戻ったほうが良いです。 簡単にまとめると、元々あまり執着ないしやることない、なんか最近クソみたいな社内ポリシーがいっぱい出来て萎える、話の合う人がやめることにしたから会社にいる意味を感じないため辞めるということです。

@dagezi
dagezi / github-url.el
Last active December 30, 2015 21:09
Create URL from current buffer and insert to kill-ring.
(defun github-url-decompose (file &optional partial)
(cond
((file-directory-p (expand-file-name ".git" file)) (cons file partial))
((equal "/" file) nil)
(t (github-url-decompose (directory-file-name (file-name-directory file))
(if partial
(concat (file-name-nondirectory file) "/" partial)
(file-name-nondirectory file))))))
(defun github-url-get-origin (dir)
@doi-t
doi-t / setting_default_value.bash
Last active April 2, 2023 11:35
シェル変数のデフォルト値を設定する
#!/bin/bash
foo=${1:-hoge}
echo $foo #$1がなかったらhogeをデフォルト値としてfooに代入する
#var自身にデフォルト値としてhogeを代入としたいので以下のように書きたい
${var:=hoge} #このままでは、hogeが展開されてしまって、hogeなんてコマンドはないとシェル怒られる
echo "1:$var"
var=
@nikushi
nikushi / chunk-test.md
Last active December 30, 2015 02:39
Transfer-Encoding: chunkedを返答するときでもWebRickだとContent-Lengthが付いてしまう

WebRick

$ telnet localhost 9292
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.1
Host: localhost:9292
@mars
mars / register_chrome_with_window_size.rb
Created October 13, 2013 01:58
Set window size for Capybara/Selenium/chromedriver
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app,
browser: :chrome,
desired_capabilities: {
"chromeOptions" => {
"args" => %w{ window-size=1024,768 }
}
}
)
end
#!/usr/bin/env ruby
require 'pit'
require 'octokit'
org_name = ARGV[0]
unless org_name
abort "Usage #{$0} org_name"
end
@kyanny
kyanny / gist:6396592
Last active December 22, 2015 01:29
RubyConf 2013 CFP
Title
Tachikoma - Continuous gem dependency updating with pull request
Abstract
Today you manage gems of Ruby application with Bundler, but you often neglect to update.
Whatever gems your application depends on, you can get the most benefit by following cutting-edge. Eventually you have to update them, so if you do it more frequently you'll have less pain.
@fujimura
fujimura / spaghetti_and_neapolitan.hs
Last active December 20, 2015 17:08
spaghetti_and_neapolitan.hs
spaghetti :: String
spaghetti = "gtgtsgipgttptinggipsppaigsesgpetgstpatetisiesagaeaigttetepitiatsegssieeeeatepaaiagtpieataatppiitgiapsteitatiiatpetetetttgpetpaasipttssstpeeeggtiagtttegtiipestsasgpsepaasapttgattgiatppegitiatpasgatgepttggapesaeetaeissttggieietgspagesiipestipggstttpateptitiaetottissgggtttaipappgstsptttgtpispattgegstltiappseisapgistaiagteeiptptpisaieisagstapeteietgteiisgtiptstgtstasspeatspptitttatteastsgtptgtasggpniaaeteaisett"
neapolitan :: String
neapolitan = "neapolitan"
solve :: String -> String -> String
solve [] _ = ""
solve xs [] = xs
solve (x:xs) (y:ys)
#! /usr/bin/env ruby
# Pull all directory under current directory, if it's on master, has no local changes, can be pulled fast-forward.
def git_repo?
`git status`.chomp !~ /Not a git repository/
end
def not_changed?
`git status -s`.chomp.empty?