Skip to content

Instantly share code, notes, and snippets.

Avatar
🕶️
Working on @slab, @sturama & @gdg-x

Sheharyar Naseer sheharyarn

🕶️
Working on @slab, @sturama & @gdg-x
View GitHub Profile
@sheharyarn
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 & 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 Aug 29, 2015
Rails Server Shortcuts
View README.md

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 Nov 12, 2014
Java: Create Tables in SQLite beautifully
View SQLiteHelper.java
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 Aug 29, 2015
Using AndroidAsyncHttp Library
View APIClient.java
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 Jan 7, 2015
My Verification on Keybase.io
View keybase.md

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 Aug 29, 2015
Eval String using JSFuck
View eval_jsfuck.md

Eval using JSFuck

The magic eval() function in jsfuck:

[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+
[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][
[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[
]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]
@sheharyarn
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) {
e.preventDefault();
@sheharyarn
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
if ENV['CLASS']
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
// https://gist.github.com/sheharyarn/c781dd642d387b947020
// Copyright (c) 2015 Sheharyar Naseer - MIT License
@import "sass-media-queries";
@sheharyarn
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 (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>