Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
emad-elsaid / network-connections-places
Last active November 9, 2018 08:04
this shows you the connections from your machine to the outside world and where every connection leads to, the company that owns this IP and which country is it
#!/usr/bin/env ruby
require 'json'
ips = `ss -4 | awk '// { print($6) }' | cut -d':' -f1`.lines.map(&:strip).uniq
markers = []
ips.each do |ip|
info = `curl -s ipinfo.io/#{ip}`
json = JSON.parse(info)
#!/usr/bin/env ruby
require 'tty-prompt'
require 'open-uri'
require 'json'
require 'colorize'
require 'colorized_string'
prompt = TTY::Prompt.new
user_name = prompt.ask("What is name of the user or organisation?")
require 'sinatra'
set :port, 3000
TEMPLATE = DATA.read
class Async
# execute a block identified by `id` synchronously if block is done returns
# the block return value if not finished it returns the `default` value the
# if the `id` id not provided it uses the block source location as an id
# Example:
#!/usr/bin/env ruby
# How to use that script
# =======================
#
# I write several small scripts to aid me in my workflow, I usually keep them in
# one directory added to my PATH but that means to execute one of them I need to
# recall the name of every script, but in reality I forget that That I even
# wrote it and sometimes I rewrite the same script many times because of this.
#
# So what I learned here is that these scripts needs a long meaningful name, and
#!/usr/bin/env ruby
# How to use that script
#=======================
# I write several small scripts to aid me in my workflow, I usually keep them in
# one directory added to my PATH but that means to execute one of them I need to
# recall the name of every script, but in reality I forget that That I even
# wrote it and sometimes I rewrite the same script many times because of this.
# So what I learned here is that these scripts needs a long meaningful name, and
# some interface to search through them an interface that's flexible enough like
# Emacs helm package, a fuzzy finder that search through a long list of scripts
acpi
adobe-source-han-sans-otc-fonts
aircrack-ng
alsa-utils
android-studio
android-tools
ansible
arandr
arc-gtk-theme
aspell-en

Keybase proof

I hereby claim:

  • I am emad-elsaid on github.
  • I am emadelsaid (https://keybase.io/emadelsaid) on keybase.
  • I have a public key ASCV61CUZ9bu9t-EbGJywYRLtjjNKNbPtc0sdca0IDsyZQo

To claim this, I am signing this object:

@emad-elsaid
emad-elsaid / hydra.rb
Last active September 21, 2018 09:45
this script uses 'command_tree' gem to define a tree of commands for the terminal
#!/usr/bin/env ruby
require 'command_tree'
t = CommandTree::Tree.new
# You register functions here to be executed with characters sequence
t.register('a', 'Greetings')
t.register('ag', 'Greeting') { puts 'hello' }
t.register('aG', 'Greeting special') { puts 'hello man.' } # character are case sensitive
t.register('as', 'Sup') { puts 'Sup man' }
#!/usr/bin/env erb
<%
stats = `bundle --local | tail -n2 | head -n1`.scan(/[0-9]+/)
def files_for(ext)
Dir.glob('**/*.' + ext)
end
def size_for(ext)
files_for(ext).map{|f| File.size(f) }.inject(:+).to_i
end
(setq quick-command "pwd")
(defun set-quick-command ()
"Set quick command"
(interactive)
(setq quick-command (read-string "Enter a quick commmand:")))
(defun execute-quick-command ()
"Execute a command that was set in quick-command variable"
(interactive)