Skip to content

Instantly share code, notes, and snippets.

View yu-iskw's full-sized avatar

Yu Ishikawa yu-iskw

View GitHub Profile
@yu-iskw
yu-iskw / circleci_config_commands.yml
Last active October 2, 2020 06:39
Reusable CircleCI command to halt a job if target files are not changed
# .circleci/config.yml
commands:
check-diff-files-to-halt:
description: "halt CircleCI step if there is any files matched with a pattern"
parameters:
pattern:
description: "regular expression to filter changed files"
type: string
steps:
- run: |
@yu-iskw
yu-iskw / get_changed_files.sh
Last active October 2, 2020 06:03
A bash script to get changed files in git
#!/bin/bash
set -e
# Arguments
pattern="${1:?"the first argument for pattern is not set"}"
# Constants
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
# Determine the target
@yu-iskw
yu-iskw / tfrecord.py
Created March 28, 2019 02:48
TFRecord for list of list
def _int64_feature(value):
# value must be a numpy array.
return tf.train.Feature(int64_list=tf.train.Int64List(value=value.flatten()))
# Write an array to TFrecord.
# a is an array which contains lists of variant length.
a = np.array([[0, 54, 91, 153, 177],
[0, 50, 89, 147, 196],
[0, 38, 79, 157],
[0, 49, 89, 147, 177],
@yu-iskw
yu-iskw / makefile.inc
Created February 2, 2018 23:38
makefile.inc to build faiss on my Mac
# -*- makefile -*-
# Tested on macOS Sierra (10.12.2) with llvm installed using Homebrew (https://brew.sh)
# brew install llvm
CC=/usr/local/opt/llvm/bin/clang++
CFLAGS=-fPIC -m64 -Wall -g -O3 -msse4 -mpopcnt -fopenmp -Wno-sign-compare -I/usr/local/opt/llvm/include -I/usr/include/malloc -std=c++11
LDFLAGS=-g -fPIC -fopenmp -L/usr/local/opt/llvm/lib
# common mac flags
@yu-iskw
yu-iskw / error.md
Last active March 2, 2018 11:37
Error when I tried to install ipopt with brew
$ export HOMEBREW_NO_AUTO_UPDATE=1

$ brew tap homebrew/science --full

$ cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-science
$ git checkout 60f6064467f36b80dbcc91164d21acd4ca227ae4

$ brew install ipopt --with-openblas
Warning: Calling 'depends_on :fortran' is deprecated!
@yu-iskw
yu-iskw / image-downloader.py
Created January 11, 2018 18:42
Fast image downloader with concurrent
import os
import imghdr
import concurrent.futures
from urllib.parse import urlparse
from urllib.request import urlretrieve
def is_jpeg(path):
if imghdr.what(path) == 'jpeg':
return True
@yu-iskw
yu-iskw / file0.txt
Last active September 19, 2017 23:03
Python で大量の JPEG 画像を高速にダウンロードするスクリプト ref: http://qiita.com/yu-iskw/items/303c8ae3828f93bbd3fc
usage: image-downloader.py [-h] --url-list URL_LIST_PATH --outputs OUTPUT_PATH
Options for image-downloader.py
optional arguments:
-h, --help show this help message and exit
--url-list URL_LIST_PATH
path to a list of image URLs
--outputs OUTPUT_PATH
@yu-iskw
yu-iskw / add.sh
Last active July 1, 2022 20:51
Example to add a airflow connection to google cloud platform
#!/bin/bash
airflow run add_gcp_connection add_gcp_connection_python 2001-01-01
@yu-iskw
yu-iskw / log.txt
Created July 20, 2017 19:43
Spark Streaming on Google Dataproc was failed.
com.google.cloud.hadoop.services.agent.AgentException: Node was restarted while executing a job. This could be user-initiated or caused by Compute Engine maintenance event. (TASK_FAILED)
at com.google.cloud.hadoop.services.agent.AgentException$Builder.build(AgentException.java:83)
at com.google.cloud.hadoop.services.agent.job.AbstractJobHandler.lambda$kill$0(AbstractJobHandler.java:211)
at com.google.cloud.hadoop.services.repackaged.com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:211)
at com.google.cloud.hadoop.services.repackaged.com.google.common.util.concurrent.AbstractTransformFuture$AsyncTransformFuture.doTransform(AbstractTransformFuture.java:200)
at com.google.cloud.hadoop.services.repackaged.com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:130)
at com.google.cloud.hadoop.services.repackaged.com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:435)
@yu-iskw
yu-iskw / file0.txt
Last active July 18, 2017 14:36
Apache Airflow + Slack でデータクオリティチェックを自動化する ref: http://qiita.com/yu-iskw/items/dc0561c15729bb390f9f
{"timestamp":1500233640,"user_id":1234,"event_id":"view",...}
{"timestamp":1500233641,"user_id":4321,"event_id":"post",...}