This file contains hidden or 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 clipping object is a JavaScript object | |
// that contains the following properties. | |
// Properties values may be null. | |
// title (String) | |
// text (String) | |
// url (String) | |
// saveDate (Date) | |
// Return true if the clipping can be reformatted with this script. |
This file contains hidden or 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 |
This file contains hidden or 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
""" | |
1から100までの数をプリントするプログラムを書け。ただし3の倍数のときは数の代わりに「Fizz」と、5の倍数のときは「Buzz」とプリントし、3と5両方の倍数の場合には「FizzBuzz」とプリントすること。 | |
""" |
This file contains hidden or 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
function sleep(waitMsec) { | |
var startMsec = new Date(); | |
// 指定ミリ秒間、空ループ。CPUは常にビジー。 | |
while (new Date() - startMsec < waitMsec); | |
} | |
function asyncLoop(iterations, func, callback) { |
This file contains hidden or 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
#!/bin/bash -x | |
TARGET_DIR=$1 | |
ls -sl ${TARGET_DIR} \ | |
| grep jpg \ | |
|sed -e 's/\.jpg//g' \ | |
| awk '{print $NF}' \ | |
| ruby -e 'aids = {}; while gets; aids[$_.strip.split("_")[1]] = 0; end; File.open("./book_kvs_plus_imageid.tsv").each do |l| a = l.strip.split("\t"); if aids.has_key?(a[2]) then puts "#{a[1]}_#{a[2]}.jpg\t#{a[0]}" end; end'\ | |
> ${TARGET_DIR}/list.txt |
This file contains hidden or 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 Array | |
def odd_values | |
self.values_at(* self.each_index.select {|i| i.odd?}) | |
end | |
def even_values | |
self.values_at(* self.each_index.select {|i| i.even?}) | |
end | |
def sum | |
inject { |sum, x| sum + x } | |
end |
This file contains hidden or 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
# GBDTの特徴量作成 | |
def merge_features(): | |
return pd.concat([ | |
features(), | |
series2df((meta_features()[log_prefix("condition.timestamp")].astype(str) + "_" + meta_features()[log_prefix("condition.bcookie")]), "query"), | |
meta_features()[exhibit_prefix("aid")], | |
correct_label().astype(int)], axis=1).fillna(0).sort_values(['query'], ascending=[True]) | |
df = merge_features() |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
""" | |
概要: セッションデータの欠損している日付を調べる | |
実行コマンド: | |
hadoop fs -ls /projects/auc/var/session_data/app/*/_SUCCESS | rev | cut -c 10-17 | rev | python date_check.py | |
実行結果: 欠損している日付が表示される | |
""" | |
from datetime import datetime, timedelta |
This file contains hidden or 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
require 'pp' | |
require 'nokogiri' | |
require "selenium/webdriver" | |
require 'uri' | |
def translate(texts) | |
# phantomjs --webdriver=8001が必要? | |
driver = ::Selenium::WebDriver.for(:phantomjs) | |
texts.each do |text| |
This file contains hidden or 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
array = [1,1,2,2,3,3,4,5,6,6,6] | |
def detect_diff_iter(array): | |
""" | |
イテレーション時の次の値で、値が変化するならばTrueを返す | |
""" | |
for i, val in enumerate(array): | |
if i+1 < len(array): | |
next_val = array[i+1] | |
else: |
NewerOlder