Skip to content

Instantly share code, notes, and snippets.

@tjws052009
tjws052009 / gen.rb
Created December 5, 2022 03:31
Create semi-realtime demo data which includes geo_point and some sensor-like data for Elasticsearch.
# example for running this script
# ES_URL="xxyyzz.es.asia-northeast1.gcp.cloud.es.io" KB_URL="xxyyzz.kb.asia-northeast1.gcp.cloud.es.io" ES_PORT="9243" ES_USER="elastic" ES_PASSWORD="xxyyzz" ruby gen.rb
#
# WARNING:
# This script deletes an index while processing, make sure you don't forget to comment that out if you plan to keep the index.
require 'base64'
require 'json'
require 'net/http'
@tjws052009
tjws052009 / ilm_vs_ds.md
Created April 23, 2021 00:42
A quick memo on setting up ILM and Datastreams in Elasticsearch
# Comparing ILM to datastreams in terms of set up

# ===================================
# Clean up and settings to help with demo

GET _cat/indices/exp_*
GET _data_stream/exp_ds*
GET _ilm/policy/exp_policy
GET _index_template/exp_temp
@tjws052009
tjws052009 / eql.md
Last active August 3, 2021 02:20
A bit of EQL
@tjws052009
tjws052009 / vega-heatmap.json
Last active March 24, 2021 06:51
Vega experiment
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 500,
"height": 500,
"title": "Test heatmap",
"data": [
{
"name": "input",
"values": [
{"x": 0, "y": 0, "val": 0},
@tjws052009
tjws052009 / setup_centos7_esws.sh
Last active December 21, 2020 02:35
Setup for CentOS7 Elasticsearch Workshop
#!/bin/bash
# sudo yum update -y
# install elastic yum repo
sudo rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
sudo sh -c "cat > /etc/yum.repos.d/elasticsearch.repo <<EOL
[elastic-7.x]
name=Elastic repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
@tjws052009
tjws052009 / snippets.txt
Last active September 27, 2019 00:20
azure fundamental snippets
# Last tested 2019/09/24 - No guarentees it works
# Slides - available until 2019/09/27 6PM
https://azfund1909.blob.core.windows.net/file/AzureFundamentals-v20190926.pdf?sp=r&st=2019-09-26T00:00:00Z&se=2019-09-30T08:18:58Z&spr=https&sv=2018-03-28&sig=4u89POJ0ErCLpP%2FaCmoqm3Gw9gKSKykg012D6%2BxjxnA%3D&sr=b
# PaaS deployment snippet
$ sudo yum -y install git # not needed for Cloud Shell
$ git config --global user.email "johndoe@example.com"
$ git config --global user.name "John Doe"
$ wget https://github.com/tjws052009/rubyapp/archive/master.zip
@tjws052009
tjws052009 / iaasnetwork.json
Created June 25, 2018 01:21
Azure ARM Template for 2VMs and 1 Load Balancer.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"loadBalancers_app_lb_name": {
"defaultValue": "app-lb",
"type": "String"
},
"virtualMachines_app_vm_name": {
"defaultValue": "app-vm",
@tjws052009
tjws052009 / git_rbenv.sh
Last active November 25, 2018 07:38
Docker用に git + rbenv インストールするためのスクリプト用意
#!/bin/bash
sudo yum install -y git
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
@tjws052009
tjws052009 / sample.rb
Created January 24, 2014 10:55
実験でrubyの「普通」な書き方と、関数型っぽい書き方の実行速度を比べてみたくなったので、消費税計算っぽい事をお題にやってみた。
#-*- coding:utf-8 -*-
#
# Ruby skeleton file
#
require 'benchmark'
require 'ruby-prof'
itrs = 500
#!/bin/sh
usage() {
echo "Usage: hoge.sh -h hostname -m master_hostname -p puppet_port"
exit 2
}
params=`getopt "h:m:p:i:k:" $*`
set -- $params