Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'erb'
require 'tmpdir'
require 'digest'
argv_hash = Digest::MD5.hexdigest(Dir.pwd + ARGV.join)
file = ARGV.shift
if file.nil? || file.empty? || file == '--help'
puts 'Usage: erbview FILE'
exit
@emad-elsaid
emad-elsaid / access_postgresql_with_docker.md
Created November 24, 2018 13:52 — forked from MauricioMoraes/access_postgresql_with_docker.md
Allow Docker Container Access to Host's Postgres Database on linux (ubuntu)

You have to do 2 things in order to allow your container to access your host's postgresql database

  1. Make your postgresql listen to an external ip address
  2. Let this client ip (your docker container) access your postgresql database with a given user

Obs: By "Host" here I mean "the server where docker is running on".

Make your postgresql listen to an external ip address

Find your postgresql.conf (in case you don't know where it is)

$ sudo find / -type f -name postgresql.conf

@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' }