Skip to content

Instantly share code, notes, and snippets.

@hkurokawa
hkurokawa / check-download.sh
Last active April 20, 2021 16:13
Bash scripts to export custom emojis in a slack team
#! /bin/bash
TOKEN=xxxxx
curl -s -XPOST "https://slack.com/api/emoji.list?token=${TOKEN}" | jq -r '.emoji | to_entries[] | select(.value | test("^alias:") | not) | [.key, .value] | @tsv' | while IFS=$'\t' read -r emoji url; do
file="${emoji}.${url##*.}"
if [ ! -f ${file} ]; then
echo "The file does not exist: ${file}"
continue
fi
expected_size=$(curl -sI ${url} | awk '/Content-Length/{print $2}' | tr -d "\r\n")
import org.apache.lucene.analysis.ja.JapaneseAnalyzer
import org.apache.lucene.analysis.ja.JapaneseTokenizer
import org.apache.lucene.analysis.ja.dict.UserDictionary
import org.apache.lucene.analysis.ja.tokenattributes.BaseFormAttribute
import org.apache.lucene.analysis.ja.tokenattributes.PartOfSpeechAttribute
import org.apache.lucene.analysis.ja.tokenattributes.ReadingAttribute
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute
import org.junit.Test
import java.io.StringReader
@hkurokawa
hkurokawa / Vagrantfile
Last active October 12, 2017 07:01
Vagrantfile for ISUCON 6 Qualification on AWS-EC2
# coding: utf-8
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
import io.reactivex.Maybe;
import io.reactivex.Single;
import org.junit.Test;
public class SingleTest {
@Test public void testSingleConcat() {
Single<String> localSource = Single.create(emitter -> {
emitter.onError(new RuntimeException("1個目のError"));
});
class A
FOO = 'foo'
end
class B < A
def self.foo
p FOO
end
class << self
final Exception e = new Exception("Failure!");
Single.zip(Single.just(1), Single.error(e), Pair::new)
.test()
.assertError(e);
final Exception e = new Exception("Failure!");
Observable.just(1)
.zipWith(Observable.error(e), Pair::new)
.test()
.assertError(e);
@hkurokawa
hkurokawa / AndroidManifest.xml
Created September 5, 2016 12:28
Code to reproduce a problem of InfiniteViewPager
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hiroshi.adaptersample">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
@hkurokawa
hkurokawa / UsingResourceSample.java
Last active July 14, 2016 10:34
A sample code to reproduce an issue that the unsubscription thread is sometimes different from the subscription thread.
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
import rx.schedulers.Schedulers;
public class UsingResourceSample {
public static void main(String[] args) throws InterruptedException {
for (int i = 0; i < 10; i++) {
Observable.using(() -> {
System.out.println("Getting @" + Thread.currentThread());
#! /bin/sh
WEBHOOK_URL=https://hooks.slack.com/services/XXXXXXXX
CHANNEL=#mychannel
echo "Starting notification for ${CHANNEL} with ${WEBHOOK_URL}"
if [ -z "$(which curl)" ];then
echo "curl command doesn't exist!" 1>&2
exit 1