Skip to content

Instantly share code, notes, and snippets.

View efazati's full-sized avatar
🎯
Focusing

Mohammad Efazati efazati

🎯
Focusing
View GitHub Profile
@efazati
efazati / spotify_mute.sh
Created July 20, 2020 13:42
mute spotify on ads
#!/bin/bash
# Based on https://gist.github.com/pcworld/3198763
# Mute spotify when it starts advertisement
# Run like this
# nohup bash ~/bin/spotify/mute.sh > /tmp/spotify_mute.log &
# Settings
# VAR
ADMUTE=0
@efazati
efazati / clean_AWS_EBS.sh
Created March 1, 2019 15:15
clean unused volume from EBS
export AWS_PROFILE=xxxx;
aws ec2 describe-volumes --filters "Name=status,Values=available" --output json --profile $AWS_PROFILE| python -c "from __future__ import print_function; import json,sys;data=json.load(sys.stdin); [ print(v['VolumeId']) for v in data['Volumes']]" | xargs -n 1 -I % aws ec2 delete-volume --volume-id=% --profile $AWS_PROFILE
@efazati
efazati / remove-gpg-user.sh
Created January 4, 2019 09:51 — forked from glogiotatidis/remove-gpg-user.sh
Git-crypt remove user.
#!/bin/bash
#
# Script to remove GPG key from git-crypt
#
# It will re-initialize git-crypt for the repository and re-add all keys except
# the one requested for removal.
#
# Note: You still need to change all your secrets to fully protect yourself.
# Removing a user will prevent them from reading future changes but they will
# still have a copy of the data up to the point of their removal.
@efazati
efazati / backup.sh
Created July 15, 2017 05:49
backup mongo with dropbox
MONGO_DATABASE="dbname"
APP_NAME="dbname"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
BACKUPS_DIR="/dropbox/backups/$APP_NAME"
BACKUP_NAME="$APP_NAME-$TIMESTAMP"
$MONGODUMP_PATH -d $MONGO_DATABASE
@efazati
efazati / i3
Last active February 22, 2017 06:21
i3
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
#-*- coding: utf-8 -*-
from lxml import html
import requests
from pymongo import MongoClient
from pprint import pprint
import urllib
import telepot
from datetime import datetime
@efazati
efazati / OptionParser.py
Created June 30, 2015 08:22
OptionParser
from optparse import OptionParser
import time
def fn1():
print 'test'
if __name__ == '__main__':
parser = OptionParser()
@efazati
efazati / ThreadedTCPRequestHandler.py
Last active August 29, 2015 14:16
ThreadedTCPRequestHandler.py
class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):
def handle(self):
logger.info({'module': 'server', 'msg': 'Client connected %s' % self.client_address[0]})
cur_thread = threading.current_thread()
data = self.request.recv(1024) # clip input at 1Kb
try:
msg_analyser(data)
response = "{}: {}".format(cur_thread.name, data)
@efazati
efazati / app.ini
Created December 7, 2014 07:40
uwsgi
[uwsgi]
socket = /tmp/app.sock
chdir = /opt/www/app/
processes = 8
master = true
touch-reload = /opt/www/app/reload
plugins = python
module = deploy
callable = application
#virtualenv = /opt/www/app/env
@efazati
efazati / input.py
Created November 24, 2014 11:28
simple get data
from optparse import OptionParser
import time
import sys
def show_lcd(text):
print text
if __name__ == '__main__':
parser = OptionParser()