Skip to content

Instantly share code, notes, and snippets.

View modsaid's full-sized avatar

Mahmoud Salem modsaid

View GitHub Profile
@shyam
shyam / compile-ruby-1.9.x-on-linux.sh
Created September 22, 2011 06:49
Installing Ruby 1.9.x from source on Linux ( Debian/Ubuntu and RHEL/CentOS )
# Note: This script show how to compile ruby-1.9.2-p290. It can also be used for 1.9.3-p0 or higher versions.
#
# Dependencies
#
# Debian and derivatives:
# aptitude install build-essential libssl-dev libcurl4-openssl-dev libreadline5-dev zlib1g-dev libxslt1-dev libxml2-dev
@postmodern
postmodern / bump_copyright.rb
Created January 3, 2012 02:18
Automatically bump the year in the Copyright-notice headers of Ruby files.
@modsaid
modsaid / download_railscasts.rb
Created April 7, 2013 13:42
Ruby script for downloading rails casts http://blog.modsaid.com/2010/02/ruby-script-for-downloading-rails-casts.html this has been posted 3 years ago actually
#!/usr/local/bin/ruby
# A script to download the latest episodes from railscasts.com
#
# requires simple-rss (1.2.2) gem
# and base on linux wget
#
# author: modsaid < mahmoud@modsaid.com >
#
@muhammednagy
muhammednagy / fun.erl
Last active February 24, 2017 17:54
variables and patterns in erlang
-module(fun).
-export([maxThree/3,howManyEqual/3]).
maxThree(A,B,C) ->
Z = max(A,B),
max(Z,C).
howManyEqual(A,A,_) ->
2;
@madtrick
madtrick / remote_authenticatable.rb
Created October 19, 2012 08:43
Example module to perform remote authentication with Devise
module Devise
module Models
module RemoteAuthenticatable
extend ActiveSupport::Concern
#
# Here you do the request to the external webservice
#
# If the authentication is successful you should return
# a resource instance
@seanlinsley
seanlinsley / gist:2038003
Last active June 7, 2019 08:00
A better form to edit multiple child records. Created for https://github.com/gregbell/active_admin/issues/1097
<%= semantic_form_for @parent do |a| %>
<%= a.inputs "Family Details" do %>
<%= a.input :name %>
<%= a.input :user %>
<%= a.input :region %>
<% end %>
<%= a.inputs "Children" do %>
<table>
@amir20
amir20 / to_csv.rb
Created March 15, 2012 01:10
Converts YAML to CSV
#!/usr/bin/ruby
if ARGV.size.zero?
puts %Q[
Usage:
./to_csv.rb file.yml > out.csv
]
exit
end
@ondrej-kvasnovsky
ondrej-kvasnovsky / commands.md
Last active April 25, 2020 19:43
Commands to install and configure ElasticSearch on Ubuntu

Install ElasticSearch and Java

1  wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.0.1.deb
2  sudo dpkg -i elasticsearch-1.0.1.deb
3  sudo update-rc.d elasticsearch defaults 95 10
4  sudo add-apt-repository ppa:webupd8team/java
5  sudo apt-get update
6  sudo apt-get install oracle-java7-installer
7  java -version
@rsvp
rsvp / netspeed.sh
Last active May 13, 2020 15:08
netspeed.sh : check download speed rate via command line | Linux bash script
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2013-07-11
#
# _______________| netspeed : check download speed via command line.
#
# Usage: netspeed [tokyo, london, usw, use, east, west, URL]
# ^default U.S. west coast.
# [ -speed_KB/sec ]
# ^negation activates the Mbps converter.
#
@tansengming
tansengming / Rails Console Actionmailer test.rb
Created April 24, 2009 15:14
Rails Console Actionmailer test
# Copy and paste this to the rails console to test your email settings
class MyMailer < ActionMailer::Base
def test_email
@recipients = "someone@somewhere.com"
@from = "must_be_same_as_smpt_account_login@gmail.com"
@subject = "test from the Rails Console"
@body = "This is a test email"
end
end