Skip to content

Instantly share code, notes, and snippets.

@varlal
varlal / config.json
Created December 15, 2018 15:20
S3に保存したjsonファイルに変更を加え別のS3バケットに保存するサンプル
{ "accessKeyId": "<id>", "secretAccessKey": "<key>", "region": "ap-northeast-1" }
@varlal
varlal / Result_of_test(test.log)
Created November 17, 2018 17:38
Relax... CouchDB compaction test.
--- State1: Start ---
#du -h ~/date
12K /home/varlal/data/shards/40000000-5fffffff
8.0K /home/varlal/data/shards/00000000-1fffffff
8.0K /home/varlal/data/shards/80000000-9fffffff
8.0K /home/varlal/data/shards/60000000-7fffffff
8.0K /home/varlal/data/shards/c0000000-dfffffff
8.0K /home/varlal/data/shards/20000000-3fffffff
8.0K /home/varlal/data/shards/a0000000-bfffffff
8.0K /home/varlal/data/shards/e0000000-ffffffff
@varlal
varlal / a_tour_of_go_list.go
Last active April 3, 2018 14:22
a_tour_of_go_list
// Goのプログラムはpackageで構成
// importでパッケージを読み込み
package main
// 規約:パッケージ名はインポートパスの最後の要素と同じ名前
// 例えば、math/randをインポートすると、package randを読み込む
import "math/rand"
// 1行づつimport
@varlal
varlal / servo.ino
Last active September 2, 2017 17:54
16servo
#include <Adafruit_PWMServoDriver.h>
#include <Wire.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
#define SERVOMIN 150
#define SERVOMAX 600
#define CENTER 375
#define MODE_DEBUG 1
#define MODE_MOTION 2
#include <Servo.h>
Servo myservo;
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int servoPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0;
int sensorBuff[10] = {0,0,0,0,0,0,0,0,0,0};
int aveValue = 0;
@varlal
varlal / ubuntu16_04-init.sh
Last active November 26, 2016 17:16
仮想環境でubuntuを立てる頻度が多くなったので始めるやるコマンドをまとめておく
#! /bin/sh
# ubuntu16.04
#
# homeの表記を英語にする
LANG=C xdg-user-dirs-gtk-update
sudo apt-get update
sudo apt-get upgrade
@varlal
varlal / file0.txt
Last active November 11, 2016 06:53
4ステップで始めてみた最新MQ Pulsar ref: http://qiita.com/varlal/items/bc082b3680b8c858020b
$ curl -L -O https://github.com/yahoo/pulsar/releases/download/v1.15.2/pulsar-1.15.2-bin.tar.gz
$ tar xvfz pulsar-1.15.2-bin.tar.gz
$ ./pulsar-1.15.2/bin/pulsar standalone
@varlal
varlal / SRM583_DIV2_250.txt
Last active June 17, 2016 15:55
ある数字の文字numが与えられた時,一度だけ一文字を交換できる.ただし,先頭に0は来ない. この時,値が最小になるように文字を交換せよ.
0)
“596”
Returns: “569”
You can swap num[1] and num[2] to get the minimum integer.
1)
“93561”
Returns: “13569”
2)
@varlal
varlal / SwappingDigits.java
Created June 17, 2016 15:51
SwappingDigits.java
import java.util.Collections;
import java.util.TreeSet;
public class SwappingDigits {
public String minNumber(String num) {
TreeSet<String> results = new TreeSet<String>();
results.add(num);
int n = num.length();
for (int i = 0; i < n; i++) {
@varlal
varlal / basicCreate.sh
Last active October 26, 2016 22:51
さくっとBasic認証を追加するスクリプト ref: http://qiita.com/varlal/items/a3fd37f4e636785d26e1
#!/bin/sh
echo "Create .htaccess and .htpasswd for basic auth"
BASE_PATH=`pwd`
cat <<EOF > .htaccess
AuthUserfile $BASE_PATH/.htpasswd
AuthGroupfile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic