Skip to content

Instantly share code, notes, and snippets.

View sheharyarn's full-sized avatar
🕶️
Working

Sheharyar Naseer sheharyarn

🕶️
Working
View GitHub Profile
@sheharyarn
sheharyarn / ruby_method_search.rb
Last active August 29, 2015 13:59
Search an Object's Methods in Ruby easily
# Create a method 'search_methods' for the Object Class
class Object
def search_methods(qry)
self.methods & self.methods.select { |m| m.to_s.include? qry.to_s }
end
end
# Now search methods for any Ruby Object
Array.search_methods 'enum' # => [:to_enum, :enum_for]
Player.last.search_methods :trust # => [:untrust, :untrusted?, :trust]
@sheharyarn
sheharyarn / README.md
Last active August 29, 2015 14:05
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
sheharyarn / SQLiteHelper.java
Created November 12, 2014 22:25
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
sheharyarn / APIClient.java
Last active August 29, 2015 14:10
Using AndroidAsyncHttp Library
RequestParams params = new RequestParams();
params.put("email", "a@b.c");
params.put("password", "12345678");
APIClient.post("/login", params, new JsonHttpResponseHandler() {
// @Override them all
public void onStart() { } // Runs before anything else
public void onFinish() { } // Runs after everything else
@sheharyarn
sheharyarn / keybase.md
Created January 7, 2015 22:52
My Verification on Keybase.io

Keybase proof

I hereby claim:

  • I am sheharyarn on github.
  • I am sheharyar (https://keybase.io/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
sheharyarn / eval_jsfuck.md
Last active August 29, 2015 14:19
Eval String using JSFuck

Eval using JSFuck

The magic eval() function in jsfuck:

[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+
[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][
[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[
]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]
@sheharyarn
sheharyarn / arrowNav.js
Created April 21, 2015 18:05
jQuery use Arrow Keys to go to next/previous (comic) page
(function($) {
function goToComic(position) {
comicLink = $('link[rel="' + position + '"]').attr('href');
if (comicLink)
window.location.href = comicLink;
}
$(document).keydown(function(e) {
e.preventDefault();
@sheharyarn
sheharyarn / capistrano.paperclip.rake
Last active August 29, 2015 14:23
Paperclip Refresh Tasks for Capistrano 3
# 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
if ENV['CLASS']
on roles(:app) do
within release_path do
// Super Simple wrapper for Sass Media Queries
// Provides only two mixins:
// - small-screens
// - medium-screens
// https://gist.github.com/sheharyarn/c781dd642d387b947020
// Copyright (c) 2015 Sheharyar Naseer - MIT License
@import "sass-media-queries";
@sheharyarn
sheharyarn / mediastorm_caps.rb
Created March 15, 2015 11:05
Download Subtitles/Captions for MediaStorm Videos
#!/bin/env ruby
#### This Ruby Script extracts Captions as .srt files from
#### MediaStorm Videos (http://mediastorm.com)
#### 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>