Skip to content

Instantly share code, notes, and snippets.

kiyoto kiyoto

Block or report user

Report or block kiyoto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kiyoto
kiyoto / book_crossing_action_query.sql
Created Jul 23, 2012
Book Crossing Dataset Action Queries
View book_crossing_action_query.sql
-- Query 1: Counting Harsh, Generous and Lazy
td query -w -d book_crossing_dataset "
SELECT rating_type, COUNT(*) As cnt
FROM
(
SELECT user_id, MIN(book_rating) AS stat, COUNT(book_rating) AS cnt, 'Generous' AS rating_type
FROM ratings
WHERE 0 < book_rating
GROUP BY user_id
HAVING 5 < COUNT(book_rating)
@kiyoto
kiyoto / google_analytics_to_td.js
Last active Sep 9, 2019
Google Analytics Report into Treasure Data (for the previous day)
View google_analytics_to_td.js
// See https://developers.google.com/analytics/devguides/reporting/core/v3/reference for how Core Reporting API works
// TODO: Filter by user segment, etc.
INPUTS = {
groupBy: ['country'],
metrics:['visits'],
sortBy:['visits'],
profileId: 'YOUR_GA_PROFILE_ID',
databaseName: 'google_analytics',
tableName: 'sample_report',
tdAPIKey: 'YOUR_TD_API_KEY'
@kiyoto
kiyoto / repo_names.txt
Created Jun 8, 2014
docker repo names
View repo_names.txt
0718c7bf/fbtrack
0718c7bf/tomcat6java8
0x42/base
0xahmed/netcat
0xfa1a/centos-ssh
0xfa1a/dockerfiles
0xffea/raring-server-cloudimg-amd64
0xffea/saucy-server-cloudimg-amd64
0xffea/saucy-server-existdb-amd64
1uptalent/docker-registry
@kiyoto
kiyoto / lato.less
Created Aug 19, 2017 — forked from Drunkar/lato.less
slack for windowsで日本語フォントをnoto sans cjk jpに変更する。path: C:\Users\<ユーザ名>\AppData\Local\slack\app-<バージョン>\resources\app.asar.unpacked\src\static\lato.less
View lato.less
/*
This is a smaller variant of the new Lato2, serving compressed woff2 files.
Currently: TS-Only
Clients needs to have Lato2 pref turned ON.
The payload is 50% smaller. However, woff2 is not yet well supported,
so we're still providing the woff as fallback.
@kiyoto
kiyoto / tidy.ps1
Last active Jul 22, 2017
tidy download directory on windows
View tidy.ps1
# tidy up the ~/Downloads directory
cd C:\Users\me\Downloads
$week_ago = (Get-Date).AddDays(-7)
dir | Select-Object {
$last_access = $_.lastAccessTime
if ($last_access -lt $week_ago) {
$path = "{0:yyyyMM}" -f $last_access
if (! (Test-Path $path)) { mkdir $path }
if ($_.FullName -notmatch "^20\d\d\d\d") { mv $_.FullName $path }
@kiyoto
kiyoto / error.log
Created Aug 11, 2016
Tried Fluentd on Bash on Windows.
View error.log
2016-08-11 00:07:24 -0700 [error]: unexpected error error_class=Errno::EINVAL error="Invalid argument - recvmsg(2)"
2016-08-11 00:07:24 -0700 [error]: /home/kiyoto/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/serverengine-1.6.4/lib/serverengine/socket_manager_unix.rb:30:in `recv_io'
2016-08-11 00:07:24 -0700 [error]: /home/kiyoto/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/serverengine-1.6.4/lib/serverengine/socket_manager_unix.rb:30:in `recv_tcp'
2016-08-11 00:07:24 -0700 [error]: /home/kiyoto/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/serverengine-1.6.4/lib/serverengine/socket_manager.rb:37:in `listen_tcp'
2016-08-11 00:07:24 -0700 [error]: /home/kiyoto/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/fluentd-0.14.2/lib/fluent/plugin/in_forward.rb:100:in `listen'
2016-08-11 00:07:24 -0700 [error]: /home/kiyoto/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/fluentd-0.14.2/lib/fluent/plugin/in_forward.rb:68:in `start'
2016-08-11 00:07:24 -0700 [error]: /home/kiyoto/.rbenv/versions/2.3.1/lib
@kiyoto
kiyoto / collatz.markdown
Created May 1, 2016
The Collatz Conjecture in PostgreSQL
View collatz.markdown

##QUERY (PostgreSQL 9.4)

WITH RECURSIVE t(n) AS (
  VALUES(1337)
  UNION ALL
  SELECT CASE WHEN n%2=0 THEN n/2 ELSE 3*n+1 END FROM t WHERE n > 1)
SELECT * FROM t
View sc_im_td_tag.js
// Intimate Merger
!function(a,b,c,d){if(!b[a]){b[a]=function(){b[a].instances.push(this),this.init&&this.init()},b[a].instances=[];for(var e=0,f=["td_send","td_send_imid"];e<f.length;e++)b[a].prototype[f[e]]=function(a){return function(){this["tmp_"+a]=this["tmp_"+a]||[],this["tmp_"+a].push(Array.prototype.slice.call(arguments))}}(f[e]);var g=c.getElementsByTagName(d)[0],h=c.createElement(d);h.async=!0,h.src="//cf.im-apps.net/sdk/tdim-1.1.0.min.js",g.parentNode.insertBefore(h,g)}}("TDIM",window,document,"script");
!function(t,e){if(void 0===e[t]){e[t]=function(){e[t].clients.push(this),this._init=[Array.prototype.slice.call(arguments)]},e[t].clients=[];for(var r=function(t){return function(){return this["_"+t]=this["_"+t]||[],this["_"+t].push(Array.prototype.slice.call(arguments)),this}},n=["addRecord","set","trackEvent","trackPageview","ready"],s=0;s<n.length;s++){var i=n[s];e[t].prototype[i]=r(i)}var a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=("https:"===document.locatio
@kiyoto
kiyoto / google_adwords_to_td.js
Created Apr 1, 2016
Google Adwords Account Performance Daily Dump
View google_adwords_to_td.js
CONSTANTS = {
tdAPIKey: 'YOUR_TD_API_KEY_HERE',
databaseName: 'adwords_reports',
tableName: 'sample_report',
timeColName: "Date",
timeLowerBound: Date.parse(new Date())/1000 - 7*86400,
timeUpperBound: Date.parse(new Date())/1000 + 3*86400
}
function validateDateColumn(o) {
@kiyoto
kiyoto / google_spreadsheet_to_td.js
Last active Apr 1, 2016
AppScript to copy Google Spreadsheet into Treasure Data
View google_spreadsheet_to_td.js
CONSTANTS = {
maxColumns: 1000,
rowsPerRead: 200,
maxRows: 100000,
tdAPIKey: 'YOUR_API_KEY',
databaseName: undefined,
tableName: undefined,
timeColName: "time",
timeLowerBound: Date.parse(new Date())/1000 - 7*86400,
timeUpperBound: Date.parse(new Date())/1000 + 3*86400
You can’t perform that action at this time.