Skip to content

Instantly share code, notes, and snippets.

@vs-zhang
vs-zhang / copy.rb
Created November 14, 2017 18:04 — forked from chrisbodhi/copy.rb
Copy from IRB/Pry to the system clipboard
# https://coderwall.com/p/qp2aha/ruby-pbcopy-and-pbpaste
def pbcopy(input)
str = input.to_s
IO.popen('pbcopy', 'w') { |f| f << str }
str
end
@vs-zhang
vs-zhang / install_elasticsearch_osx.md
Created August 18, 2017 19:15 — forked from djonsson/install_elasticsearch_osx.md
OS X installation instructions for Elasticsearch + Kibana + Marvel

What is this?

Following this guide will set up a local Elasticsearch with Kibana and Marvel using Homebrew and Homebrew Cask

Prerequisites

If you already have Java installed on your system, skip steps Install Cask and Install Java

If you already have Java and Homebrew installed on your system, skip steps Prerequisites, start at Install Elasticsearch and Kibana after running $ brew update

Install Homebrew

  • $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@vs-zhang
vs-zhang / slack-dark-theme.css
Last active September 18, 2017 15:35 — forked from gkostov/slack-dark-theme.css
Dark theme for slack
#msgs_scroller_div::-webkit-scrollbar-track, #client_body::before, .client_container,
#search_terms, #client_body, #footer, ts-message, .channel_header, ts-jumper ts-jumper-container,
ts-jumper input[type="text"],
.supports_custom_scrollbar:not(.slim_scrollbar) #col_channels:hover #channels_scroller::-webkit-scrollbar-track{
background: #333 !important;
}
#client_body::before {
border-bottom: 1px solid #1a2129 !important;
}
@vs-zhang
vs-zhang / shortest_encapsulator
Created March 24, 2015 21:23
find the shortest encapsulator during string arrays, etc 'abc', 'bc', 'a' will be 'abca'
def make_encapsulator_string(first, second, collapse_index)
first + second[0+collapse_index...second.length]
end
def encapsulate_two_strings(first, second)
max_index = first.length < second.length ? first.length : second.length
while max_index >= 0
return make_encapsulator_string(first, second, max_index) if second.start_with?(first[-max_index..-1])
max_index -= 1
end