Skip to content

Instantly share code, notes, and snippets.

View arashm's full-sized avatar
:shipit:

Arash Mousavi arashm

:shipit:
View GitHub Profile
#!/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}"
#!/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
#!/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`
@arashm
arashm / keybase.md
Created October 25, 2014 10:34
keybase.md

Keybase proof

I hereby claim:

  • I am arashm on github.
  • I am thearashm (https://keybase.io/thearashm) on keybase.
  • I have a public key whose fingerprint is A4E0 F08E DCD6 83C7 2C9A DAEE 4BE1 AC21 B6B6 E8FA

To claim this, I am signing this object:

@arashm
arashm / en2fa.js
Last active December 17, 2015 23:08 — forked from bahar-Agi/en2fa.js
#Javascript
/*
* 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 = '';
@arashm
arashm / IranElection.rb
Last active December 18, 2015 13:10
Script to Report Iran Election Results (2013) Every 1 Minute
# /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 }
@arashm
arashm / pre-commit.sh
Created July 12, 2013 18:17
If you want to make sure that all of your JS code stays compliant to the style defined in your .jshintrc, you can set the following contents to your .git/hooks/pre-commit file, which is then run each time you try to commit any new of modified files to the project http://seravo.fi/2013/javascript-the-winning-style
#!/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 ];
set fisher_home ~/.local/share/fisherman
set fisher_config ~/.config/fisherman
set -gx EDITOR vim
set -gx GEM_EDITOR vim
set -gx LESSOPEN "| /usr/bin/src-hilite-lesspipe.sh %s"
set -gx LESS ' -R '
set -gx TERM xterm-256color
set -gx RUST_SRC_PATH $HOME/workspace/NiceProjects/Rust/rust/src
set -gx LANG en_US.utf8
set -gx LC_ALL en_US.utf8
@arashm
arashm / postgres_queries_and_commands.sql
Created June 26, 2016 15:50 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@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