This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
if __name__ == '__main__': | |
num = raw_input() | |
num = int(num) if num else 10 | |
l = [1] | |
print l | |
for i in range(num): | |
l = map(lambda x,y:x+y,[0]+l,l+[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
#--*-- coding: utf-8 --*-- | |
num = gets.chomp.to_i | |
num ||= 10 | |
a=[1] | |
num.times{ | |
a=[1]+a.zip(a.slice(1..(a.size))).map{|a,b| a.to_i+b.to_i} | |
p a.join(' ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//文字列を配列に変換し、1文字ずつスライスしながら重複チェックする | |
function check_unique($str){ | |
//get length | |
$len = strlen($str); | |
//change array | |
$arr = str_split($str); | |
for($i=0;$i<$len;$i++){ | |
$char = array_shift($arr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//文字列のまま重複チェック | |
function check_unique($str){ | |
$len = strlen($str); | |
for($i=0;$i<$len;$i++){ | |
$char = substr($str,$i,1); | |
//検査対象の文字が文字列のどの位置にあるかを前からと後ろから走査して文字位置が違うとFalse(uniqueではない) | |
if(strpos($str,$char) != strrpos($str,$char)){ | |
return "False"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function check_unique($str){ | |
//引数から配列を生成 | |
$arr = str_split($str); | |
$length = count($arr); | |
//1文字づつ比較 | |
for($i=0;$i<$length;$i++){ | |
$tmp = $arr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function check_unique($str){ | |
//引数から1文字1要素の配列を生成 | |
$arr = str_split($str); | |
//配列の値をキーにする配列を生成 | |
$tmp = array_combine($arr,$arr); | |
//引数から生成した配列の要素数とその配列から生成した配列の要素数を比較(キーは重複できないので) | |
return count($arr) == count($tmp)?"True":"False"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function sendmail($mail_info){ | |
$email = \Email::forge(); | |
$mail->from($mail_info['from']); | |
$mail->to($mail_info['to']); | |
$mail->cc($mail_info['cc']); | |
$mail->subject(mb_convert_kana($mail_info['subject'],"KV"));//件名に半角カナが含まれた場合を考慮して全角カナに変換 | |
//最初の引数はファイルを見つけるためにも使うのでそのまま、通常は第1引数のみ。文字化け対策に別名用引数の第5引数にエンコードした添付ファイル名を渡す | |
if(array_key_exists("attach",$mail_info)) $mail->attach($file_info['attach'],false,null,null,mb_convert_encoding($file_info['attach'],"ISO-2022-JP","CP932")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
Upload::save()を行う前にアップロードするファイル名をエンコードするイケナイ方法 | |
ファイル名に含まれている半角カナを全角に変換し、さらに内部エンコードからCP932にエンコード | |
**/ | |
Upload::register('before',function($file){ | |
$file['filename'] = mb_convert_encoding(mb_convert_kana($file['filename'],"KV"),"CP932"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media print { | |
/* 印刷時に非表示にする要素の指定をする */ | |
body.print div.print-none , | |
body.print div.navbar, | |
body.print hr, | |
body.print div.footer, | |
body.print span#anken-toggle-mark { | |
display: none; | |
} |
NewerOlder