Skip to content

Instantly share code, notes, and snippets.

@TorvaldsDB
TorvaldsDB / image_validate.rb
Last active Nov 26, 2019
How to validate whether an image url is valid or not
View image_validate.rb
module ImgageValidate
module_function
def url_exist?(url)
uri = URI.parse(url)
Net::HTTP.start(uri.host, uri.port) do |http|
Net::HTTP.start(uri.host, uri.port) do |http|
response = http.head(uri.path)
case response
when Net::HTTPSuccess, Net::HTTPRedirection
@TorvaldsDB
TorvaldsDB / alias_for_tmux_sessions.markdown
Created Nov 14, 2019
tmux alias config in .bashrc OR .bash_profile OR .zshrc to conveniently handle tmux sessions
View alias_for_tmux_sessions.markdown
  alias tnew='tmux new -s' # new a session
  alias tls='tmux ls'      # list all sessions
  alias topen='tmux a -t'  # open one of sessions with session number
  alias tlast='tmux a'     # resume last used session
  alias tkill='tmux kill-session -t' # kill one of sessions with session number
  alias tkillall='tmux kill-server'  # kill all sessions
@TorvaldsDB
TorvaldsDB / sample.js
Created Nov 10, 2019
JS how to return a sample of an array?
View sample.js
arr = [1, 2, 3, 4 , 5]
arr[Math.floor(Math.random() * arr.length)]