teleren/devto huggingface dataset:
A quick reference to Python string methods - Cases
Tags: python, beginners
Published: 2019-09-11 08:34:55

---
title: A quick reference to Python string methods - Cases
published: true
tags: python, beginners
series: A quick reference to Python string methods
canonical_url: https://wangonya.com/blog/python-string-methods-cases/
---

## Cases

### `capitalize()`

#### Parameters

```
string.capitalize()
```

`capitalize()` takes no parameters.

#### Return value

Returns a **copy** of the string with the first letter of the first word capitalized and all the other characters of thestring in lowercase.

#### Example

```
Python 3.7.4

>>> s = "soMe peopLe AcTUally tyPE Like thIs."

>>> s.capitalize()
'Some people actually type like this.'
```

### `title()`

#### Parameters

```
string.title()
```

`title()` takes no parameters.

#### Return value

Returns a **copy** of the string with the first letter of **each** word capitalized and all the other characters of thestring in lowercase.

#### Example

```
Python 3.7.4

>>> s = "soMe peopLe AcTUally tyPE Like thIs."

>>> s.title()
'Some People Actually Type Like This.'
```

### `swapcase()`

#### Parameters

```
string.swapcase()
```

`swapcase()` takes no parameters.

#### Return value

Returns a **copy** of the string with all uppercase characters swapped to lowercase and lowercasecharacters swapped to uppercase.

#### Example

```
Python 3.7.4

>>> s = "soMe peopLe AcTUally tyPE Like thIs."

>>> s.swapcase()
'SOmE PEOPlE aCtuALLY TYpe lIKE THiS.'
```

### `upper()`

#### Parameters

```
string.upper()
```

`upper()` takes no parameters.

#### Return value

Returns a **copy** of the string with all characters in uppercase.

#### Example

```
Python 3.7.4

>>> s = "soMe peopLe AcTUally tyPE Like thIs."

>>> s.upper()
'SOME PEOPLE ACTUALLY TYPE LIKE THIS.'
```

### `lower()`

#### Parameters

```
string.lower()
```

`lower()` takes no parameters.

#### Return value

Returns a **copy** of the string with all characters in lowercase.

#### Example

```
Python 3.7.4

>>> s = "soMe peopLe AcTUally tyPE Like thIs."

>>> s.lower()
'some people actually type like this.'
```
Coursera's Algorithmic Toolbox Week 3 - Greedy Algorithms
Tags: beginnners, computerscience
Published: 2019-09-16 11:04:52

---
title: Coursera's Algorithmic Toolbox Week 3 - Greedy Algorithms
published: true
tags: beginnners, computerscience
canonical_url: 
---

When solving problems, it's important to have different types of strategies that can be used to find optimal solutions. One of those strategies, Greedy Algorithms, is the topic of week 3.

## What are Greedy Algorithms?

Greedy algorithms are one type of algorithm in our toolbox for solving problems, they can be broken down into four main steps:

1. Make a greedy choice
2. Prove choice is a safe choice
3. Reduce to a subproblem
4. Iterate
5. Optimize (optional if needed)

_Largest Number Example Problem For Steps Below_

Given a list of single-digit numbers, create the largest possible number from it.

```
Input: 8 7 6 1 3 2 4 5 9
Output: 987654321
```

### Make Greedy Choice & Prove It's Safe

Begin the problem by trying to determine a greedy choice you can make, such as scan the array and find the largest number within it, append it to the result and remove it from the original array.

This optimal choice will allow us to find the largest number possible for an array of single-digit integers.

The lecture states to first find a few greedy choices, determine which is optimal, then prove it. If it can be proven then it is a safe move, and we can use it to solve the problem.

### Reduce to Subproblem, Then Solve & Iterate

The greedy strategy re-uses its safe move over and over, on smaller chunks of the problem, leading to a solution.

For our largest number array example, first, the array has 9 digits. 9 is found as the largest digit and removed.

We break it down into a subproblem of now 8 digits. We find the next highest number, 8, and append it to the result. `98`.

As this continues, the problem continues to be reduced in size while our optimal greedy choice helps us solve it!

### Optimize

As Donald Knuth said, "Premature optimization is the root of all evil."

One wonderful part of Computer Science is the ability to find better and better solutions as you learn from previous mistakes or discoveries. Algorithms can be changed to run faster, if necessary.

This optional step of Greedy Algorithms can be used when solving challenging problems that require top performance.

## Closing Thoughts

Solving algorithm problems with the Greedy Algorithm strategy can be a very useful and simple technique for Software Engineers. The lecture provided great information on other types of problems that can be solved, the min refill problem, or the fractional knapsack. It gave good overviews of the runtimes and analysis of algorithms to solve them, and then asked for us to solve a few in the programming assignment.

Overall - the program assignments take me back to doing my assignments at the JMU Computer Labs, the nostalgia is unreal and I look forward to refreshing on all of the knowledge my professors taught us back then!

Stay tuned for week 4!!
Basic Javascript: Removing Elements from an Array
Tags: beginners, programming, javascript
Published: 2019-09-10 23:44:53

---
title: Basic Javascript: Removing Elements from an Array
published: true
cover_image: https://thepracticaldev.s3.amazonaws.com/i/mjjfwxxnpczifpuswtsc.jpeg
tags: beginner, programming, javascript
---

I am back again this week to cover another fundamental topic on Javascript. I will be going over various ways to remove elements from an array. Although the topic is simple enough, I often find myself mixing up certain methods and what each of them actually do. By writing this guide, hopefully I will be able to further solidify my knowledge on these methods and help anyone else out who might be in the same situation.

### **1. shift()**
```javascript
let breads = [wheat, ciabatta, sourdough, brioche]
breads.shift() // returns wheat
console.log(breads) // [ciabatta, sourdough, brioche]
```
Using the shift method removes the first element in an array. It returns the first element and completely modifies the original array.

### **2. pop()**
```javascript
let fruits = [apple, banana, kiwi, orange]
fruits.pop() // returns orange
console.log(fruits) // [apple, banana, kiwi]
```
Using the pop method removes the last element in an array. It returns the last element and completely modifies the original array.

### **3. splice()**
```javascript
let cars = [Toyota, Ford, Jeep, BMW]
cars.splice(1, 1) // returns [Ford]
console.log(cars) // [Toyota, Jeep, BMW]
```
The splice method can be used to remove or add elements in an array. The first argument is the index location at which elements are to be removed or added. The second argument is the number of elements to be removed from the array. In the example above, the arguments call for one element at index one to be removed. This method returns a new array with the removed element and modifies the original array.

Using this method, you can remove a range of elements from an array.

```javascript
let heroes = [Superman, Batman, Spiderman, Ironman, Thor, Hulk, Flash]
heroes.splice(2, 4) // returns [Spiderman, Ironman, Thor, Hulk]
console.log(heroes) // [Superman, Batman, Flash]
```

### **4. slice()**
```javascript
let shoes = [Nike, Adidas, Reebok, Jordan, Vans]
shoes.slice(1, 4) // returns [Adidas, Reebok, Jordan]
console.log(shoes) // [Nike, Adidas, Reebok, Jordan, Vans]
```
The slice method can be used to remove elements from an array without modifying the original array. The first argument specifies the starting index location and the second argument specifies the ending index location(the end is not included).  A new array object will be created using the elements within the range of those indexes. 

I hope this was helpful to anyone just starting to learn Javascript or to those who needed a refresher on a simple, but important topic. Let me know if there are any other methods that I missed out on. Thanks for reading!
What I Learned
Published: 2019-09-10 23:02:12

---
title: What I Learned
published: true
description: Learning
tags: 
---
Today I will discuss briefly what I learned during my first few days of my internship. I will try to keep things vague so as not to discuss company trade secrets. If I am wrong in anything, please correct me so I can learn the right things.

I learned about controllers, storage boxes and servers. I've learned about initiators and target devices as well as the SAS protocol. I learned the history of protocol advancements. Parallel ATA was the first, then came SATA, then SCSI, then finally SAS. I learned about firmware and drivers. I learned about backplanes, expanders, cooker boards and VSMs. I learned about SDKs and platforms. 

In my next post, I hope to talk more about the things I learn. I hope to eventually play with the hardware, write some C++ code, and encounter some challenges to talk about. For now, I'm mainly learning about the company's products and about the field.
Split your Django generated models into separated files
Tags: django, models, split
Published: 2019-09-10 22:38:53

---
title: Split your Django generated models into separated files
published: true
description: A script to help you split your models generated from django inspectdb into separated files
tags: django, models, split
---

# Split Django Models

Split Django generated models into separated files, with proper names, classes and imports.

## Usage

Generate your models:  
```bash
python3 manage.py inspectdb > models.py
```

Run the script:  
```bash
./split_django_models.sh models.py
```

Put them all into a folder so you can enjoy the step bellow:  

The script also creates a *\_\_init\_\_.py* file, so you can import them all at once:  
```python
from yourapp.models import *
```

Get the script [here](https://github.com/victorqribeiro/splitDjangoModels)
CompileSwift Podcast Episode 8 - Apple Event 09/2019
Tags: apple, podcast
Published: 2019-09-10 22:35:56

Yep, I wrapped up all the announcements without the marketing spin in under 10 minutes.

Enjoy

[Goto Podcast](https://anchor.fm/compileswift/episodes/Apple-September-2019-Announcements----iPhone-11--Watch-Series-5--7th-Generation-iPads-e5are4)
Introducing the Debug Challenge
Tags: debug, challenge, practice, showdev
Published: 2019-09-10 22:30:18

Introducing the Debug Challenge!  From now on, every week I’ll be posting a product, code snippet, or GitHub repository that has an issue.  Your job?  Debug it and get it up-and-running!  How does it work?

When I post the challenge, I’ll tell you what’s not working, and you can check it out.  You can research (or find code on Stack Overflow) or just use your current knowledge to solve the problem.  Before the week is over, comment on the challenge post.  The winning solution will need an explanation of what went wrong, how you found the solution, and what the solution is.  When the next challenge rolls around, the winner will be announced at the top of the post!  

The first Debug Challenge will begin this Sunday, so hone up your skills, devs!  Good luck!
Discussion: What is the best way to get users to refresh a web app?
Tags: nuxt, zeit, graphql, javascript
Published: 2019-09-10 20:35:09

---
title: Discussion: What is the best way to get users to refresh a web app?
published: true
description: Notification system to get the latest updates to users?
tags: Nuxt, Zeit, GraphQL, js
---

I'm currently developing a Nuxt web app for our staff to use for processing orders. 

At the moment, there are a lot of bugs being fixed or new features implemented.

The trouble is, the users generally keep the tab open for days on end, since they are using it constantly - and since it's Nuxt, they don't ever hard-refresh.

This means they don't get the bug fixes they asked for as soon as they have been deployed.

**What is the simplest notification system for me to quickly post a 'Refresh this page to see the latest version' popup?**

I'm using Nuxt, GraphQL, and Zeit deployment, so if it could trigger from a successful deploy on Zeit that would be awesome.
Getting a job at Google after coding bootcamp
Tags: beginners, career, codenwebie, firstyearincode
Published: 2019-09-10 20:13:06

I recently did an interview with Clément Mihailescu (former software engineer at Google, soon to be software engineer at Facebook) about his coding bootcamp experience and his journey from learning to code to getting a job at Google afterwards.

We ran through the similarities of our coding bootcamp experiences, and differences, as well as the challenges in the job search afterwards.

Check out the video below if you're interested in learning about alternative paths into the tech industry!
[YouTube - Matt Upham](https://www.youtube.com/mattupham?
sub_confirmation=1)
{% youtube AxM-rsV32Sw %}
[Coding bootcamp experience (Job at Google after)](https://youtu.be/AxM-rsV32Sw)

Are you currently learning to code? If so, what have been your biggest challenges? Are you going a more traditional route (CS degree), or alternative route (Self-taught / Coding bootcamp)?

If you found this video useful, please consider subscribing to my YouTube Channel! I talk about software & tech, life in Silicon Valley, and self-improvement!

**Subscribe Here**
[YouTube - Matt Upham](https://www.youtube.com/mattupham?sub_confirmation=1)
Three things from today - 9/10
Tags: devjournal, datascience, career
Published: 2019-09-10 19:48:55

#9/10/2019
### Tuesday.

A quote from Kahlil Gibran:

> “Work is love made visible. And if you can't work with love, but only with distaste, it is better that you should leave your work and sit at the gate of the temple and take alms of the people who work with joy”

Three things simply from today:

##1.  ["It's later than you think"](https://www.linkedin.com/pulse/its-later-than-you-think-j-r-storment/)

A seriously heartbreaking but moving story about loss. Helps keep perspective about what is important. Warning that this could make you tear up during a meeting.

##2. [Google's dataproc service is in alpha.](https://cloud.google.com/dataproc/)

> Cloud Dataproc is a managed Apache Spark and Apache Hadoop service that 
> lets you take advantage of open source data tools for batch processing, > querying, streaming, and machine learning.

This is a really interesting alternative to HDInsights or Databricks. I will need to toy with this later.

##3. [Senior Engineer checklist](https://littleblah.com/post/2019-09-01-senior-engineer-checklist/)

A great list of standards to print out and aspire to if you're looking to grow your career.

See you party people Tomorrow!!
How did you setup Capybara + Webdrivers on WSL for testing?
Tags: help, discuss, testing, ruby
Published: 2019-09-10 19:37:05

I recently started contributing to dev.to's GitHub repository by refactoring some .js files to meet the eslint specs. Some of the files that need to be refactored require multiple other ones to be refactored too at the same time in order to not break certain functionality.

In order to check for that I have been trying to setup the Acceptance testing as specified in the docs + with some online help to check whether all functionality remains as is or not. But I have been hitting various hurdles throughout where either the chrome binary wouldn't be found, post that after installation it posted `Invalid Session id` or sometimes it would work totally. It's a mystery for me currently.

Any help / pointer in the right direction would be much appreciated :D. Willing to provide any details required for the same!
Announcing fastr_conf Toronto
Tags: techtalks, career
Published: 2019-09-10 19:12:20

The web is changing, fast! As a web developer, you need to evolve with it, or risk being left in the dust.

_**fastr_conf**_ aims to inform and empower web developers to be more productive, level-up their skills, and ultimately fast-track their projects and their careers.

This is a one-day, single track, crash-course on disruptive technologies such as JAMstack and Static Site Generators that are making an impact in the industry.

We've partnered with Juno College (HackerYou) and established web developers, to deliver meaningful, and action-able sessions.

[Learn More](https://www.eventbrite.com/e/fastr-conf-2019-tickets-71565816283)
I have pushed myself towards .net but Linux keeps pulling me back.
Tags: csharp, rust
Published: 2019-09-10 19:01:03

Hello to all of you :)

I have been following this portal for quite some time then registered and tried to talk to some of you. 

To be honest, this is my first post around here. I would like to know your opinion about my learning curve which in my case is very different. I have read articles of people doing one thing and moving to another after a big amount of time. Actually, I am not that person but I am trying to do my best.

I have seen a post of a girl who was a little annoyed that she is getting declined on a job interview, but people did leave her some suggestions. I think that it does take courage to leave such a post on such a big portal like dev.to

So I thought about sharing my problems and maybe getting any suggestions or action points from all of you :)

Let's go. I have started learning Linux quite some time ago but it was never a development operating system for me. I always have ended up installing the system on a virtual machine and doing apt-get update and apt-get install, leaving the machine un-touched and then removing it. Due to my passion for photography, I was always using Windows. Games where always the point of my interest.
 
Then I went to become an engineer. I had csharp at my University and even wrote some small projects in it. Mostly console application without any superb purpose. I have even written a calendar with sync for windows phones - it was that time when Nokia was bought by Microsoft. 

I was learning csharp for quite some time but never used it commercially. I have worked for a company which did use a SharePoint with csharp but I was on the front-end with typescript and kendo. 

Nowadays I went through a rough road and bought so many great books to start learning csharp from scratch. Created a big curve for my own development and started to push toward .net with all the possible knowledge I could get. 

I work in the QA department, in a company where they make network hardware. Linux is the host environment I am using all the time and to say it louder I love it. I have become lazy to learn csharp but instead, I have learned rust, bash, and even python become my close friend with Tkinter GUI stuff to mess around. 

Is this the wrong approach and should I leave the whole Linux stuff and come back to reading and learning csharp?

Or is it ok to stay close to Linux and sometime later try csharp again?

I would like to know if someone had the same road? Was it hard? or was it ok for you?

Did it take so much time? 

I would like to hear some opinions and suggestions on this because going deeper with rust and python makes me feel a little (to be honest) overwhelmed.

Thanks in return.
envsure : {dev} en(v)sure packages are installed
Tags: showdev, node, javascript
Published: 2019-09-10 18:54:49


## Lets begin at the *why*
 
While using `storybook` in ~~a~~ some projects, I saw the huge amount of packages that needed to be installed by this (dependencies/addons). Sure on a local repo, installing it once this can be ignored. 

But when you push it to your CI and have for example different CI-runners for different kind of tests, you probably don't need to install storybook (and addons) every time for each CI. Well .. maybe one if you want to test your components? But even then only this particular CI-job would need to install the packages.

### Workaround 1: `package.json` (one I used)
You could just create `package.json`-script-task, like: 
`"install-stuff": "npm install myPackage@1 otherPackage@2 andSo@0n"`

This is probably ok for 3-4 packages, but not when having to add like 8+ and having to handle the versions all into one line in your `package.json`? I for one don't want to do that (again)

### Workaround 2: `install-other-packages.sh`
Use the same `npm install` in a shell-script, sure you can use multiple lines to ease the overview. 

This would be ok if you have one group of packages you need once but what about different groups ?

### Workaround 3: 
Use a different folder in your repo (which has its own `package.json` with these needed packages)

None of these workarounds were good enough for me. So I just made my own.

## Introducing `envsure` - the unusual (node) package installer addon

You can use `envsure` by either having it installed globally `npm install -g envsure` or by using `npx`

Example: 
`envsure groupName` or `npx envsure groupName`

It will use the `envsure.json` in your current directory to install all needed packages for `groupName` without added them to package.json.

```json
{
  "version": 1,
  "groupName": {
    "packageA": "1.2.3",
    "packageB": "2.3",
    "and-so-on": "1"
  }
}
```

`version`: (optional) property is used to determine the json schema, in case of future updates. 

Also you could just use it with your usual npm-script
```json
...
   "premy-routine": "npx envsure groupName",
   "my-routine": "..."
...
```

Links: [repo](https://github.com/negue/envsure) | [npm](https://www.npmjs.com/package/envsure)


This is the first cli I've ever made. So I probably don't have any best-practices on what to use for node-based cli's. Sorry about that! 


Also this is probably just a niche use-case, but maybe it'll help somebody.
TIL: Todo Tree a nifty VScode Extension
Tags: vscode, extension, todayilearned
Published: 2019-09-10 18:49:43

---
title: TIL: Todo Tree a nifty VScode Extension
published: true
description: Highlight your TODOs etc. in your editor
tags: vscode, extension, til
---
This is a really nifty extension for **vscode**.

It lets you define tags in your code like `TODO` and `FIXME` (_the defaults_) which will then be highlighted in your code and will appear in a special sidebar section.

![Todo Tree screenshot example](https://thepracticaldev.s3.amazonaws.com/i/sezj5mkhkhofqph6v36v.png)

This is my configuration used for the above example.

```json
{
    "todo-tree.autoRefresh": true,
    "todo-tree.defaultHighlight": {
        "type": "text-and-comment"
    },
    "todo-tree.customHighlight": {
        "TODO": {
            "foreground": "black",
            "background": "green",
            "iconColour": "green",
            "icon": "check",
            "type": "text"
        },
        "FIXME": {
            "foreground": "black",
            "background": "red",
            "iconColour": "red",
            "icon": "bug"
        },
        "REVIEW": {
            "foreground": "black",
            "background": "cyan",
            "iconColour": "lightblue",
            "icon": "eye"
        },
        "HACK": {
            "foreground": "black",
            "background": "#FFA500",
            "iconColour": "orange",
            "icon": "alert"
        },
        "REF": {
            "foreground": "black",
            "background": "grey",
            "iconColour": "grey",
            "icon": "link",
            "type": "tag"
        }
    },
    "todo-tree.tags": [
        "TODO",
        "FIXME",
        "REVIEW",
        "HACK",
        "REF"
    ]
}
```

You can define you own tags and can assign, icons and colour schemes, based on your preferences.

[This TIL](https://github.com/jonasbn/til/blob/master/vscode/todo_tree_extension.md) was lifted from [my TIL collection](http://jonasbn.github.io/til/).

## Resources:

- [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree)