Skip to content

Instantly share code, notes, and snippets.

View tarunama's full-sized avatar

tarunama tarunama

  • Free
  • Osaka,JAPAN
View GitHub Profile
@tarunama
tarunama / map_sample.py
Last active August 29, 2015 14:00
[Python] map ってなんだろう ref: http://qiita.com/tarunama/items/4e77339edd0cb10c5e19
items = ["2", "4", "8"]
for r in map(int, items):
print(isinstance(r, int))
"""
output
True
True
True
<?PHP
$content = fopen($argv[1], "r");
while (($line = fgets($content)) !== false) {
$ary = preg_split("/[\s]/", $line);
$str = $ary[1];
$pattern = preg_split("/[\\+\-]/", $ary[1]);
foreach (str_split($pattern[0]) as $val) {
@tarunama
tarunama / first_char.php
Created May 22, 2014 05:51
[PHP] 文字列の1文字目を大文字にする ref: http://qiita.com/tarunama/items/2bb5ff9ff1556d61e526
foreach ($ary as $val) {
$val[0] = strtoupper($val[0]);
....
}
<?php
$data = array();
$data[] = 'hoge';
$data[] = 'foo';
// この間50行くらい
// あ、$dataは配列なのか、と想定してコード読める
function typeHinting(array $data)
<?php
trait Access
{
public function destination($to_where)
{
echo $to_where;
}
}
<?php
abstract class Working
{
abstract protected function where();
abstract protected function why();
abstract protected function how();
public function work()
{
@tarunama
tarunama / abstract.php
Last active August 29, 2015 14:07
[PHP]抽象クラスとTraitのコードを見比べる。 ref: http://qiita.com/tarunama/items/694c790101eacf759500
<?php
abstract class Working
{
abstract protected function where();
abstract protected function why();
abstract protected function how();
public function work()
{
@tarunama
tarunama / PHPの場合
Last active August 29, 2015 14:09
[Scala]PHPerのScala入門メモ(途中) ref: http://qiita.com/tarunama/items/f30420fa117c84274e1b
trait Access {
function howTo() {
echo "HowTo";
}
}
class Company {
use Access;
}
$access = new Company();
$access->howTo(); // HowTo
@tarunama
tarunama / file0.js
Last active August 29, 2015 14:13
[JavaScript] jQueryのメソッドにCallback関数を適応させる時のメモ ref: http://qiita.com/tarunama/items/7e5d1a6c5794c478a950
// main
$("#hoge").click(function () {
console.log("function main start");
// 適当なメソッド
console.log("method animate start");
var value;
$("#foo").animate({
right: 100
@tarunama
tarunama / file0.js
Created January 11, 2015 05:51
[JavaScript] exit()的なことがしたい時 ref: http://qiita.com/tarunama/items/0b2eb347f3f92f4c5e3a
for (var i=0; i < 10; i++)
{
console.log(hoge);
// returnで無理矢理処理を終わらせる
return;
// ここら辺でエラーでる
if (hoge < 10) return true;
}