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 / simple-elixir-server.exs
Created June 3, 2022 22:39
Simple Elixir Server as a Script
Mix.install([{:plug_cowboy, "~> 2.0"}])
defmodule Server do
use Plug.Router
plug(:match)
plug(:dispatch)
match _ do
send_resp(conn, 200, "Hello World!")
end
@sheharyarn
sheharyarn / gmail-recruiter-reply.appscript.js.gs
Last active July 23, 2020 12:04
Google Appscript to auto-reply to recruiters
function respondToEmails() {
//var filter = 'from:(some.email@address.com) AND -label:"Auto-Replied"';
var filter = 'label:"Job Proposals" AND -label:"Auto-Replied"';
var completeLabel = GmailApp.getUserLabelByName("Auto-Replied");
var threads = GmailApp.search(filter);
var replyFrom = "Recruiter Bot <your.email+recruiterbot@gmail.com>";
val realEmail = "your.real@email.com"
var formLink = "https://link.to/your/form"
var response = (
@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; }
@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 / .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 / 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 / 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 / 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 / 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 / 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==