Skip to content

Instantly share code, notes, and snippets.

@mousavian
mousavian / keybase.md
Last active January 1, 2016 08:42
keybase.md

Keybase proof

I hereby claim:

  • I am mousavian on github.
  • I am mousavian (https://keybase.io/mousavian) on keybase.
  • I have a public key whose fingerprint is 2F46 5BDA 596E 2752 A31A A306 75BB 88CA 99BB 6A68

To claim this, I am signing this object:

@mousavian
mousavian / openstack-cleanup-database
Created June 17, 2015 02:17
A tool to cleanup openstack nova database from all deleted instances
#run this to keep the output:
#$ cleaner.py > cleaner.log
import mysql.connector
uuids = []
class MySQLCursorDict(mysql.connector.cursor.MySQLCursor):
def _row_to_python(self, rowdata, desc=None):
row = super(MySQLCursorDict, self)._row_to_python(rowdata, desc)
if row:
return dict(zip(self.column_names, row))
@mousavian
mousavian / fakes.py
Last active February 3, 2016 10:03
Mock pystalkd Beanstalkd connection for unit testing in Django - Python
class FakeBeanstalkdJob():
body = None
def __init__(self, body=''):
if not isinstance(body, str):
raise Exception('Job body must be a str instance')
self.body = body
def delete(self):
pass
@mousavian
mousavian / .tmux.conf
Last active October 16, 2018 03:59
tmux config for Babun in Windows
# http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# split panes using | and -
bind | split-window -h
bind - split-window -v
@mousavian
mousavian / gugu.sh
Created March 15, 2016 02:28
Simple script to automate session/window & pane creation for tmux
#!/bin/bash
sn=GuGu
# Start the session and window 0 in workplace
# This will also be the default cwd for new windows created
# via a binding unless overridden with default-path.
cd /home/workspace
tmux new-session -s "$sn" -n "FirstWindowName" -d
tmux split-window -v
import Html exposing (text)
islamic_epoch = 1948439.5
gregorian_epoch = 1721425.5
persian_epoch = 1948320.5
type alias Date =
{ year : Int
, month : Int
, day : Int
import Html exposing (text)
import List
type alias Date =
{ year : Int
, month : Int
, day : Int
}
gregorian_days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
@mousavian
mousavian / scanit_bot.sh
Created December 19, 2016 18:41
control scanner using telegram bot
KEY="<telegram-token>"
CHATID="<CHATID>"
COUNTER=1
replay() {
curl -s -d "chat_id=$CHATID&text=$1" "https://api.telegram.org/bot$KEY/sendMessage"
}
while [[ true ]]; do
URL_GET="https://api.telegram.org/bot$KEY/getUpdates?limit=1&update_id=$UPDATEID&offset=$((UPDATEID + 1))"
@mousavian
mousavian / axios-vs-superagent.js
Last active January 23, 2018 06:59 — forked from natesilva/axios-vs-superagent.js
Compare performance of Axios vs. SuperAgent when running under Node.js
const HttpAgent = require('agentkeepalive')
const superagent = require('superagent')
const Benchmark = require('benchmark')
const axios = require('axios')
const http = require('http')
var suite = new Benchmark.Suite()
const targetUrl = 'http://httpbin.org/ip'
const axiosInstance = axios.create({
baseURL: 'http://httpbin.org',
@mousavian
mousavian / akamai.api.sh
Created July 22, 2018 06:57
Akamai Open API Curl command example
#!/bin/bash
readonly CLIENT_SECRET=""
readonly CLIENT_TOKEN=""
readonly ACCESS_TOKEN=""
readonly HOST=""
readonly REQUEST_PATH="/papi/v1/search/find-by-value"
readonly REQUEST_BODY='{"propertyName":"myProperty"}'
readonly REQUEST_TYPE="POST"