Skip to content

Instantly share code, notes, and snippets.

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

Sheharyar Naseer sheharyarn

🕶
Working on @slab, @sturama & @gdg-x
Block or report user

Report or block sheharyarn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sheharyarn
sheharyarn / amazon-smile.userscript.js
Created May 8, 2019
Redirect Amazon to Amazon Smile – Tampermonkey Userscript
View amazon-smile.userscript.js
// ==UserScript==
// @name Amazon Smile Redirect
// @namespace https://www.amazon.com/
// @version 0.1
// @description Redirect Amazon to Amazon Smile
// @author Sheharyar Naseer (@sheharyarn)
// @include https://www.amazon.com/*
// @grant none
// ==/UserScript==
@sheharyarn
sheharyarn / app-context.js
Last active Oct 18, 2018
Custom Wrapper around React Contexts
View app-context.js
/**
* Custom Implementation of React Context to manage
* global application state
*
* @author Sheharyar Naseer (@sheharyarn)
* @license MIT
*
* Normal Usage:
*
* ```
@sheharyarn
sheharyarn / flatten.exs
Created Sep 3, 2018
Flatten a List in Elixir (Custom Implementation)
View flatten.exs
defmodule Flatten do
@doc """
Flattens a List in Elixir
## Examples
```
Flatten.flatten([1,2,3,4])
# => [1,2,3,4]
@sheharyarn
sheharyarn / memoize.ex
Last active Jul 19, 2018
Simple Memoization in Elixir (using FastGlobal)
View memoize.ex
defmodule Memoize do
@moduledoc """
Simple memoization helper built on top of FastGlobal.
Remember to add `{:fastglobal, "~> 1.0"}` to your
dependencies first.
## Usage
@sheharyarn
sheharyarn / reddup_video_controls.js
Created Mar 11, 2018
Reddup video controls script for GreaseMonkey / Tampermonkey
View reddup_video_controls.js
// ==UserScript==
// @name Reddup Video Controls
// @version 0.1.0
// @namespace https://www.reddup.co/
// @homepageURL https://sheharyar.me/
// @author Sheharyar Naseer
// @description Show Video Controls for all videos on Reddup
// @include http*://www.reddup.co/*
// @license MIT
// ==/UserScript==
@sheharyarn
sheharyarn / bitcoin.conf
Last active Mar 2, 2018
Quickly work with BTC Testnet
View bitcoin.conf
testnet=1
server=1
# enable SSL for RPC server
#rpcssl=1
rpcallowip=0.0.0.0/0
rpcuser=admin
rpcpassword=123
@sheharyarn
sheharyarn / RVEmptyObserver.java
Created May 13, 2017
Set Empty Layout for RecyclerViews in Android
View RVEmptyObserver.java
/**
* Custom implementation of AdapterDataObserver to show empty layouts
* for RecyclerView when there's no data
*
* Usage:
*
* adapter.registerAdapterDataObserver(new RVEmptyObserver(recyclerView, emptyView));
*/
public class RVEmptyObserver extends RecyclerView.AdapterDataObserver {
private View emptyView;
@sheharyarn
sheharyarn / api_controller.rb
Last active Jun 12, 2018
API Authentication with Devise in Rails
View api_controller.rb
class API::BaseController < ApplicationController
def index
render json: { active: true }
end
def authenticate
if user = User.authenticate(request.headers['X-AUTH-TOKEN'])
sign_in(user, store: false)
@sheharyarn
sheharyarn / serialize_query.js
Created Mar 5, 2017
Serialize an Object into URI Query in Javascript
View serialize_query.js
/**
* This method converts a Javascript object into
* a URI query string. Also handles nested arrays
* and objects (in Rails / PHP syntax)
*
* @author Sheharyar Naseer (@sheharyarn)
* @license MIT
*
* @example
*
@sheharyarn
sheharyarn / create_image_attachment.rb
Last active Oct 21, 2017
Polymorphic Paperclip class with unique partial ActiveRecord index on :default_image
View create_image_attachment.rb
# db/migrations/xxxxxxxxxxxxxx_create_image_attachment.rb
class CreateImageAttachments < ActiveRecord::Migration[5.0]
def change
create_table :image_attachments do |t|
t.belongs_to :imageable, polymorphic: true
t.attachment :data
t.boolean :default, default: false
t.timestamps
end
You can’t perform that action at this time.