Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
Tech C**P
http://pyvideo.org/pydata-amsterdam-2017/a-pythonic-tour-of-neo4j-and-the-cypher-query-language.html
PyData Amsterdam 2017

This talk gives an overview of the Neo4j graph database and the Cypher query language from the point of view of a Python user. We'll look at how to run queries and visualise or extract those results into software such as Pandas. We'll also explore the property graph data model and look at how it differs from other data models.

Graph databases offer a fresh perspective on data modelling and one that is often closer to the real world than a traditional RDBMS. In this talk, we'll look at how to work with Neo4j's property graph data model from the point of view of a Python user, how this model differs from other database models and we'll also show how to integrate the Cypher query language into a Python application.

This talk will (hopefully!) contain a couple of live demonstrations. We'll explore how to integrate Cypher query results with data analysis tools such as Pandas as well as how to visualise graph data through the Neo4j browser.


#neo4js #python #pandas #pyvideo
How much do you know about python traceback? Here we will dive deep into this concept.

What is a traceback?
This module provides a standard interface to extract, format and print stack traces of Python programs.

It acts a lot like a python interpreter when it print a stack trace. traceback module has many functions, we will review some of them here.

traceback.print_exc():
Print exception information and up to limit stack trace entries from the traceback tb to file. This is a shorthand for print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file).

traceback.format_exc():
This is like print_exc(limit) but returns a string instead of printing to a file.

A sample traceback usage derived from python documentation:
import sys, traceback

def run_user_code(envdir):
source = raw_input(">>> ")
try:
exec source in envdir
except:
print "Exception in user code:"
print '-'*60
traceback.print_exc(file=sys.stdout)
print '-'*60

envdir = {}
while 1:
run_user_code(envdir)

#python #traceback #exception #format_exc #print_exc
In os x you can use repeat command to repeat a command! If you want to send multiple get request using cURL:
repeat 10 curl https://www.google.com

In Linux we can do the same using for loop:
for i in {1..12}; do echo 'test'; done

#osx #linux #repeat #for
diff command is usually used to get differences between two files:
diff file1.py file2.py

Interesting part of this is that we can even get the differences between to folders, which differ in some files:
diff -bur folder1 folder2

b flag means ignoring whitespace.
u flag means a unified context (3 lines before and after).
r flag means recursive.

#linux #osx #diff
Check if you can connect to APNS SERVER using openssl:
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert /etc/pushd/apns-cert.pem -key /etc/pushd/apns-key.pem

At the end if you can connect to the APNS server you would see Verify return code: 0 (ok). Finally press CTRL+C to go outside of
response.

#pushd #openssl #apns #push
http://www.wispiapp.com/

Wispi is a free cross-platform mobile communications app that allows users to combine voice calls, individual chats as well as group messaging through 3G, 4G or Wi-Fi connection. Our aim is to connect and promote communication between Wispi users FREE where possible and offer users excellent alternatives to the current phone / communication operator.


#wispi #chat #free_call #messaging_app
Some useful string methods, variables:

string.ascii_letters: in case you want to use alpha characters a-zA-Z. The output is:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

string.ascii_lowercase:
abcdefghijklmnopqrstuvwxyz

string.ascii_uppercase:
ABCDEFGHIJKLMNOPQRSTUVWXYZ

string.digits output is numbers:
0123456789

string.punctuation output is special charaters:
!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~

string.whitespace includes all whitespace charaters:
\t\n\x0b\x0c\r

NOTE: space is at the end of the above output, which is not visible.

There are many usecases you can do with this list like generating password, invitation code and etc from a psecific list.

#python #string #ascii_lowercase #ascii_uppercase #digits #punctuation #whitespace
Tech C**P
Some useful string methods, variables: string.ascii_letters: in case you want to use alpha characters a-zA-Z. The output is: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ string.ascii_lowercase: abcdefghijklmnopqrstuvwxyz string.ascii_uppercase:…
Generate a sample string (bonus coupon) from string functions and removing misguiding characters from the final list:
def generate_coupon(coupon_code_length=10):
alphanum = list(string.ascii_uppercase + string.digits)
alphanum.remove('L')
alphanum.remove('I')
alphanum.remove('1')
alphanum.remove('0')
alphanum.remove('O')

return ''.join(random.choice(alphanum) for i in range(coupon_code_length))

This function returns a random string from ascii_uppercase and string.digits. This is one usages out of very many usages of string module public variables. :)

GET THE IDEA!

#python #string #ascii_uppercase #digits #random #random_choice #range
You can use regex when you want to query MongoDB by using RegExp:
db.users.find({username: RegExp('ali.*')})

The above query will find users with username that starts with ali.

#mongo #mongodb #regexp #find
In docker you export an image into a tar file and then import that image without ever needing to download it again from docker hub.

To export an image you need to know the image name in your host (you can get image name by listing all images using docker images):
—------------------------—
docker save python > python.tar

—------------------------—

python is an image name in docker hub that we have downloaded it once from the hub registry. Now after using save command you will have a .tar file in your current path.

If you want to import this images in another server or in case all your images have been removed from your host server or local server, you just need to use load command to load the image into your local docker registry:
—------------------------—
docker load -i python.tar

—------------------------—

You need to be in the path that python.tar file exists.
Now after loading the image you can see that the image is added to your local registry. To check that use docker images

#docker #import #export #save #load #registry #hub #image
Forwarded from كانال خبري چمدان
🔸دیجی کالا و بامیلو دیشب که شبیه نمونه های خارجی تخفیف های بزرگ ارایه می دادند، هر دو از دسترس خارج شدند!
@Derangnews
When you don't have an idea about the load and expecting a 502 BAD Gateway. It means nothing but lack of scaling capablities or maybe lack of knowledge! After years of experience between Digikala crews, this is how they handle load of traffic if we not mention Bamilo!

Having a spare server or two, would difinitely help in balancing load in peak. Not having a good deployment strategy to distribute load to newly added healthy nodes would eventually make such a bad user experience.

Digikala! If I were you, I would place automatic scaling (or 1 single click deployment) to prevent such a results. (besides using load balancers that you guys difintely use).

#digikala #bamilo #502 #bad_gateway #scaling #ux
Remove all unused docker data including volumes, images, network, etc in one command:
docker system prune [OPTIONS]

To remove all unused data:
docker system prune -a

The command will give a warning and then deletes all unused data from docker.
WARNING! This will remove:
- all stopped containers
- all volumes not used by at least one container
- all networks not used by at least one container
- all images without at least one container associated to them
Are you sure you want to continue? [y/N] y

#docker #prune #system #docker_system #dangling