Skip to content

Instantly share code, notes, and snippets.

torvalds TorvaldsDB

Block or report user

Report or block TorvaldsDB

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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)]
You can’t perform that action at this time.