Skip to content

Instantly share code, notes, and snippets.

@morteza-mori
morteza-mori / postgresql
Last active September 4, 2018 10:21
psql copy tabale
psql
@morteza-mori
morteza-mori / mongodb
Last active August 25, 2018 15:37
mongo running /data/db problem
mongod --dbpath /data/<path> --port <port no>
http://pdf2md.morethan.io/
@morteza-mori
morteza-mori / python autocompletion
Last active August 21, 2018 18:31
python autocompletion
import rlcompleter, readline
readline.parse_and_bind('tab:complete')
@morteza-mori
morteza-mori / virtualenv
Last active August 19, 2018 02:58
virtualenv - install
apt install python3-pip
pip3 install virtualenv
which virtualenv
cd /home/morteza/Desktop/
mkdir python
cd python/
virtualenv test
You must provide a DEST_DIR
Usage: virtualenv [OPTIONS] DEST_DIR
import ldap, sys
LDAP_SERVER = 'ldaps://grep01.test.test.ir'
LDAP_BASE = 'ou=Special Users,dc=gandou,dc=test,dc=test,dc=ir'
BIND_USER = 'uid=ibsngproxy,ou=Users,dc=test,dc=test,dc=ir'
BIND_PASSWORD = 'halohalohalo'
ldap.set_option(ldap.OPT_DEBUG_LEVEL, 4095)
try:
l = ldap.initialize(LDAP_SERVER)
@morteza-mori
morteza-mori / install-docker-deb8.sh
Created May 23, 2018 06:17 — forked from tsaqib/install-docker-deb8.sh
Docker installer script for Debian 8 Jessie
# Docker installation script for Debian 8 Jessie on Azure
# Usage: execute sudo -i, first.
# wget -q -O - "$@" https://gist.githubusercontent.com/tsaqib/b2c83ac30f962ab78a5472902c325aa9/raw/ --no-cache | sh
# After running the script reboot and check whether docker is running.
apt-get purge lxc-docker*
apt-get purge docker.io*
apt-get update -y && sudo apt-get upgrade -y
apt-get install -y apt-transport-https ca-certificates
@morteza-mori
morteza-mori / manual.md
Created May 22, 2018 10:54 — forked from mortymacs/manual.md
Set Proxy On Docker Service in Linux
  • First install tor and privoxy and config them.
  • Create a file in this directory with below config: touch /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=127.0.0.1:8118"
@morteza-mori
morteza-mori / ad_test.py
Created May 22, 2018 10:43 — forked from mortymacs/ad_test.py
Retrieve user information from AD via Python LDAP
import sys, ldap
# DN = username@example.com, secret = password, un = username
DN, secret, un = sys.argv[1:4]
server = "ldap://server.com"
port = 389
base = "dc=example,dc=com"
scope = ldap.SCOPE_SUBTREE
@morteza-mori
morteza-mori / aaa
Created May 7, 2018 03:56
show bw in mongo db problem
git diff core/snapshot/plugins/user_bw.py
diff --git a/core/snapshot/plugins/user_bw.py b/core/snapshot/plugins/user_bw.py
index fedd628..6ce7f9d 100755
--- a/core/snapshot/plugins/user_bw.py
+++ b/core/snapshot/plugins/user_bw.py
@@ -42,8 +42,8 @@ class UserBWPlugin(ClientInterface):
# sometimes user goes offline and we
# are getting None value for user_obj
- if user_obj is None:
from core.errors import *
from core.ibs_exceptions import *
toLog("HEEEEEEEEEEEEEEEEEEEEEEEEEE", LOG_DEBUG)
error, auth_response = user_worker_main.getMPIHUB().\
evaluateOnMain(True,
"ldap_main.getManager().authenticate",
[ldap_dn, clear_text_password, True]
)
toLog(">>>>> {} {}".format(ldap_dn, error, auth_response), LOG_DEBUG)