Skip to content

Instantly share code, notes, and snippets.

View modsaid's full-sized avatar

Mahmoud Salem modsaid

View GitHub Profile
@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;
@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
@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 >
#
@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
@bradmontgomery
bradmontgomery / dummy-web-server.py
Last active April 15, 2024 14:27
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 (Updated for Python 3.7)
Usage:
./dummy-web-server.py -h
./dummy-web-server.py -l localhost -p 8000
Send a GET request:
@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
@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>
@postmodern
postmodern / bump_copyright.rb
Created January 3, 2012 02:18
Automatically bump the year in the Copyright-notice headers of Ruby files.
@samqiu
samqiu / railscasts.rb
Last active December 9, 2022 03:49
Download free Railscast video
#!/usr/bin/ruby
require 'rss'
# Usage
# $ ./railscasts.rb http://railscasts.com/subscriptions/YOURRAILSCASTRSS/\/
# episodes.rss
# OR
# $ ./railscasts.rb
p 'Downloading rss index'
@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.
#