Skip to content

Instantly share code, notes, and snippets.

View masnun's full-sized avatar

Abu Ashraf Masnun masnun

View GitHub Profile
defmodule Extorrent.Middleware.HTTPBasicAuth do
def call(env, next, %{username: username, password: password} = opts) do
env
|> add_authorization_header(username, password)
|> Tesla.run(next)
end
defp add_authorization_header(env, username, password) do
auth_hash = Base.encode64(username <> ":" <> password)
@masnun
masnun / top_likers.py
Created March 5, 2016 21:17
Facebook Top Likers
import facebook
from collections import Counter
import requests
likes_counter = Counter()
# Get temp tokens at: https://developers.facebook.com/tools/explorer/
USER_ACCESS_TOKEN = ""
client = facebook.GraphAPI(access_token=USER_ACCESS_TOKEN, version='2.5')
# -*- coding: utf-8 -*-
import scrapy
class MySpider(scrapy.Spider):
name = "myspider"
def start_requests(self):
return [
scrapy.Request('http://masnun.com')
(ns user
(:use [clojure.tools.namespace.repl :only [refresh]]))
(defn rerun
[]
(refresh :after 'my-project.core/-main))
(defproject my-project "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:main my-project.core
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:profiles {:dev {:source-paths ["startup"]}}
:dependencies [[org.clojure/clojure "1.6.0"]
@masnun
masnun / lein.clj
Last active August 29, 2015 14:11
(require '[clojure.tools.namespace.repl :refer [refresh]])
(refresh)
(-main)
from subprocess import Popen, PIPE, call
from sys import argv, exit
from time import sleep
from os import getpid
def get_process_list(app):
ps_aux = Popen(["ps", "aux"], stdout=PIPE)
grep = Popen(["grep", app], stdin=ps_aux.stdout, stdout=PIPE)
awk = Popen(["awk", "{print $2}"], stdin=grep.stdout, stdout=PIPE)
ps_aux.stdout.close()
{% extends 'emails/html/base.html' %}
{% block body %}
<h2 class="null" style="color: rgb(51, 51, 51); font-family: Arial, Verdana, sans-serif; line-height: 20.796875px;"><span style="font-size:14px;"><span style="line-height: 1.6em; color: rgb(32, 32, 32); font-family: Arial;">Hi &lt;First Name&gt;,</span></span></h2>
<p style="color: rgb(51, 51, 51); font-family: Arial, Verdana, sans-serif; font-size: 13px; line-height: 20.796875px;"><br />
<span style="font-size:14px;">Thanks&nbsp;for booking at <a href="http://www.aircourts.com" target="_self">aircourts.com</a>!&nbsp;</span><br />
&nbsp;</p>
#!/bin/bash
# Expand globs to null when there are no matches
shopt -s nullglob
# Look for either a '<subdir>/console' or a 'symfony' file
until
file=(*/console symfony); [[ -f "$file" ]] && php "$file" "$@" && exit;
do
[[ "$PWD" == "/" ]] && break;