This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* English digit to persian | |
* Copyright(C) 2009 by Amin Akbari [ http://eAmin.me/ ] | |
* Licensed under the MIT Style License [http://www.opensource.org/licenses/mit-license.php] | |
* | |
*/ | |
String.prototype.toFaDigit = function() { | |
return this.replace(/\d+/g, function(digit) { | |
var ret = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /usr/bin/env ruby | |
# if you have "rufus-scheduler" gem installed you can uncomment corresponding lines in order to | |
# run the script in every certain time. | |
# require 'rufus/scheduler' | |
require 'open-uri' | |
class Election | |
VALUES = %w{Rohani Qalibaf Rezaei Jalili Velayati Qarazi } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Pre-commit Git hook to run JSHint on JavaScript files. | |
# | |
# If you absolutely must commit without testing, | |
# use: git commit --no-verify | |
filenames=($(git diff --cached --name-only HEAD)) | |
which jshint &> /dev/null | |
if [ $? -ne 0 ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'nokogiri' | |
require 'open-uri' | |
doc = Nokogiri::HTML(open('http://wallbase.cc/toplist')) | |
doc.css('div.wrapper a img').each_with_index do |img, i| | |
image_name = img['data-original'].split('-').last | |
link = "http://wallpapers.wallbase.cc/rozne/wallpaper-#{image_name}" | |
puts "Downloadin Wallpaper #{i}: #{image_name}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'cinch' # gem install cinch | |
require 'wolfram-alpha' # gem install wolfram-alpha | |
options = { "format" => "plaintext" } | |
APP_ID = 'XXXXXXXXXXXXXXXX' # get your AppID from http://products.wolframalpha.com/api | |
client = WolframAlpha::Client.new APP_ID, options | |
bot_name = 'WolframBot' | |
bot = Cinch::Bot.new do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'nokogiri' # gem install nokogiri --no-document | |
require 'net/http' | |
require 'json' | |
require 'cgi' | |
# Suppose you want to know how to format a date in bash. Why open your browser and read through | |
# blogs (risking major distraction) when you can simply stay in the console and ask howdoi: | |
# $ ruby howdoi.rb format date bash | |
# > DATE=`date +%Y-%m-%d` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
OlderNewer