Convert from Python to JSON

If you have a Python object, you can convert it into a JSON string by using the json.dumps() method. Example Convert from Python to JSON: import json # a Python object (dict): x = {   “name”: “John”,   “age”: 30,   “city”: “New York” } # convert into JSON: y = json.dumps(x) # the result is a JSON string: print(y)  

Python Flask how to get parameters from a URL

In Flask, How do I extract parameters from a URL? How can I extract named parameters from a URL using flask and python? When the user accesses this URL running on my flask app, I want the web service to be able to handle the parameters specified after the question mark: Use request.args to get parsed contents…

Ubuntu 16 default python is almost python 3

Loads of solutions exist, but for changing the system default, alias is not the way to go. $ update-alternatives –list python update-alternatives: error: no alternatives for python ls -larth `which python`* -rwxr-xr-x 2 root root 4.3M Nov 17 19:23 /usr/bin/python3.5 -rwxr-xr-x 1 root root 3.4M Nov 19 09:35 /usr/bin/python2.7 lrwxrwxrwx 1 root root 24 Feb 5 09:36…

Create new post WordPress programmatically with custom meta fields

How can you create and insert new posts containing already filled Advanced Custom Fields programmatically into your database? Say you have an ACF group with 3 fields each of a different type description (type Text) image (type Image) categories (type Taxonomy) prepare a basic post $my_post = array( ‘post_title’ => ‘My post’, ‘post_content’ => ‘This is my post.’, ‘post_status’ =>…

How to test sendmail from the terminal

Sendmail is an open source smtp server. Many different languages and frameworks interface with sendmail, and when debugging it’s good to be able to quickly test whether or not sendmail is working. The following is a quick way to verify that sendmail is working. echo “Subject: test” | /usr/lib/sendmail -v [email protected]

WordPress display the_meta() of in custom page

I have some meta values on my wordpress custom page that I need to be displayed in a table. Is there any way I can do that. Here’s the code I’m using now: <?php the_meta(); ?> And this is what it shows: I want to do something like: I found out that: the_meta() is located in…

How to Find the ID Facebook Page

Facebook requires you to input the Page ID when creating social plugins and chat widgets for the Messenger platform but they do not offer any easy way to determine the ID of Facebook pages. This simple guide should help. Find Facebook Page ID Step 1: Open any Facebook Page in your desktop browser and right-click the…

Ansible task executed if file not exists condition

In this post, I will share an ansible task that is executed only if a condition is matched, the condition here is to check if file NOT exists on the system. — – name: run the playbook tasks on the localhost hosts: 127.0.0.1 connection: local become: yes vars: vhost_domain: “wpdemo.com” tasks: – name: ensure aptitude is…

Up and running kubernetes cluster on aws eks in 10 minutes

In this post, I will share the post Up and running kubernetes cluster on aws eks in 10 minutes with cli tool called eksctl. eksctl is cli tool written in GO by weaveworks and based on Amazon’s official CloudFormation templates. Install eksctl In our example, we will use wget, so make sure it is installed before you proceed. curl…

Ansible structure layout – the best approach

This is called Ansible structure layout – the best approach that we used to use it as a template for our projects. This may be not the best but you can customized it as to fit your own. Directory Layout The top level of the directory would contain files and directories like so: production.in #…