Skip to content

Instantly share code, notes, and snippets.

View takeshy's full-sized avatar

takeshy takeshy

  • Sun Asterisk
  • Yokohama
View GitHub Profile
@takeshy
takeshy / index.js
Created February 25, 2020 08:55
firehose_to_elasticsearch_with_slack_notify_on_error
const https = require('https');
const postSlack = (rec)=>{
return new Promise((resolve, reject)=>{
const path = rec.ecs_cluster.match(/staging/) ? process.env.STAGING_SLACK_PATH : process.env.PRODUCTION_SLACK_PATH;
const data = JSON.stringify({ text: JSON.stringify(rec) });
const options = {
hostname: 'hooks.slack.com',
port: 443,
path,
@takeshy
takeshy / firehose-cloudwatch-logs-processor-elasticsearch_by_cloudwatch_subscription.js
Created February 23, 2020 03:49
kinesys firehose by cloudwatch subscription to elasticsearch
/*
For processing data sent to Firehose by Cloudwatch Logs subscription filters.
Cloudwatch Logs sends to Firehose records that look like this:
{
"messageType": "DATA_MESSAGE",
"owner": "123456789012",
"logGroup": "log_group_name",
"logStream": "log_stream_name",
@takeshy
takeshy / firehose-cloudwatch-logs-processor-elasticsearch_by_cloudwatch_subscription.js
Created February 23, 2020 03:48
kinesys firehose by cloudwatch subscription to elasticsearch
/*
For processing data sent to Firehose by Cloudwatch Logs subscription filters.
Cloudwatch Logs sends to Firehose records that look like this:
{
"messageType": "DATA_MESSAGE",
"owner": "123456789012",
"logGroup": "log_group_name",
"logStream": "log_stream_name",
@takeshy
takeshy / enhancedDispatch.ts
Last active November 18, 2019 02:16
promise custom hooks
import { Actions, AppState } from "./reducers/index";
import { useReducer, useMemo, useRef, useEffect } from "react";
import withPromise from "./withPromise";
const groupStart =
process.env.NODE_ENV !== "production"
? (val: string) => {
console.groupCollapsed("Action Type:", val);
}
: (val: string) => {};
@takeshy
takeshy / log2bin.rb
Last active September 24, 2019 08:16
#!/usr/bin/ruby
if ARGV.length != 1
puts "#{$0} outputfile"
exit -1
end
unless file = File.open(ARGV[0],"wb")
puts "#{$0} outputfile"
puts "#{ARGV[0]} can't write"
exit -1
@takeshy
takeshy / vscofnig.json
Created June 23, 2019 05:40
settings json for vs code
{
"editor.minimap.enabled": false,
"editor.formatOnSave": true,
"tslint.alwaysShowRuleFailuresAsWarnings": true,
"window.zoomLevel": 2,
"explorer.confirmDelete": false,
"files.trimTrailingWhitespace": true,
"files.eol": "\n",
"typescript.updateImportsOnFileMove.enabled": "always"
}
@takeshy
takeshy / .vimrc
Created November 15, 2018 02:41
remove trailing space on save
function! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre *.ts,*.rb,*.tsx,*.js,*.erb :call <SID>StripTrailingWhitespaces()
#!/usr/bin/env ruby
require 'nkf'
raw = File.read("#{ENV['HOME']}/Downloads/EIJIRO-1445.TXT")
data = NKF.nkf("-w -d", raw)
results = {}
first_flg = false
data.each_line do |raw_line|
next if !first_flg && !raw_line.match(/a\s+{不-1}/)
#!/usr/bin/ruby
require 'rubygems'
require 'mysql'
require 'optparse'
options = {
:database => '',
:host=> 'localhost',
:create=> false,
:count=> false,
:index=> false,
@takeshy
takeshy / read_ts.vim
Last active July 11, 2018 07:41
typescriptのimport先のファイルの読み込み
function! ReadFile() abort
let s:currentPos = col('.')
let s:colNum = s:currentPos - 1
let s:lastPos = len(getline('.'))
let s:fileName = ''
let s:ext = '.' . expand("%:e")
while s:colNum > -1
if getline('.')[s:colNum] =~ "\['\"\]"
break
end