Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* 複数の配列から一つずつ要素を取得して、指定した個数分要素を取得したら終了
*/
$ary = [
'a' => ['a1', 'a2', 'a3', 'a4'],
'b' => ['b1', 'b2', 'b3'],
'c' => ['c1', 'c2'],
'd' => ['d1', 'd2', 'd3', 'd4'],
];
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
strict="true"
colors="true"
verbose="true">
<testsuites>
<testsuite name="Version">
<script src="http://gist-it.appspot.com/github/tadasy/sample_travis_memcached/blob/master/.travis.yml"></script>
@tadasy
tadasy / setiptables.sh
Last active December 14, 2015 14:19
iptablesの設定shell
#!/bin/bash
# フィルタリングルールを消去する
/sbin/iptables -F
# デフォルトポリシーを設定
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P OUTPUT DROP
# Repeated applications of the hash make brute force (even with a compromised
# database and site key) harder, and scale with Moore's law.
#
# bq. "To squeeze the most security out of a limited-entropy password or
# passphrase, we can use two techniques [salting and stretching]... that are
# so simple and obvious that they should be used in every password system.
# There is really no excuse not to use them." http://tinyurl.com/37lb73
# Practical Security (Ferguson & Scheier) p350
#
# A modest 10 foldings (the default here) adds 3ms. This makes brute forcing 10
@tadasy
tadasy / by_password.rb
Created April 19, 2011 12:43
restful-authentication/lib/authentication/by_password.rb
module ModelClassMethods
# This provides a modest increased defense against a dictionary attack if
# your db were ever compromised, but will invalidate existing passwords.
# See the README and the file config/initializers/site_keys.rb
#
# It may not be obvious, but if you set REST_AUTH_SITE_KEY to nil and
# REST_AUTH_DIGEST_STRETCHES to 1 you'll have backwards compatibility with
# older versions of restful-authentication.
def password_digest(password, salt)
digest = REST_AUTH_SITE_KEY
@tadasy
tadasy / gist:743083
Created December 16, 2010 05:46
filter_parameter_logging sample
class LoginController < ApplicationController
filter_parameter_logging :password
end