This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#read -p "Enter your url: " $address | |
###### | |
# Ping URL and get percent | |
###### | |
address='google.com' | |
log_file='packet.log' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gb | |
{ | |
if [ -d ".git" ] | |
then | |
cc=$(git log --pretty=oneline|wc -l) | |
gb=$(git branch | grep '*' | awk '{print $2}') | |
echo [$gb:$cc] | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
pattern = re.compile('.*<([a-zA-Z0-9\-\+_-]+@[a-zA-Z0-9_]+\.[a-zA-Z]{2,})>.*') | |
## example-1 | |
data = "bla bla bla ..... reza <salam@gmail_test.com> bla bla bla" | |
print pattern.findall(data) | |
## example-2 | |
data = "bla bla bla ..... reza <a-a+1@gmail_test.com> bla bla bla" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
pattern = re.compile('.*<a.*href="(?P<link>[a-zA-Z0-9\+\/\.\?#:_-]+)".*>(?P<title>\w+)</a>.*') | |
data = '<div calss="bla"><a href="http://link1.domain/index.php" class="test">Link1</a></div>' | |
print pattern.findall(data) | |
##output : [('http://link1.domain/index.php', 'Link1')] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo -e 'Id | Queries' | |
echo '-------------' | |
i=0 | |
while [ $i -lt 10 ] | |
do | |
a=$(mysql -uroot -p1234 -e "show status like 'Queries'" | tail -1 | awk '{print $2}') | |
sleep 1 | |
b=$(mysql -uroot -p1234 -e "show status like 'Queries'" | tail -1 | awk '{print $2}') | |
result=$[b-a] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import re | |
pattern = '.*<(iframe|param).*(src|value)="(?P<link>http://www.youtube.com/(embed|v)/[a-zA-Z0-9/\.\?&;=\+_-]+);?.*".*>.*</(iframe|param)>.*' | |
action = re.compile(pattern) | |
result = action.findall('<div><iframe.....></iframe><param......></param></div>') | |
print result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
pattern = '\$*(?P<var>[a-zA-Z0-9_\.]+)\s*=\s*\'?\"?(?P<value>[a-zA-Z0-9_\+\.]*)\'?\"?' | |
#pattern = '\$*(?P<var>\w+)\s*=\s*\'?\"?(?P<value>\w*)\'?\"?' | |
action = re.compile(pattern) | |
data = ''' | |
$firstname = "Morteza" | |
$last_name="ipo" | |
$age=23 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vim /etc/httpd/conf.d/s.conf | |
------------------------------ | |
WSGISocketPrefix /var/run/wsgi | |
<VirtualHost *:80> | |
#WSGISocketPrefix /var/run/wsgi | |
WSGIDaemonProcess myapp user=apache group=apache threads=5 | |
WSGIScriptAlias /myapp /var/www/html/myapp/myapp.wsgi | |
Alias /myapp /var/www/html/myapp | |
AddType text/html .py | |
<Directory /var/www/html/myapp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
session = False | |
def login_required(fn): | |
def ok(input): | |
if(session == True): | |
data = "welcome dear %s" % input | |
else: | |
data = "you are not logged in" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import random | |
class random_ext(): | |
@staticmethod | |
def shuffle_child(var,key,make=None): | |
''' | |
Shuffle child index |
OlderNewer