Skip to content

Instantly share code, notes, and snippets.

@benmaughan
benmaughan / move-file-here.el
Last active April 22, 2016 08:37
Move a file from somewhere else to here.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; move file here ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'dash)
(require 'swiper)
;; start directory
(defvar bjm/move-file-here-start-dir (expand-file-name "~/downloads"))
(defun bjm/move-file-here ()
@rauchg
rauchg / README.md
Last active January 6, 2024 07:19
require-from-twitter
@cherenkov
cherenkov / get_ameblo_image.rb
Created February 21, 2016 18:30
アメブロの画像URLを取得する #pictruby
def main
url = Popup.input "amebloのURLを入力してください"
url = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D'" + url + "'%20and%20xpath%3D'%2F%2Fimg%5Bcontains(%40src%2C%20%22http%3A%2F%2Fstat.ameba.jp%2Fuser_images%2F%22)%5D%5Bnot(contains(%40src%2C%20%22%3Fcpd%3D%22))%5D'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"
json = Browser.json url
p json
end
@kjunichi
kjunichi / puts_japanese_charactor.rb
Created May 20, 2015 05:48
文字コードを直接指定することで、WebRubyでも日本語をputsで表示出来た
a=0xE3.chr+0x81.chr+0x82.chr
puts a
@sunaot
sunaot / hello_ruby.md
Last active April 4, 2017 11:04
さらっと読んで Ruby がわかった気になれるプログラミング言語 Ruby のかんたんな紹介
@sunaot
sunaot / eigenclass.md
Last active July 4, 2019 02:32
class << self によるクラスメソッドの定義のイディオムの説明とその背景にある特異クラスのかんたんな解説

Ruby のコードを読んでいると

class Hoge
  class << self
    def hello
      puts 'hello'
    end
  end
end
@hoshi-takanori
hoshi-takanori / MyTextView.h
Last active February 11, 2020 23:07
UITextView subclass to replace range with attributed text, with undo/redo support. (iOS 7 only)
#import <UIKit/UIKit.h>
@interface MyTextView : UITextView
- (void)replaceSelectionWithAttributedText:(NSAttributedString *)text;
- (void)replaceRange:(NSRange)range withAttributedText:(NSAttributedString *)text;
@end
# 私が考える安全なプログラムを書くために必要なこと
今も昔も「入力によって挙動が大幅に変わるAPI」が世の中には多数存在していて、プログラマが本来意図した挙動と異なる動作を引き起こしている。
- ファイルを開こうとしたらコマンドを実行できてしまったり
- CSSセレクタを書いてるつもりがHTMLタグを生成してしまったり
- SELECT文を発行するつもりがDELETE文を発行できてしまったり
こういったときに
- 入力値検証をしないと危険になる