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 / SimpleRVAdapter.java
Last active February 9, 2021 10:11
Simple Recycler View adapter (without XML layout)
/**
* SimpleRVAdapter to quickly get started with simple Lists in Recyclerview
*
* Usage:
*
* RecyclerView rv = (RecyclerView)findViewById(R.id.rv);
* rv.setLayoutManager(new LinearLayoutManager(getContext()));
* rv.setAdapter(new SimpleRVAdapter(new String[] {"1", "2", "3", "4", "5", "6", "7"}));
*
* @author Sheharyar Naseer
@sheharyarn
sheharyarn / flatten.rb
Last active April 20, 2017 01:32
Ruby implementation of Array#flatten
class Array
## Returns a new flattened array
def custom_flatten
new_array = []
# Recursively iterate over sub-arrays and other
# elements and concat them to the new array
self.each do |obj|
if obj.is_a?(Array)
// 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 / elixir_sips.exs
Last active December 22, 2021 08:42
Download videos from ElixirSips.com
defmodule Episode do
defstruct id: nil, name: nil, video: nil, markdown: nil, post: nil
def list do
[
%Episode{id: "001", post: "271", name: "Introduction and Installing Elixir", video: "1366", markdown: "1382" },
%Episode{id: "002", post: "275", name: "Basic Elixir", video: "1367", markdown: "1357" },
%Episode{id: "003", post: "280", name: "Pattern Matching", video: "14879", markdown: "1413" },
%Episode{id: "004", post: "284", name: "Functions", video: "5086", markdown: "1559" },
%Episode{id: "005", post: "298", name: "Mix and Modules", video: "5087", markdown: "1654" },
@sheharyarn
sheharyarn / capistrano.nginx.rake
Created June 27, 2015 20:53
Nginx Tasks for Capistrano 3
# Add this file to "rails_app/lib/capistrano/tasks/nginx.rake"
# This will create these tasks:
# - cap stage nginx:start
# - cap stage nginx:stop
# - cap stage nginx:restart
# - cap stage nginx:reload
# Because of "sudo", you'll have to put nginx commands in your visudo file
# See this: https://gist.github.com/sheharyarn/f3d98e8cc859f092532b
@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
@sheharyarn
sheharyarn / nginx.overrides
Created June 27, 2015 20:31
Restart / Reload Nginx without Entering Sudo Password
# Enter this command to create a sudoers override/include file:
# sudo visudo -f /etc/sudoers.d/nginx.overrides
# (Make sure you actually have this in your /etc/sudoers - Run `sudo visudo` to check)
# #includedir /etc/sudoers.d
# This file assumes your deployment user is `deploy`
# Nginx Commands
Cmnd_Alias NGINX_RESTART = /usr/sbin/service nginx restart
@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 / 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 / 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>