Skip to content

Instantly share code, notes, and snippets.


Mahmoud Salem modsaid

View GitHub Profile
modsaid /
Created Jan 20, 2020
helpful to apply after iptables commands on remote servers to avoid locking yourself out
sleep 2m
iptables -F
iptables -P INPUT ACCEPT
modsaid /
Created May 30, 2018 — forked from bradmontgomery/
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
Very simple HTTP server in python.
./ [<port>]
Send a GET request::
curl http://localhost
modsaid / action_mailer_check.rb
Created Mar 9, 2016
Script to test action mailer configuration. to be run through the console, or rails runner
View action_mailer_check.rb
# author @modsaid
# Script to test action mailer configuration. to be run through the console, or rails runner
class MyMailer < ActionMailer::Base
default from: ''
def test_email
mail(to: "",
subject: 'SMTP configuraiton test',
body: 'bla bla bla')
modsaid /
Last active Sep 15, 2015
Convert batch csv files into xlsx in a single command
# This script uses ssconvert to convert all *.csv files in the current directory into *.xlsx format
command -v ssconvert >/dev/null 2>&1 || { echo >&2 "ssconvert is not installed, please install it via apt-get install gnumeric"; exit 1; }
find . -maxdepth 1 -name "*.csv" -exec ssconvert {} --export-type=Gnumeric_Excel:xlsx2 \;
modsaid /
Created Oct 21, 2014
Rename hourly rotated web access logs (access.log.1, access.log.2) to include the timestamp for better management of the times
# This script is made to rename default rotated access log files from access.log.1, access.log.2 and
# so on, to using timestamp instead of auto increment index (to be access.log.2014102009)
# cd LOGS_DIR && ./
Rails as it has never been before :)
modsaid / add-copyright.rb
Last active May 25, 2016
This ruby scripts add the prepends the specified arbitrary text (e.g copyright notice) to all .rb files under a given directory
View add-copyright.rb
modsaid / download_railscasts.rb
Created Apr 7, 2013
Ruby script for downloading rails casts this has been posted 3 years ago actually
View download_railscasts.rb
# A script to download the latest episodes from
# requires simple-rss (1.2.2) gem
# and base on linux wget
# author: modsaid < >
modsaid / gist:3833121
Created Oct 4, 2012
Testing ActionMailer from Rails 3 console
View gist:3833121
#place this directly in the rails console of ur rails application
class UserMailer < ActionMailer::Base
default from: ''
def test_email
@receiver_email = ''
mail(to: @receiver_email, subject: 'testing email from console')
modsaid / application_controller.rb
Created May 14, 2012
Default rescue for all actions/controllers
View application_controller.rb
#To be placed in application_controller.rb
rescue_from Exception, :with => :rescue_all_exceptions unless %W(development test).include?(Rails.env)
def rescue_all_exceptions(exception)
buffer = "[EXCEPTION] "
buffer << exception.message << "\t(Request: #{request.url}\t Referrer: (#{request.env['HTTP_REFERER']} ) \n\t"
buffer << exception.backtrace.join("\n\t")
Rails.logger.error buffer