Skip to content

Instantly share code, notes, and snippets.

View k4zy's full-sized avatar

Kazuki Yoshida k4zy

  • Cookpad.Inc
  • Yebisu/Tokyo
View GitHub Profile

スコープ関数とデリゲーションについて

拡張関数について

kotlinは任意のクラスに後からメソッドを追加できます。これを拡張関数と呼びます。

fun String.print() {
  System.out.println(this)
}
Error detected while processing function <SNR>59_ShowMarks:
line 39:
E885: Not possible to change sign ShowMark76
Press ENTER or type command to continue
def quicksort(list):
if len(list) <= 1:
return list
pivot = list[0]
left = []
right = []
for val in list[1:len(list)]:
if val < pivot:
left.append(val)
else:
import math
import string
class RectangularGrid:
def countRectangles(self, width, height):
counter = 0
for i in range(1,width+1):
for j in range(1,height+1):
if i != j:
counter += ( (1+ (width-i)) * (( 1 + (height- j))) )
import math
import string
class BinPacking:
def minBins(self, tuple_items):
items = list(tuple_items)
bin_count = 0
while 100 in items and 200 in items:
items.remove(100)
#include <stdio.h>
// 1.一番ベーシックな構造体の定義の文法
struct sample1{
float f;
};
int main()
{
struct sample1 a;
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"font_face": "Migu 1M",
"font_size": 13,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Emmet",
"CoffeeCompile"
],
@k4zy
k4zy / gist:5270944
Last active December 15, 2015 13:59
android base adapter templete
import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
public class MainViewListAdapter extends BaseAdapter{
List<MainViewListEntry> entries;
@k4zy
k4zy / gist:5127651
Created March 10, 2013 08:33
近江鉄道のスクレイピング スクリプトでけた~ サンプルurl: http://kazy.oops.jp/debug/oumi.php?id=167_7_1 http://www.busqr.com/jikoku/01/stop/iku/xxx.html <= xxxの所をidで渡す感じです
<?php
$id = $_GET['id']; //GETパラメーターを取得
function is_on_service_time($line){
return preg_match("/<FONT\scolor=\"\#0000cc\">\d{2}:<\/FONT>\s<A\shref=\"bin\/\d{5}\.html\">\d{2}<\/A>/xsiu",$line,$item);
}
$result_array = array();
$url = "http://www.busqr.com/jikoku/01/stop/iku/".$id.".html";
@k4zy
k4zy / gist:5124237
Created March 9, 2013 13:56
navitimeから時刻表を抽出するスクレイピング スクリプトです. サンプルurl : http://kazy.oops.jp/doshisha/navitime.php?direction=up&station=doshishamae (jsonを返します) 今は同志社近辺に対応する形になってますが一般化はできます かなり辛い感じなコードがたっぷりなので書き直します すいません
<?php
$direction = $_GET['direction'];
$station = $_GET['station'];
$direction_num = $direction == 'up' ? 0 : 1;
$station_id = array('shintanabe'=>'00004328','kyotanabe'=>'00001755','imadegawa'=>'00002735','demachiyanagi'=>'00003573','doshishamae'=>'00006957','kodo'=>'00001781');
$station_code = array('shintanabe'=>'近鉄京都線','kyotanabe'=>'片町線','imadegawa'=>'京都市営烏丸線','demachiyanagi'=>'京阪本線',);
$url = "http://www.navitime.co.jp/diagram/".$station_id[$station];
header('Content-Type:text/html; charset=UTF-8');
$context = stream_context_create(array(
'http' => array(