Skip to content

Instantly share code, notes, and snippets.

@kiyoto
kiyoto / lato.less
Created August 19, 2017 22:32 — 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
/*
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 July 22, 2017 22:05
tidy download directory on windows
# 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 August 11, 2016 07:08
Tried Fluentd on Bash on Windows.
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 09:10
The Collatz Conjecture in PostgreSQL

##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
// 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_analytics_to_td.js
Last active September 9, 2019 17:39
Google Analytics Report into Treasure Data (for the previous day)
// 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 / google_adwords_to_td.js
Created April 1, 2016 23:29
Google Adwords Account Performance Daily Dump
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 April 1, 2016 23:08
AppScript to copy Google Spreadsheet into Treasure Data
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
@kiyoto
kiyoto / strata_hadoop_2015.csv
Created March 11, 2015 16:56
Strata_hadoop_2015 CSV Data
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 10.
"","avg_points","num_reviews","time","date","title","location","category"
"1",4,1,"10:40a","02/20/2015","The IoT P2P Backbone","LL21 E/F","Machine Data / IoT"
"2",4.4,10,"11:30a","02/19/2015","Unboxing Data Startups","LL20 BC","Business & Industry"
"3",3.57,7,"11:30a","02/20/2015","The Sushi Principle: Raw Data Is Better","LL21 E/F","Machine Data / IoT"
"4",4,1,"2:20p","02/20/2015","Streaming Analytics: It'™s Not The Same Game","LL21 E/F","Machine Data / IoT"
"5",3.25,16,"1:30p","02/18/2015","Building A Data Platform","210 C/G","Hadoop Platform"
"6",NA,0,"11:30a","02/20/2015","Silicon Valley Data Science: Ask Us Anything","211 B","Ask Us Anything"
"7",4,1,"10:40a","02/20/2015","Credit Suisse Puts Vendors in the Hot Seat on Data Quality and Governance","230 B","Sponsored"
"8",4.86,7,"9:00a","02/18/2015","Hardcore Data Science","LL20 BC","Hardcore Data Science"
"9",4,6,"1:30p","02/18/2015","Tensor Methods for Large-scale Unsupervised Learning: Applications to Topic and Community Modeling","LL20 BC.","Hardcore D
@kiyoto
kiyoto / strata_hadoop_2015.R
Created March 10, 2015 05:31
Script for Strata Hadoop 2015 Reviews Data Collection + Analysis
library(ggplot2)
library(dplyr)
library(scrapeR)
strata_speakers <- "http://strataconf.com/big-data-conference-ca-2015/public/schedule/speakers"
speaker_page <-
scrape(url=strata_speakers,
parse=T, headers=T)
href <- xpathSApply(speaker_page[[strata_speakers]], "//a/@href")
href <- unique(href)