Skip to content

Instantly share code, notes, and snippets.

Avatar

takeshy takeshy

View GitHub Profile
@takeshy
takeshy / index.js
Created Feb 25, 2020
firehose_to_elasticsearch_with_slack_notify_on_error
View index.js
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 Feb 23, 2020
kinesys firehose by cloudwatch subscription to elasticsearch
View firehose-cloudwatch-logs-processor-elasticsearch_by_cloudwatch_subscription.js
/*
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 Feb 23, 2020
kinesys firehose by cloudwatch subscription to elasticsearch
View firehose-cloudwatch-logs-processor-elasticsearch_by_cloudwatch_subscription.js
/*
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 Nov 18, 2019
promise custom hooks
View enhancedDispatch.ts
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) => {};
View log2bin.rb
#!/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 Jun 23, 2019
settings json for vs code
View vscofnig.json
{
"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 Nov 15, 2018
remove trailing space on save
View .vimrc
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()
View eijiro_to_dicwin.rb
#!/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}/)
View table_info.rb
#!/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 Jul 11, 2018
typescriptのimport先のファイルの読み込み
View read_ts.vim
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
You can’t perform that action at this time.