Skip to content

Instantly share code, notes, and snippets.

View potix2's full-sized avatar
:octocat:

Katsunori Kanda potix2

:octocat:
View GitHub Profile
@potix2
potix2 / install.sh
Created March 27, 2019 11:42
Install modules to use puppeteer on Amazon Linux
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/atk-2.28.1-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-atk-2.26.2-1.el7.x86_64.rpm
sudo rpm -ivh --nodeps http://mirror.centos.org/centos/7/os/x86_64/Packages/at-spi2-core-2.28.0-1.el7.x86_64.rpm
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
sudo yum install -y nodejs gcc-c++ make cups-libs dbus-glib libXrandr libXcursor libXinerama cairo cairo-gobject pango libXScrnSaver gtk3
sudo yum install -y libX11 libXcomposite libXcursor libXdamage libXext libXi libXtst cups-libs libXScrnSaver libXrandr alsa-lib pango gtk3
mkdir puppeteer
cd puppeteer/
npm install puppeteer
@potix2
potix2 / main.go
Created January 10, 2019 06:13
GetEncryptedSystemParameterFromLambda
package main
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ssm"
@potix2
potix2 / Main.scala
Created March 19, 2018 07:18
Call sheets API v4 with a service account
import java.io.{File, InputStream}
import java.net.URL
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport
import com.google.api.client.http.javanet.NetHttpTransport
import com.google.api.client.json.jackson2.JacksonFactory
import com.google.api.services.sheets.v4.model._
import com.google.api.services.sheets.v4.{Sheets, SheetsScopes}
@potix2
potix2 / main.go
Created November 21, 2017 05:56
escape invalid utf8 bytes
package main
import (
"fmt"
"strings"
"unicode/utf8"
)
func escape(s string) string {
return strings.Trim(fmt.Sprintf("%q", s), "\"")
@potix2
potix2 / gist:79cd2ff12b9ab2f0cd98e08785fc85a3
Created December 21, 2016 14:00
string.Template test
>>> from string import Template
>>> import os
>>> s = Template("I am $USER")
>>> s.substitute(os.environ)
'I am potix2'
@potix2
potix2 / Chapter3.md
Last active July 17, 2018 06:25
実践機械学習システム - 3章

3章 クラスタリング: 関連のある文書を見つける

  • ラベル付きデータが入手できない状況を考える
  • Q&Aサイトを運営する場面。今見ているページ内容と関連する情報を提示したい。
  • 文書間の類似度を素早く算出することで実現する。クラスタリングを使う。

3.1 文書の関連性を計測する

3.1.1 やってはいけないこと

@potix2
potix2 / tracker.py
Created November 17, 2016 09:17
rostopic list | grep kinect2
/kinect2/bond
/kinect2/hd/camera_info
/kinect2/hd/image_color
/kinect2/hd/image_color/compressed
/kinect2/hd/image_color_rect
/kinect2/hd/image_color_rect/compressed
/kinect2/hd/image_depth_rect
/kinect2/hd/image_depth_rect/compressed
/kinect2/hd/image_mono
/kinect2/hd/image_mono/compressed
@potix2
potix2 / view_mask.py
Created November 17, 2016 08:58
simple target dtection
#!/usr/bin/env python
import cv2
import numpy
# read png image and convert the image to HSV
image = cv2.imread("/path/to/target.png", cv2.IMREAD_COLOR)
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
# detect green objects
@potix2
potix2 / tagless.scala
Created December 18, 2015 14:50
[WIP]tagless final
//SEE: http://keens.github.io/slide/DSLtoTagless_Final/
case class Result
case class JSON
trait ScenarioSYM[T] {
def get(url: String): ScenarioSYM[T]
def post(url: Sting, data: JSON): ScenarioSYM[T]
def and(first: ScenarioSYM[T], second: ScenarioSYM[T]): ScenarioSYM[T]
def run(scenario: ScenariosSYM[T]): ScenarioSYM[T]
}
class ConcatDFSpec extends org.specs2.mutable.Specification {
def concat(df: DataFrame, inputColName: String, concatColName: String, outputColName: String, dataType: DataType): DataFrame =
df.withColumn(outputColName, callUDF(_ ++ _, dataType, df(inputColName), df(concatColName)))
// val paramMap: ParamMap
// val inputCol: Param[String]
// val outputCol: Param[String]
// val concatCol: Param[String]
// concat(df, paramMap(inputCol), paramMap(outputCol), paramMap(concatCol), dataType)
type A = Map[String, Int]