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 / RVEmptyObserver.java
Created May 13, 2017 13:55
Set Empty Layout for RecyclerViews in Android
/**
* 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 / bitcoin.conf
Last active March 2, 2018 08:47
Quickly work with BTC Testnet
testnet=1
server=1
# enable SSL for RPC server
#rpcssl=1
rpcallowip=0.0.0.0/0
rpcuser=admin
rpcpassword=123
@sheharyarn
sheharyarn / reddup_video_controls.js
Created March 11, 2018 05:19
Reddup video controls script for GreaseMonkey / Tampermonkey
// ==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 / memoize.ex
Last active September 27, 2020 10:05
Simple Memoization in Elixir (using FastGlobal)
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 / flatten.exs
Created September 3, 2018 22:08
Flatten a List in Elixir (Custom Implementation)
defmodule Flatten do
@doc """
Flattens a List in Elixir
## Examples
```
Flatten.flatten([1,2,3,4])
# => [1,2,3,4]
@sheharyarn
sheharyarn / app-context.js
Last active August 12, 2021 14:43
Custom Wrapper around React Contexts
/**
* Custom Implementation of React Context to manage
* global application state
*
* @author Sheharyar Naseer (@sheharyarn)
* @license MIT
*
* Normal Usage:
*
* ```
@sheharyarn
sheharyarn / simple-elixir-app.dockerfile
Last active April 15, 2020 16:01
Minimal Dockerfile for simple Elixir applications
# Build the release
# -----------------
FROM elixir:1.9.0-alpine as build
ENV MIX_ENV=prod
WORKDIR /source
RUN mix local.hex --force && mix local.rebar --force
# Cache dependencies
@sheharyarn
sheharyarn / .dockerignore
Created April 15, 2020 13:13
Dockerignore for Elixir / Phoenix applications
# Elixir Artifacts
/_build/
/deps/
/doc/
/cover/
/.fetch
*.ez
APPNAME-*.tar
erl_crash.dump
@sheharyarn
sheharyarn / twitter_deleter.ex
Last active April 15, 2020 18:23
Delete all of your tweets before a certain date
defmodule TwitterDeleter do
@tweet_data Path.expand("~/Downloads/twitterdump/assets/tweet.js")
@cutoff Date.from_iso8601!("2015-01-01")
@call_limit 3000
@chunk_no 3
require Logger
def run do
file = File.read!(@tweet_data)
@sheharyarn
sheharyarn / localdev.nginx.conf
Created May 8, 2020 17:45
Multi subdomain local website Nginx config
# Dev Local Conf for multiple subdomain websites
# Here `appdev.com` is pointing to 127.0.0.1
#resolver 127.0.0.11 valid=5s; # for docker
ssl_certificate /usr/local/etc/nginx/ssl/app.server.crt;
ssl_certificate_key /usr/local/etc/nginx/ssl/app.server.key;
upstream app_backend { server localhost:4000; }
upstream app_website { server localhost:5001; }