Skip to content

Instantly share code, notes, and snippets.

View arashm's full-sized avatar
:shipit:

Arash Mousavi arashm

:shipit:
View GitHub Profile
@arashm
arashm / redis_pub_sub.rb
Last active March 7, 2024 15:05
A simple chat app to demonstrate a pub/sub system using Redis and Server-Sent Event(SSE). You can see if you open two browsers, both browsers will get updates when user submits a message.
#!/usr/bin/env ruby
# A simple chat app to demonstrate a pub/sub system using
# Redis and Server-Sent Event(SSE)
require 'sinatra'
require 'sinatra/streaming'
require 'redis'
require 'json'
set :port, 3000
html = <<-EOT
@arashm
arashm / soundcloud.rb
Created April 8, 2014 18:53
Simple script to downoad MP3 files from SoundCloud via WGet
#!/usr/bin/env ruby
require 'uri'
require 'httparty'
# Download mp3 files from SoundCloud
# Usage:
# ./soundcloud.rb https://soundcloud.com/tara-tiba/paeez_tara-tiba
class SoundCloud
include HTTParty
base_uri 'https://soundcloud.com'
@arashm
arashm / radiojavan.rb
Last active April 22, 2022 20:03
Fetch download links of RadioJavan Playlists
#!/usr/bin/env ruby
# gem install mechanize
require 'mechanize'
abort "Usage:\n\tradiojavan.rb \"https://www.radiojavan.com/playlists/playlist/mp3/02596ef9986a\" output_txt" if ARGV.size < 2
playlist_url = ARGV[0]
output_file = ARGV[1]
HOST = 'https://www.radiojavan.com'
@arashm
arashm / geminfo.rb
Created August 5, 2021 10:45
Fetch gems info from rubygems.org and pretty print it to terminal
#!/usr/bin/env ruby
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'rest-client'
gem 'colorize'
end
@arashm
arashm / rbenv_migrate_gems.sh
Created February 3, 2013 09:31
migrate GEMs from rbenv cache to the newer version of ruby (without internet) Thanks to Austin Ziegler - http://stackoverflow.com/questions/13649241/copying-gems-from-previous-version-of-ruby-in-rbenv
#!/bin/sh
# if you're using ZSH, change the shebang above to "#!/bin/zsh -i"
if [ ${#} -ne 2 ]; then
echo >&2 Usage: $(basename ${0}) old-version new-version
exit 1
fi
home_path=$(cd ~; pwd -P)
old_version=${1}
@arashm
arashm / Gemfile
Created June 24, 2020 22:51 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@arashm
arashm / client.rb
Created November 15, 2019 16:38
Simple TCP/IP Server that can listen to multiple clients and send messages to all of them
# frozen_string_literal: true
require 'socket'
class Client
def initialize
@socket = TCPSocket.new('localhost', 2000)
end
def next_line
@arashm
arashm / IranLUGs.md
Last active September 23, 2018 16:51
@arashm
arashm / crt_gen.sh
Last active June 23, 2017 18:28
Make self signed SSL certificate
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out certificate.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key certificate.key -out certificate.csr
echo "Removing passphrase from key (for nginx)..."
cp -v certificate.{key,org}
openssl rsa -in certificate.org -out certificate.key
@arashm
arashm / nginx_enable.fish
Created August 27, 2016 15:26
A simple script to change the current enabled config of nginx
function nginx-enable --argument-names config_name -d "enable the given nginx config"
set nginx_conf_path "/etc/nginx"
set available_directory "servers-available"
set enabled_directory "servers-enabled"
if test ! -n "$config_name"
echo "No config is given."
return
end