Skip to content

Instantly share code, notes, and snippets.

Working on @slab, @sturama & @gdg-x

Sheharyar Naseer sheharyarn

Working on @slab, @sturama & @gdg-x
View GitHub Profile
sheharyarn / ruby_method_search.rb
Last active Aug 29, 2015
Search an Object's Methods in Ruby easily
View ruby_method_search.rb
# Create a method 'search_methods' for the Object Class
class Object
def search_methods(qry)
self.methods & { |m| m.to_s.include? qry.to_s }
# Now search methods for any Ruby Object
Array.search_methods 'enum' # => [:to_enum, :enum_for]
Player.last.search_methods :trust # => [:untrust, :untrusted?, :trust]
sheharyarn /
Last active Aug 29, 2015
Rails Server Shortcuts

Rails Server Shortcuts

Running this script will create three shortcuts (aliases) on your Server:

  • rc - Runs rails console in production
  • cdapp - CDs you into the current release of your app (capistrano)
  • applogs - Starts tailing the production.log of the current release of your app.

This script follows the ~/apps/appname/current directory structure.

sheharyarn /
Created Nov 12, 2014
Java: Create Tables in SQLite beautifully
public class SQLiteHelper extends SQLiteOpenHelper {
private static final String BOOK_TABLE = "books";
private static final HashMap<String, String> BOOK_FIELDS = new HashMap<String, String>() {{
put("title", "TEXT");
put("author", "TEXT");
put("sales", "INTEGER"); // Neatly write fields and their types
// ...
sheharyarn /
Last active Aug 29, 2015
Using AndroidAsyncHttp Library
RequestParams params = new RequestParams();
params.put("email", "a@b.c");
params.put("password", "12345678");"/login", params, new JsonHttpResponseHandler() {
// @Override them all
public void onStart() { } // Runs before anything else
public void onFinish() { } // Runs after everything else
sheharyarn /
Created Jan 7, 2015
My Verification on

Keybase proof

I hereby claim:

  • I am sheharyarn on github.
  • I am sheharyar ( on keybase.
  • I have a public key whose fingerprint is 7D2B 59DB 7F60 9FD7 F4C4 E781 FA1F 9B9B 68FE B6FF

To claim this, I am signing this object:

sheharyarn /
Last active Aug 29, 2015
Eval String using JSFuck

Eval using JSFuck

The magic eval() function in jsfuck:

sheharyarn / arrowNav.js
Created Apr 21, 2015
jQuery use Arrow Keys to go to next/previous (comic) page
View arrowNav.js
(function($) {
function goToComic(position) {
comicLink = $('link[rel="' + position + '"]').attr('href');
if (comicLink)
window.location.href = comicLink;
$(document).keydown(function(e) {
sheharyarn / capistrano.paperclip.rake
Last active Aug 29, 2015
Paperclip Refresh Tasks for Capistrano 3
View capistrano.paperclip.rake
# Put this in your rails_app/lib/capistrano/tasks/paperclip.rake
namespace :paperclip do
namespace :refresh do
desc "Refresh All Paperclip Styles (Must Specify 'CLASS' parameter)"
task :all do
on roles(:app) do
within release_path do
View _breakpoints.scss
// Super Simple wrapper for Sass Media Queries
// Provides only two mixins:
// - small-screens
// - medium-screens
// Copyright (c) 2015 Sheharyar Naseer - MIT License
@import "sass-media-queries";
sheharyarn / mediastorm_caps.rb
Created Mar 15, 2015
Download Subtitles/Captions for MediaStorm Videos
View mediastorm_caps.rb
#!/bin/env ruby
#### This Ruby Script extracts Captions as .srt files from
#### MediaStorm Videos (
#### Download The Video, and if you want to download captions,
#### lookup the 'Network' tab in Inspector to see the video id
#### It'll be a GET request to two xml documents on the mediastorm
#### server, namely; /timecodes/<id> and /phrases/<id>