teleren/devto huggingface dataset:
MySQL Bulk Insert taking long time
Tags: python, database, sql, aws
Published: 2020-06-09 13:51:39

I'm using python, using MySQL connector. I'm having nearly 67 Million (14GB) entries in a table. When I do a bulk insert of 2K data each time, it is taking very long to insert.

Inserted 2000 rows in 23 Seconds
Inserted 2000 rows in 25 Seconds
Inserted 2000 rows in 29 Seconds
Inserted 2000 rows in 28 Seconds
For another table (having less data), insertion speed is fine(2-4 seconds).

After using the transaction:

Inserted 2000 rows in 21 Seconds
Inserted 2000 rows in 20 Seconds
Inserted 2000 rows in 20 Seconds
Inserted 2000 rows in 18 Seconds
How can I improve the speed?

I'm using AWS RDS, Aurora MySQL version 5.7.12 (db.t3.medium) having CPU usage 4% to 8%. My objective is to insert around 50K data into a table. This table is currently having nearly 67 Million (14GB) data already. Data must need to be inserted ASAP. This almost real-time data is very important for the client. The table is having 18 columns: id(PK auto-increment), customer, serial_number, batch, data, and some others. Indexes are on (customer,serial_number) - To make the combination unique, batch - For searching, data(unique). All are by default BTREE indexed. This insertion should need to take less than 1 minute for 50K. But currently taking around 15 minutes. I've tried inserting on an empty table. It is inserting 50K data just in 5-7 seconds. As you increase the number of entries in the table, the insertion process time is increasing.

Is upgrading MySQL version is going to speed-up the insertion process anyhow? Is it the last option to split or partitioning the table? I cannot consolidate the data because each data is important, specially the last 2 years of data. Please help.

My table schema is already having some default values in 8 columns and these data are never going to update later. There are not many Read/Write operations are going on. Almost 2 or in some cases 3 selects per second as per RDS monitor shows.
How to write in an existing file in Python?
Tags: python
Published: 2020-06-09 11:10:03

You are going to learn **how to write text in an existing file in python**?  

Python can work with files, it can <a href="https://pythonbasics.org/read-file/">read files</a>, <a href="https://python-commandments.org/python-write-file/">write file</a> and even <a href="https://pythonprogramminglanguage.com/read-csv/">read csv files</a>. In brief, any data can be read by Python.

You can use the `open(filename,mode)` function to open a file. There are a set of file opening modes.

**To write in an existing file**  you have to open the file in **append mode("a")** , if the file does not exist, the file will be created.

To **write text in an existing file** , first step is to verify if the file exists or not? 

If the file you want to write to does not exist, program will create a new file.

## append to file

In this Python example, it creates a file, write a <a href="https://pythonspot.com/python-strings/">string</a> and then closes the file. After that, you will open the file in append mode **"a"** .
       
```python
    # write lines to an existing file
    # after creating it    
    fo = open("example1.txt", "w")
    fo.write("Hello world.")
    fo.close()
```

Now that you have a file, you can append to it

```python   
    # open the file in append mode
    fo = open("example1.txt","a")
    fo.write("I like Python")
    fo.close()
```

If you want you can read and display it

```python    
    # read and display the file 
    fo = open("example1.txt","r")
    print("The file contains: ")
    dummy = fo.read()
    print(dummy)   
    fo.close()
```    

The program above outputs this:    
    
    The file contains: 
    Hello world.I like Python 
    
This works in both the <a href="https://bsdnerds.org/learn-python/">Python shell</a> and running from a file.
Install LEMP Stack (Linux, Nginx, MySQL, PHP) on Ubuntu 18.04 AWS EC2 Instance
Tags: ubuntu, sql, php, aws
Published: 2020-06-09 13:45:35

1. Create AWS account
2. Launch new AWS ec2 instance of Ubuntu 18.04
3. Connect to instance via SSH
4. Install Nginx / Engine X
5. Install MySQL
6. Install PHP
7. Configure Nginx to use PHP processor

Full article on my blog: https://bit.ly/BDVLEMP

Thank you :)
What does the 'b' character do in front of a string literal in Python?
Tags: python
Published: 2020-06-09 13:39:37

Python sometimes has the 'b' character in front of a string. You are going to learn how to make a variable type as byte.

You will also learn **what the 'b' character does in Python**

## Example

Consider the following examples,    
    
```python
    # variable definitions
    t_str = 'string'
    t_bytes = b'string'
    
    # print the types
    print(type(t_str))
    print(type(t_bytes))
```    

You can try this both in the <a href="https://bsdnerds.org/learn-python/">shell</a> and from a <a href="https://pythonprogramminglanguage.com/how-to-run/">script</a>

The program above outputs this:    
    
    <class 'str'>
    <class 'bytes'>

This means they are of a different type.

![data types](https://dev-to-uploads.s3.amazonaws.com/i/ie0mxypdc2e6h4nuc1de.png)

## String vs bytes

As per the above example, the prefix of 'b' character to a <a href="https://pythonbasics.org/strings/">string</a>, makes the variable of <a href="https://python-commandments.org/python-data-types/">data type</a> bytes.

In the prefix 'b' before version 3, python ignored the variable bytes with 'b' in the later version. It can contain ASCII characters and it should be expressed bytes with an escape value of 128 or higher. 

The bytes are the actual data. Strings are an abstraction. A byte is a collection of 8 bits, also known as <a href="https://pythonspot.com/binary-numbers-and-logical-operators/">binary</a>

Read more:
* <a href="https://docs.python.org/3.8/library/stdtypes.html#bytes">bytes in Python docs</a>
* <a href="https://docs.python.org/3.8/library/string.html">String in Python docs</a>
Daily Challenge #255 - Is There an Odd Bit?
Tags: challenge
Published: 2020-06-09 13:31:52

---
title: Daily Challenge #255 - Is There an Odd Bit?
published: true
series: Daily Challenge
description: [add a brief description of task]
tags: challenge 
//cover_image: https://direct_url_to_image.jpg
---
Convert a given integer to binary. Return 1 when ANY odd bit of x equals 1; 0 otherwise.

**Examples**
any_odd(2) will return 1 because at least one odd bit is 1 (0010).
any_odd(170) will return 1 because all of the odd bits are 1 (10101010).

**Tests**
any_odd(5)
any_odd(7)
any_odd(10)

Good luck!

***
_This [challenge](https://www.codewars.com/kata/5d6f49d85e45290016bf4718) comes from mtruong1999 on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
string isupper() and islower() methods with examples
Tags: python
Published: 2020-06-09 13:14:56

<a href="https://python.org">Python</a> string isupper() and islower() methods with Examples.

Python isupper() and islower() are in-built methods in Python, that are used to check if a <a href="https://pythonbasics.org/strings/">string</a> is in uppercase or lowercase.  Internally it uses an <a href="https://python-commandments.org/python-if-else-elif-statement/">if statement</a> that checks the characters.

## String isupper() method

isupper() returns "true" if all characters of the string are uppercase characters.

**Syntax:**    
    
     String.isupper()

**Parameter:** 
None

**Return type:**  
* **true** - if all characters of the string are uppercase characters.
* **false**  - if any of the characters is not in uppercase character.

This works both in the Python <a href="https://bsdnerds.org/learn-python/">shell</a> and from a <a href="https://pythonprogramminglanguage.com/how-to-run/">script</a>

**Python Example:**    
The example below shows how to use the isupper() method. The method is applied to the string directly.

<img src="https://thumbs.gfycat.com/ExaltedFemaleAnemone-max-1mb.gif" alt="string">

So the methods isupper() and islower() both work with <a href="https://pythonspot.com/python-strings/">strings</a>.

    
```python
# s1 with all uppercase characters
s1 = "DEVTO"
print(s1.isupper())

# s2 with uppercase character, DOT, SPACE 
s2 = "DEV.TO"
print(s2.isupper())

# s3 with uppercase and lowercase characters
s3 ="DEV.to"
print(s3.isupper())

# s4 with all lowercase characters
s4 = "dev.to"
print(s4.isupper())
```
    

The program above outputs this:    
    
        True
        True
        False
        False
    

  

## 2) String islower() method

The method islower() returns "true" if all characters of the string are lowercase characters.

**Syntax:**    
    
     String.islower()

**Parameter:** 
None

**Return type:**  
* **true** - if all characters of the string are lowercase characters.
* **false** - if any of the characters is not in lowercase character.

**Python Example:**    
    
```python
# s1 with all uppercase characters
s1 = "DEVTO"
print(s1.islower())

# s2 with uppercase character, DOT, SPACE 
s2 = "DEV.TO"
print(s2.islower())

# s3 with uppercase and lowercase characters
s3 ="DEV.to"
print(s3.islower())

# s4 with all lowercase characters
s4 = "dev.to"
print(s4.islower())
```    

The program above outputs this:    
    
    False
    False
    False
    True
    
**Read more:**
* <a href="https://gumroad.com/l/dcsp">Python Crash Course for Beginners</a>
* <a href="https://docs.python.org/3/library/string.html">Python doc on strings</a>
Lessons I Learned from Developing an IoT Project from Scratch
Tags: iot
Published: 2020-06-09 13:13:11

I am working on an Internet Of Things (IoT) project. I work with medical IoT devices in my project.

These are the lessons I learned from this project:

**Networking**: You must know how the network works. You must have a good knowledge of network protocols such as TCP and UDP. If you will work with IoT devices that have multiple network interfaces, you must know about CIDR. Some IoT devices use different technologies such as Bluetooth and Serial port (COM) for data transmitting. Also, there are IoT specific network technologies such as LPWAN.

**Data Structures**: IoT devices use different data structures. They tend to compress data and send/receive small data because of limited resources. Some old devices which are converted to IoT use weird ways to process data. So you must be aware of endianness, signed and unsigned numbers and encodings. IoT devices can produce large data. Design your system to save and process big data. 

**Parallel Processing**: Asynchronous programming has advantages and disadvantages. Every situation is different and there is no real grab-bag solution. It is not a silver bullet. You must know the differences between process and thread, debugging and tracking asynchronous functions.

**Building Embedded Softwares**: It is now easier than before. You can easily build a specific solution with Arduino, Raspberry Pi and many other platforms. I couldn't find an IoT device that fits my need. So I decided to develop one. There is huge information about Arduino. I implemented an IoT solution with Arduino in 3 days.

**Encrption**: It is not only needed for confidentiality. It is also used for user authentication and checking the integrity of data messages. A basic understanding of encryption is enough. There are too many tools and libraries for it.

**Building a Mock Device**: I was working on a medical IoT device (defibrillator). Preparing this device and configuring the setup takes one hour at some times. So I built a mock device which is completely a software that simulates this device. I used this mock device for too many reasons: traffic monitoring, security and integrity check but mostly for demo purposes in meetings. We had only one device but more than one developer could be able to work on the mock device simultaneously. 

**Use the same device as much as possible**: Edit a configuration and boom! Nothing works! Documents about IoT devices are not up-to-date. Don't make assumptions when changing a configuration or when an IoT device will work as expected. Test it!

You will deal with a lot of cables, triple plugs, batteries, screwdrivers, wi-fi devices, SD cards, USB flash drives. 

Working with IoT devices is fun when everything works as expected :)

Original Post: https://www.saascommando.com/2020/06/lessons-i-learned-from-developing-iot.html
🌱 shape-outside - basil plant.
Tags: codepen, css
Published: 2020-06-09 13:12:27

Recently [I asked for your feedback](https://dev.to/adam_cyclones/wanted-feedback-on-design-204m) on a design, now I have kind of made it close to prod ready, still need to do some optimisations, but it looks cool!

⚠️ Broken AF on Firefox, this is due to the hacky way I moved the svg into position, I will not be using svg in the final nor moving it around with transforms.

### What is css?
- drop shadow, `filter: drop-shadow();`
- text wrap around, `clip-path` and `shape-outside`
- Graphic is svg but Im going to swap to webp and png.

PS. I grew this plant for the photo and the code, then I ate it.

What can **you** make with top down views?

{% codepen https://codepen.io/acronamy/pen/MWKavQv %}
The Swift Programming Language Companion: Properties Part 1
Tags: ios, swift, beginners
Published: 2020-06-09 12:58:35

This article is part of a series on learning Swift by writing code to The Swift Programming Language book from Apple. This is the fourth article in Section 2 (here is [Section 1](https://app-o-mat.com/post/swift-programming-language-companion-section-1))

Read each article after you have read the corresponding chapter in the book. This article is a companion to [Properties](https://docs.swift.org/swift-book/LanguageGuide/Properties.html).

### Set up a reading environment

If you are jumping around these articles, make sure you read the [Introduction](https://dev.to/loufranco/the-swift-programming-language-companion-introduction-4k0a) to see my recommendation for setting up a reading environment.

To add a new page, in Xcode:

1. Choose File > New > Playground Page
1. Rename the page to "10-Properties"

### Exercises for Properties

At this point, you should have read [Properties](https://docs.swift.org/swift-book/LanguageGuide/Properties.html) in The Swift Programming Language. You should have a Playground page for this chapter with code in it that you generated while reading the book.

#### Exercises

The chapter covers how to declare Properties inside of Structures and Classes. For Part 1, we're going to stick to the more common parts, stored properties, computed properties, and Type properties.

For these exercises, we are going to imagine a simple media playing app.

In your Playground write code to do the following:

1. (from enumerations): Declare an enumeration called `Genre` and add cases for `jazz`, `rock`, `rap`, `country`, and `folk`.
2. Declare an `Artist` struct with stored properties `name` and `birthDate`
3. Declare a `Song` struct with stored properties `title`, `artist`, and `genre`
4. Add a computed property to `Artist` called `age` which uses `birthDate` and today’s date.
5. Declare a few `Artist` and `Song` instances
6. Make a class called `Library` and add a Type property called `songs` that is an array of `Song` structs. Initialize it with a few values.

#### Hints

To find today’s date: `let today = Date()`
To find the number of seconds between two dates:
`let seconds = today.timeIntervalSince(birthDate) `

#### Next

The next article will look at the more advanced usage of properties.
Find the expert White label wordpress website builder
Published: 2020-06-09 12:57:52

Building online presence is something that every modern business needs to succeed in present era. And wordpress is one of the easiest ways of getting your presence on the web. This is one of the most popular platforms today to design professional websites in less time and budget. For all kind and size of businesses, Wordpress website is best option as you can get any type of website in wordpress. 

If you need wordpress ecommerce website then it is also possible to get it designed easily. And for wordpress development, WP Creative is the leading company you can contact. It provides highly professional and result-driven web solutions which must help you grow your business and brand globally.

With the help of professional website designers and developers, you can create most amazing website. Online success needs beautifully designed, full-functional website that attract customers and generate leads. If you want your website to meet latest standards then remember WP Creative is the only option for you. It has white label wordpress website builder who understand how to ensure your online success with custom website. Your custom website will be able to achieve your core business goals easily.

The most effective benefit of wordpress website is that if you need minor changes in your website like want to add images or posts then you can do it yourself. A Wordpress website can have unique look and style which cannot be designed on other platforms. Moreover, there are millions of themes available for wordpress websites and you can choose as per your requirement. With amazing themes, you can give your online business a very professional and customized look. So, if you are really concerned for your online presence and need unique website to grow then make sure you prefer WP Creative. For more details visit at: https://www.wpcreative.com.au/wordpress-development-services/ecommerce/
A Simple server with Deno
Tags: 100daysofcode, javascript, deno, learning
Published: 2020-06-09 12:51:30

---
title: A Simple server with Deno 
published: true
description: A website that gets spaceX API and randomly shows an image
tags: #100daysofCode,#javascript,#Deno,#learning 
cover_image: https://miro.medium.com/max/2560/1*GLUQlHX7Ys19WAMh62Htzw.jpeg
---

I wanted to experiment with Deno and build a quick site. Here it is. 

A Server that makes an API call to SpaceX and gets the image list. Whenever user makes a request it returns a random image. Started this to learn more about Deno 

From my understanding it's still in the very early stages. But could be really healful for scripting with the permissions feature.We will see  

You can find my Repo Link here
https://github.com/ganeshraja10/Latest-Tech-Learnings

```javascript
import { serve } from "https://deno.land/std@0.55.0/http/server.ts";

const SPACE_X_URL = "https://api.spacexdata.com/v3/launches/latest";

const res = await fetch(SPACE_X_URL);
const response_json = await res.json();

const images_list = response_json["links"]["flickr_images"];

const server = serve({ port: 8000 });

console.log("http://localhost:8000/");
for await (const req of server) {
  let img_url = images_list || images_list[Math.floor(Math.random() * images_list.length)];
  let response = `<h1>Hey, Here is one random Space X Image </h1> <img style='height:500;width:500' src="${img_url}"/>`;
  req.respond({ body: response });
}

```
How to Find Funding for Your Project
Tags: funding, grants, crowdfunding
Published: 2020-06-09 12:28:44

It is quantic time that we investigate options for financing your projects. It doesn't matter if you are looking to fund a new business idea or just a side project, there are options at all levels. For instance, there are microgrants up to $5000 for small side projects. For bigger business ideas, you have recurring grants, government funds, and crowdsourcing options. You can even go with advertising on your projects, sponsorships, and selling relevant merchandise. The final step is to look for venture capital, of course.

I have just published an aggregate article from all other sources, and you can find it here: https://quanticdev.com/articles/how-to-fund-your-project
Analysis of all the resources listed on the article can be found as a video: https://www.youtube.com/watch?v=uOX3IU_OSig

Funding options that we will investigate:
* Crowdfunding
  * Kickstarter & Indiegogo
  * Patreon
  * Crowdfunder
* Grants
  * Facebook SM Grants
  * AwesomeFoundation
  * Gitcoin
  * Python Software Foundation Grants
  * Tyk’s Side Project Fund
  * Unitary Fund
*  Open-Source Focused Grants
  * InternetFonden of Sweden
* Lemonade Stand Guide (list of funding types)
  * Donation Button
  * Bounties
  * Sponsorware
  * Books & Merchandise & Advertising & Sponsorship
  * Get Hired to Work On a Project
  * Start a Project For Your Company
  * Consulting & Paid Support
  * Software as a Service
  * Open Core & Paid License
  * Venture Capital
Vim / Neovim on CentOS 8
Tags: vim, neovim, centos, texteditor
Published: 2020-06-09 12:03:15

This post shows how to install [Vim](https://www.vim.org/) / [Neovim](https://neovim.io/) on [CentOS](https://www.centos.org/) 8.

### Vim

First, Vim is easy to get:

```console
# dnf install vim
```

That's really it. Now `vim` command is available.

### Neovim

Next, on Neovim, thanks to [AppImage](https://appimage.org), configuration of [EPEL](https://fedoraproject.org/wiki/EPEL) repository is not necessary any more, which has been in CentOS 7.

```console
# # prepare
# dnf install curl
# # for the sake of running appimage:
# dnf install fuse-libs

# # get appimage binary
# curl -o /usr/local/bin/nvim -LO https://github.com/neovim/neovim/releases/download/stable/nvim.appimage
# # to get the nightly version instead:
# #curl -o /usr/local/bin/nvim -LO https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage

# # make it executable
# chmod u+x /usr/local/bin/nvim
```

Now `nvim` command is available just like `vi` or `vim`.

```console
$ nvim --version
NVIM v0.4.3
...
```

The "stable" one is v0.4.3. The "nightly" one is also available.
Photo Sharing Card Layout
Tags: codepen, vue, javascript, showdev
Published: 2020-06-09 12:03:00

<p>This is my example of a card UI for photo sharing website.</p>

<p>This card, and the functionality is inspired by Instagram.</p>

<p>I used Single Page Vue Component for the design, then, GSAP for animation.</p>

<p>Although I am too late for the GSAP timeline challenge, I still tried to make it. I used timeline when the user double clicks the image.</p>

{% codepen https://codepen.io/takaneichinose/pen/ExPaEBL %}
MaterialComponents, CoordinatorLayout, AppBarLayout, Toolbar and automatic elevation Spike

Tags: android
Published: 2020-06-09 11:54:36


# MaterialComponents, CoordinatorLayout, AppBarLayout, Toolbar and automatic elevation Spike

Here's an example of how to use themes to get automatic `Toolbar` elevation without extra code or custom listeners.

Use [AppBarLayout](https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout)
from [MaterialComponents](https://github.com/material-components/material-components-android) for it.

# How to

1. Your app style should use a `MaterialCompoment` style, like [src/main/res/values/styles.xml](src/main/res/values/styles.xml).
2. Setup you AppBarLayout:
   * Use any MaterialCompoments style for this component like: `Widget.MaterialComponents.AppBarLayout.Surface`.
   * Set `app:liftOnScroll="true"` to enable the automatic elevation based on scroll.

3. Setup your scrolling view:
   * Set `app:layout_behavior="@string/appbar_scrolling_view_behavior`.

And that's all :)

# Results
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7frjikldbx3qhuvy8sb6.gif)