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
class UserController extends Controller | |
{ | |
private const USER_PATH = "/tmp/users.csv"; | |
/* | |
* $user_idに対応するユーザデータをjsonで返す | |
*/ | |
public function show(int $user_id) | |
{ | |
$user = null; // ここで作成したクラスのメソッドを呼ぶ |
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
public class HogeListView extends ListView { | |
public HogeListView(Context context) { | |
super(context); | |
} | |
public HogeListView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} |
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
String json = "{id:3, age:30, first_name: 'hoge', last_name: 'fuga'}"; | |
Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); | |
User user = gson.fromJson(json, User.class); |
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
package com.example.android; | |
import com.example.android.R; | |
import android.content.Context; | |
import android.support.v4.view.ActionProvider; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.TextView; |
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
>>> def func_dict(**argv): | |
... print 'dict ----' | |
... print argv | |
... | |
>>> | |
>>> d = {'a': 1, 'b': True, 'c': u'ほげ'} | |
>>> | |
>>> func_dict(d) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> |
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
>>> def func_tuple(*argv): | |
... print 'tuple ----' | |
... print argv | |
... | |
>>> | |
>>> t = (1, True, 'A') | |
>>> | |
>>> func_tuple(t) | |
tuple ---- | |
((1, True, 'A'),) |
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
>>> def test(*argv): | |
... hoge(argv) | |
... fuga(*argv) | |
... | |
>>> def hoge(*argv): | |
... print argv | |
... | |
>>> def fuga(*argv): | |
... print argv | |
... |
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
# 可変長引数(tuple) | |
>>> def func(*v): | |
... print v | |
... | |
>>> func(1) | |
(1,) | |
>>> func(1, "ABC", True) | |
(1, 'ABC', True) | |
# 可変長引数(dict) |
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
# 連結 | |
>>> a = [1, 2, 3] | |
>>> b = [4, 6, 6] | |
>>> a + b | |
[1, 2, 3, 4, 6, 6] | |
# 重複の削除 | |
>>> a = [100, 20, 5, 10, 5, 20, 8] | |
>>> list(set(a)) | |
[8, 20, 10, 100, 5] |
NewerOlder