| Head-to-Head Records Against Top Rivals: |
mrsuhani/Final-Project/README.md
# Final Project
This repository contains all files related to my final project on creating SEO content.
dankohler/sandbox/jsonl_to_csv.py
#!/usr/bin/env python
# coding=utf-8
import csv
import json
import sys
from datetime import datetime
def read_jsonl(filename):
“””
Reads a JSONL file into memory.
:param filename:
The path of the file.
:return:
A list of dictionaries.
“””
result = []
try:
with open(filename, ‘r’) as f:
for line in f.readlines():
result.append(json.loads(line))
return result
except IOError:
print(‘Error reading %s’ % filename)
sys.exit(1)
def write_csv(filename, data):
“””
Converts JSONL data into CSV format.
:param filename:
The path of the file.
:param data:
A list of dictionaries containing JSONL data.
:return:
None.
“””
try:
with open(filename, ‘wb’) as f:
csv_writer = csv.writer(f)
headers = set()
for row in data:
headers.update(row.keys())
csv_writer.writerow(headers)
for row in data:
csv_writer.writerow([row.get(key) for key in headers])
except IOError:
print(‘Error writing %s’ % filename)
sys.exit(1)
def convert_date(date_string):
try:
date_object = datetime.strptime(date_string[:19], ‘%Y-%m-%dT%H:%M:%S’)
return date_object.strftime(‘%Y-%m-%d’)
except ValueError:
return None
if __name__ == ‘__main__’:
data = read_jsonl(sys.argv[1])
for row in data:
# Convert timestamp from ISO format into yyyy-mm-dd format.
row[‘timestamp’] = convert_date(row[‘timestamp’])
write_csv(sys.argv[2], data)<|file_sep[//]: # (Image references)
[image1]: ./media/tutorial-vm-python/image1.png "Azure portal"
[image2]: ./media/tutorial-vm-python/image2.png "VM configuration"
[image3]: ./media/tutorial-vm-python/image3.png "Open SSH tunnel"
# Deploying an Azure Virtual Machine using Python SDK #
## Introduction ##
In this tutorial you will learn how to use Azure Python SDK version 2017-11-01-preview to deploy an Ubuntu virtual machine within your Azure subscription using Python code.
## Prerequisites ##
* An active Azure subscription ([sign up](https://azure.microsoft.com/en-us/free/) for free).
* An SSH public key pair that you want use for logging into your virtual machine.
## Create an Azure Resource Manager Service Principal ##
You will need an Azure Resource Manager Service Principal which you will use when deploying your virtual machine using Python code.
### Using Azure CLI ###
Run these commands:
az login # Login via CLI or browser prompt window opens up
az ad sp create-for-rbac –role=contributor –scopes="/subscriptions/”
Replace “ with your subscription ID which you can get from https://portal.azure.com/#blade/HubsExtension/BrowseResource/subscriptions/
This command will output something like this:
{
“appId”: “XXXXXXXXXXXXXXXXXXXX”,
“displayName”: “azure-cli-2018-03-23-14-17-29”,
“name”: “http://azure-cli-2018-03-23-14-17-29”,
“password”: “XXXXXXXXXXXXXXXXXXXX”,
“tenant”: “XXXXXXXXXXXXXXXXXXXX”
}
Copy `appId`, `password` and `tenant` values because you will need them later.
### Using Azure Portal ###
If you prefer using portal instead of CLI then follow these steps:
#### Create an Active Directory Application ####
Go to https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview then click **New application registration** button on top left corner.
![Azure portal][image1]
On next page enter name of your application e.g., `PythonSDKVM` then select **Web app / API** type then click **Create** button at bottom right corner.
![Azure portal][image1]
Click **Settings** section on left side panel then select **Properties** item from it.
![Azure portal][image1]
Copy value from **Application ID URI** field because you will need it later.
#### Assign Roles ####
Select **Access Control (IAM)** section from left side panel then select **Add** button on top left corner.
![Azure portal][image1]
On next page select **Role assignment** option then select role type e.g., Contributor from dropdown menu then search your application name e.g., `PythonSDKVM` from textbox field at bottom right corner then click it once found so it gets selected automatically then click **Save** button at bottom right corner.
#### Get Client Secret ####
Select **Settings** section from left side panel then select **Keys** item from it.
![Azure portal][image1]
Enter description e.g., `PythonSDKVMClientSecret` into textbox field at bottom right corner then select expiration period e.g., `One year` from dropdown menu at same location then click **Save** button at bottom right corner so new client secret gets created automatically after few seconds which means there should be new entry under Keys section now having description we just entered earlier along with value inside Secret value field which looks like random string but actually contains our client secret value so copy that value because we’ll need it later too!
## Writing Python Code ##
Now let’s start writing some code! First thing first let’s import required modules/libraries:
python
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.network import NetworkManagementClient
from azure.mgmt.resource import ResourceManagementClient
from msrestazure.azure_exceptions import CloudError
import os.path # For checking whether SSH public key exists locally or not yet!
Next we need to define some constants which will help us throughout our script:
python
SUBSCRIPTION_ID = ” # Your subscription ID goes here!
TENANT_ID = ” # Tenant ID goes here!
CLIENT_ID = ” # App ID goes here!
CLIENT_SECRET = ” # Client secret goes here!
LOCATION = ‘westus’ # Location where resources should get deployed!
RESOURCE_GROUP_NAME = ‘py-sdk-vms’
VNET_NAME = ‘vnet’
SUBNET_NAME =’subnet’
PUBLIC_IP_NAME =’publicip’
NIC_NAME =’nic’
VM_NAME =’vm’
USERNAME=’azureuser’
PASSWORD=’ChangeYourPassword123!’
SSH_PUBLIC_KEY_PATH=os.path.expanduser(‘~/.ssh/id_rsa.pub’) # Path where user wants his/her ssh public key stored locally !
Now let’s create credentials object using above defined constants:
python
credentials=ServicePrincipalCredentials(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
tenant=TENANT_ID)
Next step would be creating resource group object using above created credentials object alongwith other required parameters:
python
resource_client=ResourceManagementClient(credentials, SUBSCRIPTION_ID)
resource_group_params={
‘name’: RESOURCE_GROUP_NAME,
‘location’: LOCATION}
resource_client.resource_groups.create_or_update(resource_group_name=RESOURCE_GROUP_NAME,
params=resource_group_params)
Now we are ready to create virtual network object within our newly created resource group:
python
network_client=NetworkManagementClient(credentials,SUBSCRIPTION_ID)
vnet_params={
‘location’: LOCATION,
‘address_space’:
{
‘address_prefixes’: [‘10.0.0.0/16’]
},
‘default_security_group’:
{
‘reference’: {
‘type’: ‘Microsoft.Network/securityGroups’,
‘resourceGroupName’: RESOURCE_GROUP_NAME,
‘name’: ‘default-nsg’
}
},
‘default_network_security_group’:
{
‘reference’:
{
‘type’:’Microsoft.Network/networkSecurityGroups’,
‘resourceGroupName’:RESOURCE_GROUP_NAME,
‘name’:’default-nsg’
}
},
‘default_route_table’:
{
‘reference’:
{
‘type’:’Microsoft.Network/routeTables’,
‘resourceGroupName’:RESOURCE_GROUP_NAME,
‘name’:’default-route-table’
}
}}
network_client.virtual_networks.create_or_update(resource_group_name=RESOURCE_GROUP_NAME,virtual_network_name=VNET_NAME,params=vnet_params).result()
After creating virtual network object successfully we need subnet object within our newly created virtual network:
python
subnet_params={
‘address_prefix’:’10.0.1.0/24′}
network_client.subnets.create_or_update(resource_group_name=RESOURCE_GROUP_NAME,virtual_network_name=VNET_NAME,name=SUBNET_NAME,params=subnet_params).result()
Next step would be creating public IP address object within our newly created resource group:
python
public_ip_params={
‘dns_settings’:{‘domain_name_label’:”mydnslabel”+str(random.randint(10000,99999))},
‘location’:LOCATION}
network_client.public_ip_addresses.create_or_update(resource_group_name=RESOURCE_GROUP_NAME,prefix=’mypublicip’,params=public_ip_params).result()
Now let’s create network interface card(NIC) object within our newly created resource group alongwith subnet reference obtained previously while creating subnet object above :
python
nic_params={
‘location’:LOCATION,’ip_configurations’:[{‘name’:’myipconfig’,’subnet’:{‘id’:network_client.subnets.get(resource_group_name=RESOURCE_GROUP_NAME,virtual_network_name=vnet.name,name=subnet.name).id},’public_ip_address’:{‘id’:network_client.public_ip_addresses.get(resource_group_name=RESOURCE_GROUP_NAME,prefix=’mypublicip’).id}}]}
nic_result_obj=
network_client.network_interfaces.create_or_update(
resource_group_name=
RESOURCE_GROUP_NAME,network_interface_name=
NIC_NAME,params=
nic_params).result()
nic_result_obj.id.split(‘/’)[-1]
After creating NIC successfully we are ready now create VM configuration object before finally deploying VM instance itself :
python
vm_config={
‘image_reference’:{‘publisher’:’Canonical’,’offer’:’UbuntuServer’,’sku’:’16_04-lts’,’version’:’latest’},
‘vertual_machine_size’:’Standard_DS4_v4′,
‘vertical_disks’:[{‘lun’: DISK_LUN,’create_option’:’FromImage’}],
‘o_s_profile’:{‘computer_name’:VMNAME,’admin_username’:USERNAME,’linux_configuration’:{‘disable_password_authentication’:True,’ssh’:{‘public_keys’:[{‘path”:”/home/”+USERNAME+”/.”+’pub’,”key_data”:open(SSH_PUBLIC_KEY_PATH).read()}}}}},
‘nics’:[{‘id’:”https://management.azure.com”+nic_result_obj.id}],
‘o_s_profile_linux_config_disable_password_authentication’=False}
compute_client.VirtualMachines.create_or_update(
resource_group_name=
RESOURCE_GROUP_NAme,virtual_machine_name=
VIRTUAL_MACHINE_NAme,params=
vm_config).result()
print(“Virtual Machine {virtual_machine} was successfully deployed”.format(virtual_machine=VIRTUAL_MACHINE_NAme))
That’s all folks! You have successfully deployed an Ubuntu VM using Python SDK version 2017–11–01-preview ! Now go ahead connect via SSH tunnel opened earlier manually through putty/puTTYgen toolchain available online free-of-cost !
## Conclusion ##
In this tutorial you learned how easy it is deploying resources such as VMs using Python SDK version 2017–11–01-preview . I hope now onwards whenever anyone asks about deploying resources programmatically via automation scripts written using any programming language ,you would confidently say “Yes I know how do that!” 🙂 . Happy Coding !dankohler/sandbox<|file_sep—
copyright:
years: 2021
lastupdated: "2021"
—
{:shortdesc: .shortdesc}
{:new_window: target="_blank"}
{:codeblock: .codeblock}
{:pre: .pre}
{:screen: .screen}
{:tip: .tip}
{:download: .download}
# {{site.data.keyword.cloud_notm}} 上的 MongoDB Atlas
{: #mongodb-atlas}
{{site.data.keyword.cloud_notm}} 提供 MongoDB Atlas 集成,以便于在 {{site.data.keyword.cloud_notm}} 上创建和管理 MongoDB 数据库。MongoDB 是一种开源的文档数据库,可为您的应用程序提供灵活性、可扩展性和高性能。
要开始使用,请参阅以下教程:
* [在 {{site.data.keyword.cloud_notm}} 上部署 MongoDB Atlas 集群](tutorials/mongodb-atlas-cluster.html)
* [在 IBM Cloud Kubernetes Service 上部署 MongoDB Atlas 集群](tutorials/mongodb-atlas-cluster-kube.html)
* [从 {{site.data.keyword.cos_full_notm}} 配置数据源并将其迁移到 MongoDB Atlas](tutorials/mongodb-atlas-cos-migration.html)
有关详细信息,请参阅下列资源:
* [使用 IBM Cloud CLI 工具配置 {{site.data.keyword.mongodb-atlas_full}}](https://cloud.ibm.com/docs/cli/atlas?topic=atlas-cli){: external}
* [{{site.data.keyword.mongodb-atlas_short}} 文档 ](https://docs.atlas.mongodb.com){: new_window}
* 在 GitHub 上查看示例代码:
* [.Net 示例 ](https://github.com/Azure-Samples/mongodb-atlas-dotnet-core-getting-started/tree/master/src/MongoDbAtlasGettingStarted){: new_window}
* [.Net Core 示例 ](https://github.com/Azure-Samples/mongodb-atlas-dotnet-core-getting-started){: new_window}
* [.Net Core 示例 ](https://github.com/Azure-Samples/mongodb-atlas-nodejs-starter/tree/master/src/nodejs-starter){: new_window}<|file_sepacers-macOS上安装 Docker Desktop:
要在 macOS 上安装 Docker Desktop,请按照以下步骤操作:
打开浏览器并导航到 Docker 官方网站:[Docker Hub 登录页面](https://hub.docker.com/login){target=_blank}。
如果您没有 Docker 账户,请注册一个新账户。
登录后,单击“下载”按钮,然后选择适用于 macOS 的版本。
下载完成后,打开下载的 DMG 文件,并将 Docker 应用程序拖到“应用程序”文件夹中。
启动 Docker 应用程序。第一次启动时可能需要花费几分钟时间来设置容器运行时环境。
完成安装后,您可以通过单击屏幕右上角的 Docker 图标来访问 Docker 控制台。您还可以使用命令行工具(如 Terminal)与 Docker 进行交互。
注意:Docker Desktop 只支持 Intel 架构的 Mac。如果您正在使用基于 ARM 的 Mac(例如 Apple Silicon),请考虑使用其他解决方案,例如通过虚拟化或模拟运行 Intel 容器。dankohler/sandbox<|file_sep provoked by concerns about privacy policies.
This behavior may also lead users who wish not to download further files after downloading one file.
Solution :
To avoid having users download files twice:
Add a meta tag that specifies MIME type information:
<meta http-equiv="Content-Type" content="text/csv">
To avoid having users download files twice:
Add a meta tag that specifies MIME type information:
<meta http-equiv="Content-Type" content="text/csv">
To avoid having users download files twice:
Add a meta tag that specifies MIME type information:
<meta http-equiv="Content-Type" content="text/csv">
To avoid having users download files twice:
Add a meta tag that specifies MIME type information:
<meta http-equiv="Content-Type" content="text/csv">
To avoid having users download files twice:
Add a meta tag that specifies MIME type information:
<meta http-equiv="Content-Type" content="text/csv">
To avoid having users download files twice:
Add a meta tag that specifies MIME type information:
<meta http-equiv="Content-Type" content="text/csv">
To avoid having users download files twice:
Add a meta tag that specifies MIME type information:
<!DOCTYPE html>
<?xml version="1.01" encoding="UTF-8"?>
<!DOCTYPE html>
<?xml version="1.01" encoding="UTF-8"?>
<!DOCTYPE html>
<?xml version="1.01" encoding="UTF-8"?>
<!DOCTYPE html>
<?xml version="1.01" encoding="UTF-8"?>
<!DOCTYPE html>
<?xml version="1.01" encoding="UTF-8"?>
<!DOCTYPE html>
n
<meta name="
title "content= &‑‑‑‑‑‑‑‑‑‑‘
Maven Repository nexus.sonatype.org/ Maven Central/
Nexus Repository Manager OSS v(nexus. org) (Apache Tomcat v(apache. org) (Java/JBoss JSP engine) (Jetty(jetty. org) (Java/JBoss JSP engine) /
Apache HttpComponents HttpClient (Apache HttpComponents Proxies(proxy. apache. org) /
Apache HttpComponents HttpCore (Apache HttpComponents Proxies(proxy. apache. org) /
Apache HttpComponents Parent POM(apache. org) /
Java Apache HttpComponents Parent POM(apache. org) /
JDK(java. oracle. com) /
Java Development Kit(java. oracle. com) /
JSP Engine(javaee. jakartaee. org) /
JSR314 Java Servlet API Specification Version (javaee. jakartaee. org) /
JSR316 Java WebSocket API Specification Version (javaee. jakartaee. org) /
JSR356 Java EE Websocket API Specification Version (javaee. jakartaee. org) /
JSR356 Java EE Websocket API Implementation Version (javaee. jakartaee. org)
title "content= &
description
description
description
description
description
description
description
description
nnnnn
Nexus Repository Manager OSS v( nexus.sonatype.org ) Apache Tomcat v( apache.org ) Apache HttpComponents HttpClient Apache HttpComponents Proxies(proxy.apache.org ) Apache HttpComponents HttpCore Apache HttpComponents Proxies(proxy.apache.org ) Apache HttpComponents Parent POM(apache.org ) Java Apache HttpComponents Parent POM(apache.org ) JDK(java.oracle.com ) Java Development Kit(java.oracle.com ) JSP Engine(javaee.jakartaee.org ) JSR314 Java Servlet API Specification Version javaee.jakartaee.org JSR316 Java WebSocket API Specification Version javaee.jakartaee.org JSR356 Java EE Websocket API Specification Version javaee.jakartaee.org JSR356 Java EE Websocket API Implementation Version javaee.jakartaee.orgnnnnnnnnnnnnnnn
n