Skip to content

Instantly share code, notes, and snippets.

@akanehara
akanehara / c0.md
Last active December 14, 2017 17:42
『プログラミングの基礎』社内読書会 #0

#『プログラミングの基礎』社内読書会 #0

処理系のインストール

Mac, Linux

@nvkiet
nvkiet / [Swift] Hide-show keyboard
Created August 20, 2014 14:16
Hide/Show keyboard with Swift language
func handleKeyboardWillShowNotification(notification: NSNotification) {
if self.inputContainerViewBottomLayoutGuideConstraint.constant == 0 {
keyboardWillChangeFrameWithNotification(notification, showKeyboard: true)
scrollBubbleTableViewToBottomAnimated(true)
}
}
func handleKeyboardWillHideNotification(notification: NSNotification) {
if self.inputContainerViewBottomLayoutGuideConstraint.constant > 0 {
keyboardWillChangeFrameWithNotification(notification, showKeyboard: false)
@bitoffdev
bitoffdev / filedownloader.py
Last active March 26, 2025 06:52
filedownloader.py
# Python file downloader for Pythonista by OMZ Software
# By: EJM Software ---- http://ejm.cloudvent.net
# Source: https://gist.github.com/89edf288a15fde45682a
# *****************************************
# This simple script uses the requests module to download files
# and the ui module to show a progress bar
# You can use this bookmarklet to download files from Safari:
# javascript:window.location='pythonista://filedownloader?action=run&argv='+encodeURIComponent(document.location.href);
import ui, console, clipboard, sys, requests, zipfile
@chibicode
chibicode / Sublime Textの検索窓に日本語を入力する方法.md
Created July 26, 2014 03:27
Sublime Textの検索窓に日本語を入力する方法

Sublime Textの検索窓に日本語を入力するとEnterを押すなり文字が消えてしまうのですが、無理やり解決する方法を見つけました。ググってもこちらのバグレポートしか見つからなかったので報告です。

わたしの環境はMac OS XのSublime Text 3 (Build 3059)ですが、この解決方法はSublime Text 2 (Build 2220)にも対応しています。Windowsの場合は不明です。

ステップ1: Sublime Text 3の場合のみ: Default (OSX).sublime-keymapを編集可能にする

このステップはSublime Text 3の場合のみ必要です。Sublime Text 2の場合はステップ2に行って下さい。

protocol ArrayRepresentable {
typealias ArrayType
func toArray() -> ArrayType[]
}
extension Range : ArrayRepresentable {
func toArray() -> T[] {
return T[](self)
}
@echo off
set dt=%date%
set tm=%time: =0%
set d=%dt:~2,2%%dt:~5,2%%dt:~8,2%
set t=%tm:~0,2%%tm:~3,2%%tm:~6,2%
psql -U user -L %d%_%t%.log test
@hiroshiro
hiroshiro / use_return.rb
Created February 28, 2014 19:00
制御構文の条件式ネストを避けるガード節のRubyの構文。良い、悪い例。
# bad
def compute_thing(thing)
if thing[:foo]
update_with_bar(thing)
if thing[:foo][:bar]
partial_compute(thing)
else
re_compute(thing)
end
end
@mala
mala / gist:9086206
Created February 19, 2014 04:49
CSRF対策用トークンの値にセッションIDそのものを使ってもいい時代なんて、そもそも無かった

概要

http://co3k.org/blog/csrf-token-should-not-be-session-id について。

この記事では触れられていませんが、

  • むかし、セッションIDをHTMLソース中に埋め込んでも脅威は変わらないと主張した人がいました
  • 正確には「hiddenの値のみ漏れやすいような特殊な脆弱性が無ければ」という前提であったけれど、実際にそのようなバグはあったし、予見されていた。
  • とても影響のある人だったので、色々なサイトや書籍がその方法を紹介し、安全なウェブサイトの作り方にも載ってしまいました

この際ハッキリ言っておくべきだと思うので書きますが、そもそもセッションIDを(HTMLソース中に埋め込む)CSRF対策トークンとして使うのは間違いでした。最初から間違っていたのです。正確に言うとCSRFの話は関係ないですね。CSRF関係なく、特に「単体で」セッションハイジャックが可能になるような値を、HTMLソース中に埋め込むべきではありません。

@K-atc
K-atc / beta.txt
Last active January 25, 2024 14:14
キチガイ辞書(UTF-8)(Google IMEで使えます。Shift JISにエンコードすればMS IMEでも使えます。)
あげあげ (☝◞‸◟)☝ 顔文字
あげあげ ( ☝՞ਊ ՞)☝ 顔文字
あっあっ (◞‸◟;) 顔文字
あつい (。>﹏<) 顔文字
あわてる ヽ( ̄д ̄;)ノ=3=3=3 顔文字
いう ( ^o^)< 名詞
いしはらよしずみ 三( ◠‿◠ )そんな時にタウンページが便利なんですよ 顔文字
うーにゃー (」・ω・)」うー!(/・ω・)/にゃー 名詞
うーん :;(∩´﹏`∩);: 顔文字
うっとり ・:*:・(*´∀`*)・:*:・ 顔文字
@cuibonobo
cuibonobo / Large-app-how-to.md
Last active March 6, 2024 18:40
How to structure a large application in Flask. Taken from the Flask wiki: https://github.com/mitsuhiko/flask/wiki/Large-app-how-to

Here's an example application that uses the pattern detailed below: https://github.com/tantastik/talent-curator


This document is an attempt to describe the first step of a large project structure with flask and some basic modules:

  • SQLAlchemy
  • WTForms

Please feel free to fix and add your own tips.