Skip to content

Instantly share code, notes, and snippets.

@a2ikm
a2ikm / gist:a2d0f6d049ad3999b53497a611ead552
Created September 1, 2017 05:49
strip all text attributes out of copy/pasting from Terminal
defaults write com.apple.Terminal CopyAttributesProfile com.apple.Terminal.no-attributes
@a2ikm
a2ikm / gist:5cf9d03637e1cab5ac2e7446e9f67115
Created September 1, 2017 05:48
strip all text attributes out of copy/pasting from Terminal
defaults write com.apple.Terminal CopyAttributesProfile com.apple.Terminal.no-attributes
#!/usr/bin/env ruby
require "terminal-table"
slim_path = ARGV[0]
fat_path = ARGV[1]
def parse_objects(path)
ok = false
counts = {}
require "json"
require "rack/cors"
class Page
def each
loop do
count = [1, 2, 3].sample
words = %w(one two thee four five six seven).sample(count)
json = words.map { |word|
{ word: word }.to_json
@a2ikm
a2ikm / config.ru
Created June 29, 2017 17:31
chunked
class Page
def each
loop do
yield %w(one two thee four five).sample
sleep 1
end
end
end
use Rack::Chunked
#!/usr/bin/env ruby
def parse_query(query)
lines = query.split("\n")
[lines.shift, lines.join("\n")]
end
require "shellwords"
path = ARGV[0] or abort "Usage: tail_slow_log.rb <path_to_slow_log>"
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND != 'Sleep' ORDER BY TIME DESC;
@a2ikm
a2ikm / notify_slack_munin.sh
Last active February 22, 2017 07:51 — forked from hugochinchilla/slack_munin.sh
Slack notification script for Munin
#!/bin/bash
# Slack notification script for Munin
# Mark Matienzo (@anarchivist)
#
# To use:
# 1) Create a new incoming webhook for Slack
# 2) Edit the configuration variables that start with "SLACK_" and "MUNIN_URL" below
# 3) Add the following to your munin configuration:
#
@a2ikm
a2ikm / benchmark.rb
Last active February 17, 2017 14:06
Struct vs Hash initialized from Arrays
require "benchmark"
fields = [:f1, :f2, :f3, :f4, :f5, :f6]
struct = Struct.new("Something", *fields)
values_array = 10_000.times.map {
[rand(10000), rand(10000), rand(10000), rand(10000), rand(10000), rand(10000)]
}
Benchmark.bm(10) do |x|
@a2ikm
a2ikm / bash
Created December 5, 2016 13:11
`File.expand_path("..", __FILE__)` 的なやつ
here="$( cd "$(dirname "$0")"; pwd )"