Skip to content

Instantly share code, notes, and snippets.

View techmaniack's full-sized avatar

Karim Memon techmaniack

View GitHub Profile
@techmaniack
techmaniack / fifRC.rb
Created February 10, 2012 12:17
fifRC (fetch it from RailsCast)
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
source = "http://feeds.feedburner.com/railscasts"
content =""
open(source) do |s| content = s.read end
@techmaniack
techmaniack / rails_installation_ubuntu
Created March 31, 2012 12:11
Setting up RAILS on Ubuntu
STEP 1:
$ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev \
curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev \
sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison \
subversion mustang
STEP 2:
$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
@techmaniack
techmaniack / bash_top_ten_commands.sh
Last active October 7, 2015 15:08
One liner to show the top ten commands used on the system
This one-liner will read the ~/.bash_history file and give the top ten most frequently used commands
$ cat ~/.zsh_history \
| cut -f2 -d ";"\
| cut -f1 -d " "\
| awk '{c [$1]++}END{for(j in c)print j,""c[j]""}'\
| sort -hr -k2\
| head \
| column -t
@techmaniack
techmaniack / isbn_decoder.rb
Created July 29, 2012 16:09
ISBN decoder
#!/usr/bin/env ruby
#-------------------------------------------------------------------------------
# Name: isbn_decoder.rb
# Purpose: Fetch title from ISBN .
#
# Author: AbdulKarim Memon
#
# Created: 29/07/2012
# Copyright: (c) AbdulKarim Memon 2012
@techmaniack
techmaniack / find-s.rb
Created August 6, 2012 00:09
An implementation of 'Find-S' Algorithm in Ruby
#!/usr/bin/env ruby
# find-s.rb
#
# Copyright 2012 AbdulKarim Memon <abdulkarim@reversehack.in>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@techmaniack
techmaniack / smart_push.rb
Created August 12, 2012 23:19
Smart `adb push`
#!/usr/bin/env ruby
# Ever tried to use wildcard (*) while pushing multiple files to your droid via adb?
# This small little script helps you do it. Of Course there are many ways to do it
# but one is for the ruby-istas :)
# SAMPLE USAGE: ruby smart_push.rb *.pdf books # push all pdf's to /mnt/sdcard/books
ARGV.length > 1 ? (dest = "/mnt/sdcard/#{ARGV[-1]}"; ARGV.pop) : dest = "/mnt/sdcard/"
ARGV.each do |item|
puts File.basename("#{item}") + " is being pushed"
@techmaniack
techmaniack / fbtweet.rb
Created September 23, 2012 17:31
Selective tweets post
pushed_tweets=[]
while true
Twitter.user_timeline("techmaniack").each do |item|
if !pushed_tweets.include?item.id
me.feed!(:message => item.text) if item.text.include?"#fb"
puts "POSTING TWEET"
puts item.text
pushed_tweets << item.id
else
puts "NOT POSTING"
@techmaniack
techmaniack / prag_mag_grabber.rb
Created November 24, 2012 07:34
a small ruby script to grab The Pragmatic Programmers Free Magazines (http://pragprog.com/magazines)
#! /usr/bin/env ruby
require 'open-uri'
#wget could have been used but then it would
# 1) Make it dependent on an external program
# 2) Make it a one-liner ;)
#
#This script when executed will start downloading all the prag-mags
#in the current directory.
if ARGV.count == 0
@techmaniack
techmaniack / origami_grabber.rb
Last active June 1, 2017 11:45
Grab all tutorials files from dev.origami.org
#! /usr/bin/env ruby
require 'mechanize'
agent = Mechanize.new
url = "http://dev.origami.org/diagram.cfm?CurrentPage="
base = "http://dev.origami.org/"
21.times do |count|
puts url+"#{count}"
page = agent.get(url+"#{count+1}")
page.links.each do |l|
@techmaniack
techmaniack / aliases.sh
Created May 3, 2013 11:36
shell_aliases
#Capture screenshot via adb on Samsung Galaxy Devices. (Tested on Galaxy mini 2.3.4 NO ROOT)
#Stores the screenshot on the device (/mnt/sdcard/Screencapture)
alias droidshot='adb shell am startservice -a com.sec.android.app.screencapture -n com.sec.android.app.screencapture/.ScreenCaptureService'