teleren/devto huggingface dataset:
A Short Intro to Algorithms 
Published: 2020-02-10 18:26:05

An algorithms in the simplest definition is a solution to a problem. Algorithms are a set of guidelines that describe how to solve a problem and perform a task. 


A great place to start is by learning the search and sorting algorithms. The linear sort is one the simplest search algorithms. The algorithm below is the linear search: compares the key (item to find) to each item in a list until it has been found. 

![Linear Sort in Ruby](https://i.imgur.com/JbFK7i8.jpg)

![Linear Sort in Ruby](https://i.imgur.com/gTYZjEq.png)


What the algorithm is doing: 
1) The method "linear_search" takes in an array and a key. The key is the item you’re looking for. The algorithm starts from the leftmost element of the array and one by one compares the element we are searching for with each element of the array.
2) If the key is not found, a message is returned.
3) If the key is found, a message is printed out stating the key and the index.

![Linear Sort in Ruby: Solution](https://i.imgur.com/0WiRE1u.png)


Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. The algorithm below is the bubble sort: sorts an array in ascending order.

![Bubble Sort in Ruby: Solution](https://i.imgur.com/gsFc7Yv.jpg)

![Bubble Sort in Ruby: Solution](https://i.imgur.com/BbpBiNv.png)

What the algorithm is doing: 
1) The method "bubbleSort" takes in a single array parameter. 
2) A variable "n" finds the array length. Bubble sort needs to know the length in order to know how many times to iterate through the array.
3) The "loop do" will loop through then iterate through each element of the array. With "loop do" in ruby, you need to tell the method when to stop. The sentinel variable "swapped" will let the loop know when to stop. Swapped = false is set in the beginning since immediately after the beginning of your loop, there have been no swaps. Swapped will break when it can no longer be true (there are no more swapping needed). The loop will run as long as the swap is true. 
4)The loop will check if element i is greater than the element next to it i + 1. If it is, it will swap the value of i with the value of i+1. The loop will also set the value of swapped to true when there is a swap made.

![Bubble Sort in Ruby: Solution](https://i.imgur.com/M9fJAfS.png)

5)The loop will terminate when there is no more swaps needed and the array will be returned in ascending order.

![Bubble Sort in Ruby: Solution](https://i.imgur.com/EEM9awH.png)
ZingChart Angular Examples
Tags: javascript, angular, dataviz
Published: 2020-02-10 18:24:49

Whether you are looking for a solution to quickly create a chart, or you are looking to build complex dashboards within your Angular application, [ZingChart's](https://www.zingchart.com/?utm_source=devto&utm_medium=blog&utm_campaign=angular) new Angular component is the perfect solution for you.

## Getting Started
To help get you started with our library in your Angular application, check out the first post in this series - [How to Create Charts in Angular](https://blog.zingchart.com/how-to-create-charts-in-angular/).

If you run into any issues using ZingChart, its component or any of the 35+ chart types, don't hesitate to reach out to support@zingchart.com.


## Customized Charts
The ZingChart Angular component has the same capabilities that the regular library has, allowing you to fully customize charts to your brand, like this Angular Gauge Chart!
{% stackblitz zingchart-angular-example-gauge view=preview %}
[https://stackblitz.com/edit/zingchart-angular-example-gauge](https://stackblitz.com/edit/zingchart-angular-example-gauge)

## Listening to Events

We can attach a listener to any of ZingChart's events and use that information outside of ZingChart, in our Angular application. The following example shows how we can create a custom tooltip that is external to the chart.

{% stackblitz zingchart-angular-example-events view=preview %}
[https://stackblitz.com/edit/zingchart-angular-example-events](https://stackblitz.com/edit/zingchart-angular-example-events)


## Data Binding 

By data binding a chart's configuration, we can control the data and how it's appearance from Angular. The dropdown demonstrates different datasets being loaded into our chart with our `data` attribute being bound via Angular.

{% stackblitz zingchart-angular-example-data-binding view=preview %}
[https://stackblitz.com/edit/zingchart-angular-example-data-binding](https://stackblitz.com/edit/zingchart-angular-example-data-binding)


## 35+ Chart Types

The Angular component is compatible with [all chart types](https://www.zingchart.com/gallery?utm_source=devto&utm_medium=blog&utm_campaign=angular) that ZingChart offers, including plugins such as maps!

{% stackblitz zingchart-angular-example-map view=preview %}
[https://stackblitz.com/edit/zingchart-angular-example-map](https://stackblitz.com/edit/zingchart-angular-example-map)
Code Story Season 2 - released tomorrow!
Published: 2020-02-10 18:14:14

---
title: Code Story Season 2 - released tomorrow!
published: true
description: 
tags: 
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/en4cfud0lb6yryeuhves.png
---

Tomorrow marks the beginning of Season 2 of the Code Story podcast. The first episode will be a guest appearance from none other than @csallen himself! Make sure and subscribe today, so you can be the first to tune into this amazing episode, where we dive into the early days of indie hacker inception. 

Website: https://codestory.co
Apple: https://podcasts.apple.com/us/podcast/code-story/id1466861744
Spotify: https://open.spotify.com/show/0f5HGQ2EPd63H83gqAifXp
Pocket Casts: https://pca.st/Z1k7
Breaker: https://www.breaker.audio/code-story
YouTube: https://youtube.com/channel/UCgjZsiUDp-oKY_ffHc5AUpQ
RSS: https://feeds.transistor.fm/code-story
coronavirus Johns Hopkins dashboard link
Published: 2020-02-10 17:51:32

---
title: coronavirus Johns Hopkins dashboard link
published: true
description: 
tags:
---

Dashboard for showing evidence based numbers in coronavirus outbreak.

https://gisanddata.maps.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6

Leaving this here so I do not have to keep google'ing it.

Also good information if you are following. Totally not dev related, feel free to ignore. :)
How to avoid the Factory pattern in C#
Tags: csharp, dotnet, functional
Published: 2020-02-10 17:41:58

# Domain model classes

Object-orientation is great when classes represent actual domain model objects. For example, if we're modeling animal sounds, `Dog` and `Cat` classes make good sense:

```csharp
interface IAnimal
{
    string Speak();
}

class Dog : IAnimal
{
    public string Speak() => "Woof";
}

class Cat : IAnimal
{
    public string Speak() => "Meow";
}
```

# Factory pattern

Now, let's say we need to write a function that creates an arbitrary animal and asks it to speak. Unfortunately, there's no way to add a constructor to the `IAnimal` interface. One way to work around this limitation is the [Factory design pattern](https://refactoring.guru/design-patterns/factory-method/csharp/example), which creates a separate "factory" class for each of our domain model classes:

```csharp
interface IAnimalFactory
{
    IAnimal CreateAnimal();
}

class DogFactory : IAnimalFactory
{
    public IAnimal CreateAnimal() => new Dog();
}

class CatFactory : IAnimalFactory
{
    public IAnimal CreateAnimal() => new Cat();
}

```

With the new `IAnimalFactory` interface, we can create dogs and cats and make them speak:

```csharp
class Program
{
    static void Main(string[] args)
    {
        Run(1, new DogFactory());
        Run(2, new CatFactory());
    }

    static void Run(int n, IAnimalFactory factory)
    {
        var animal = factory.CreateAnimal();
        Console.WriteLine($"Animal #{n} says '{animal.Speak()}'");
    }
}

// output:
// Animal #1 says 'Woof'
// Animal #2 says 'Meow'

```

This works fine, but it adds a considerable amount of new code and conceptual overhead, because every domain model class now requires a separate factory class as well. The extra level of indirection can quickly become confusing. Is there a better way?

# Factory functions

Functional programming lets us get rid of factory classes altogether. Instead of passing an `IAnimalFactory` to `Run`, we can instead pass a "factory function" of type `Func<IAnimal>`. This takes over the role played by the factory object in the previous implementation:

```csharp
static void Run(int n, Func<IAnimal> createAnimal)
{
    var animal = createAnimal();
    Console.WriteLine($"Animal #{n} says '{animal.Speak()}'");
}
```

We can use lambdas to create our factory functions with little ceremony:

```csharp
static void Main(string[] args)
{
    Run(1, () => new Dog());
    Run(2, () => new Cat());
}

```

The output is exactly the same. By using functions as first-class objects, we've eliminated an entire category of classes and significantly simplified our code base! If you find yourself tempted to create a factory object in the future, consider using a factory function instead.
A cheatsheet for updating Linux
Tags: beginners, linux, cheatsheet
Published: 2020-02-10 17:41:44

---
title: A cheatsheet for updating Linux
published: true
description: The update commands you need for updating your Linux system
tags: beginners, linux, cheatsheet
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/2qlxtxbh89bc1l3uxg0k.jpg
---
_cover image by [Tarekheikal](https://commons.wikimedia.org/wiki/User:Tarekheikal)_
Linux needs updates, badly! Here's how to keep your version of Linux updated (not sure which version of Linux you have? [Good news I wrote a guide to that](https://dev.to/heroku/the-path-to-linux-wizardry-know-the-five-flavors-238g))
### Update commands

* On _Debian-based_ distributions, you use [`apt-get update && apt-get upgrade`](https://www.tecmint.com/useful-basic-commands-of-apt-get-and-apt-cache-for-package-management/);
* On _Redhat-based_ distributions, [`yum update`](https://access.redhat.com/articles/yum-cheat-sheet);
* On _Arch-based_ distributions, [`pacman -Syu`](https://wiki.archlinux.org/index.php/Pacman#Usage).
* _Slackware-based_ distributions vary in their approaches to package management:
   - On *SUSE-like* distributions, you use [`zypper up`](https://en.opensuse.org/Package_management);
   - On *Slackware* itself, you manage packages manually with the help of the suite of [package tools](https://docs.slackware.com/slackbook:package_management).
* _Gentoo_ uses a package management system called [Portage](https://wiki.gentoo.org/wiki/Portage). You run `emerge --sync`, do what the prompt says, then run `emerge -atv`.
* _Other_ consult your distribution's documentation.
How to Get Current User Location in Laravel
Tags: laravel, gps, tracking
Published: 2020-02-10 17:31:40

In this tutorial i am going to show you how to get current location in laravel 6. Sometimes, we may require to get user location. In this tutorial i am going to show you how we can track user ip address and can find user location information from ip address.

https://www.codechief.org/article/how-to-get-current-user-location-in-laravel
Django model data does not show in template
Tags: django, python
Published: 2020-02-10 17:30:00

models.py

from django.db import models

class ToDo(models.Model):
    title = models.CharField(max_length=100)
    detail = models.TextField()
    published_date = models.DateTimeField()

    def __str__(self):
        return self.title

Views.py

from django.shortcuts import render, HttpResponse, redirect
from django.utils import timezone
from todoapp.models import ToDo



# Create your views here.
def home(request):
    todo_items = ToDo.objects.all()
    context = {'todoItems': todo_items}
    return render(request, 'todoapp/home.html', context)

def add(request):
    if request.method=="POST":
        addTitle = request.POST['addTitle']
        addDetail = request.POST['addDetail']
        current_date = timezone.now()

        addedObject = ToDo.objects.create(title=addTitle, detail=addDetail, published_date=current_date)
        return redirect('home')


    return render(request, 'todoapp/home.html')
Create a new project...
Tags: productivity, devops, webdev
Published: 2020-02-10 17:27:48

I'm planning a project that will let people make list and share them with others. Think, to-do list that the family can view add and remove from. I want it on mobile and also a website. It will have to pull some data from a database. Push notification is also on the project plan. So my question is what should I start with? I want to stick to C# and .NET as much as I can't so I can focus on the project and not on new languages. ASP.Net Core Web App, Xamarin, UWP? I don't want to re-code for every device. This is WAY OUT of my comfort zone, but that's when I do my best, I also expect this to be a long project. More resume builder then anything. Just need to some help figuring out where to start.
I'm a developer and then Mondays happen
Tags: motivation, mentalhealth, career
Published: 2020-02-10 17:10:09

I'm a developer and I've been in this industry for 13 years and then Mondays, they're not always great! 😅

Have you ever had what I like to call a "mid developer life crisis", where you start questioning things like:

####"Why are we copying X Y Z companies if their tech implementations and architecture are totally different than ours?"
*hold your thoughts for a second and let me explain first* 

I'm not against trends or following another company's tech implementations, I simply don't agree with the approach of _"Let's do it because X Y Z are doing it"_. 

That's not how it works, you cannot force one's architecture, solutions and tech implementations to fit yours and your business necessities without first assessing if it makes sense, the risks involved, is it doable, the costs, the time, the pros and cons, etc.

####"Why do I feel like a code monkey?" 

We are the caretakers of the codebase, we read and write lines of code every single day, we know the code, the risks, the architecture, the time we need to implement a feature, the product, the business model, etc. 

So shouldn't we make tech decisions, instead of being told how to do our job?


####"Why aren't we addressing the tech debt?"

We all have been there! *__Raise your hand if you get antsy because there's no time to fix tech debt.__* 🙋🏻‍♀️ 

Tech debt is nasty and pesky "little" thing and the longer it's ignored and not addressed, the higher the risk of compromising the product and business. 

Developers need to address tech debt and improve the quality of the code and companies should highly promote this.


##So what can we do?

These are a few of the things I do when I have this "mid developer life crisis"

#####Work actions: 
1. Be professional (always) and do your job as best as you can
2. Approach your manager and explain your concerns
3. Don't point fingers or criticise, instead
4. Propose solutions and offer your help (easier said than done, I know). 
5. Take initiative and push for the things you think the company could benefit from

If you are really unhappy and feel like you're not growing as an individual and professional, then
6. Start looking for a new job. I'm sure your skills, expertise and work will be of great value and use in another company.

#####Personal actions:
1. Get some side projects to keep you motived. Not only are you learning new things, you're also exploring other languages, tech stack, tools, frameworks and expanding your "toolbelt" or "toolkit". 
2. Get a few hobbies to help you unwind and relax, at least you won't dwell in "Why this?", "Why that?" that you might ask yourself 300 times a second. 😂
3. Talk to a friend, it helps more than you think.
4. And most important of them all. It's just a job don't let it affect you and your personal life to a point were you could burnout.

###Overall
No company is perfect but if you express your concerns, propose improvements, offer your help and take initiatives, there's still hope for a better working environment.
Don't Follow the Style Guide
Tags: webdev, webperf, productivity, codenewbie
Published: 2020-02-10 17:07:57

I loved playing soccer as a child (football to the rest of the world). Like most children learning to play, I was taught not to toe-punch the ball even though I really wanted to because I could kick it harder that way. But it was terribly inaccurate so I learned and practiced other kinds of kicks instead that gave me more control and accuracy. Once I progressed in skill, I discovered that I occasionally needed to break the rule I had learned and toe-punch the ball, although only in rare circumstances.

This is an example of learning when to break the "rules".

Style guides fit into this category as well. They are meant to be clear and concise so they generally don't explore alternate or nuanced options. While this helps to prevent confusion in new learners, there will likely be times as you advance when another solution is better for your situation.

Although it's okay to simply follow best practice advice given in style guides, learning a subject **deeply through practice and exercise** can bring you to a new level of ability and let you master the appropriate times to break the rules, like learning when to toe-punch the ball. Remember: the people who write the "rules" are no smarter than you and possibly not even more experienced than you.

At Thinkster, we consider it our business to not only help you learn the "rules" but also to learn them deeply enough to know when to break them.
 
Happy coding!

Signup for my newsletter at [here.](https://is-tracking-link-api-prod.appspot.com/api/v1/click/4616255200034816/5570275139911680)
Visit Us: [thinkster.io](https://thinkster.io/) | Facebook: @gothinkster | Twitter: @GoThinkster
Chingu Weekly update vol. 105
Tags: career, collaboration
Published: 2020-02-10 17:06:28

---
title: Chingu Weekly update vol. 105
published: true
description: 
tags: #career #collaboration
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/mcwl6sb7izbmdu66hkr8.jpeg
---


## News, Shout-outs & Showcases
🚀 Voyage-16 teams have been launched!

🚀 Voyage-15 is approaching the final stretch! 

🔥THROWBACK Here is [a bot that automatically converts timezone differences](https://kronostimezoner.herokuapp.com/) for remote dev teams in Slack! It was built by dsegovia, jdrichardstech. 


🔥Check out [ty's Node app](https://weddingrsvpdemo.herokuapp.com/): "It lets you RSVP for a fictional wedding with your name and email address and then sends it to a Postgres database. You can also view a list of attendees with the /list endpoint."


🔥Here is @ mokokom's [favorite fonts app](https://favoritefonts.mokokom.com/)! 

🔥And here is Tototomi258's favorite [fonts app](https://chingu-solo.github.io/solo-koala-84/assets/public/) as well! 


##Overheard in Chingu
*Random lines taken out of context from the Chingu community.*

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0b4w8vpfvniu3pc621yl.png)

>you are a packman now??!?!?!?!
also going to prepare for 1st team 1st Voyage meeting
2 days refactoring our styling solutions and 2000 errors later .. It finally works. It reduces our generated CSS styles from 9044 lines to 6822 lines uncompressed. It's about 37kb less than before when compressed
REST is better than SOAP
Guess who has tickets to see the Stones?
Is anyone using a Yubikey or Google Titan security key fob? I'm curious to hear what your experience has been
I started coding about 7 years ago with Java and mostly it's frameworks. I dipped my toe into spring for a while but my role changed completely and got pushed into multiple things. I dabbled around with Python for a while as I was interest in Computer Vision, but then due to job requirements I had to leave that path
This is the first step to learn how to code
just fyi, the 'what does your name mean' is something I added for personal touch lol. it's not part of the actual template

## Resources of the week

From @Varun
>"One of my contact who has been working in tech industry for almost 7 years and a great teacher, has started a podcast. In [the first episode he is talking about Imposter syndrome](https://twitter.com/mgoldber/status/1225199476568207362), a most important for every dev.
 

## Meme to go
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/f0ziivzh4elds4nxt1b5.png)
In the 90s teens used pagers as the original instant messenger
Tags: teens, innovation, sms, 90s
Published: 2020-02-11 09:35:09

---
title: In the 90s teens used pagers as the original instant messenger
published: true
date: 2020-02-10 16:46:04 UTC
tags: teens,innovation,sms,90s
canonical_url: https://www.simplecto.com/90s-teens-used-pagers-as-message-service/
---

 ![In the 90s teens used pagers as the original instant messenger](https://www.simplecto.com/content/images/2020/01/90s-pager-1.jpg)

Never underestimate your customers, especially if they are teenagers.

Before cell phones blew up some of us had pagers, and I remember doing this. We had a number of ad-hoc codes that would signal times, locations, and people we were with. It was the original "Short Message Service."

Young power-users will bend your products and services in creative, funny, and frustrating ways.

![In the 90s teens used pagers as the original instant messenger](https://www.simplecto.com/content/images/2020/01/90s-pager.jpg)
Trivia #2: Where did the word "debugging" come from?
Tags: watercooler, codenewbie, computerscience
Published: 2020-02-10 16:43:48

Welcome to my little CS trivia series. Every week I post a new trivia piece because it seems that my mind is made of pieces of knowledge that don't make one knowledgeable but certainly serve as a good conversation starter (or, killer).

Today's question is...

---
## Where does the word "debugging" come from?

When I was doing [Harvard's CS50 course](https://cs50.harvard.edu/), professor [David Malan](https://cs50.harvard.edu/college/2020/spring/staff/) mentioned that the origins of debugging trace back to 1947 and [Admiral Grace Hopper](https://en.wikipedia.org/wiki/Admiral_Grace_Hopper) who found a moth that caused the Mark II computer to break. Admiral Hopper then pasted the moth into her journal with the words "First actual bug being found":
![Grace Hopper journal](https://dev-to-uploads.s3.amazonaws.com/i/vsabpdq6cbmqc9n00vsu.jpg)
*By Courtesy of the Naval Surface Warfare Center, Dahlgren, VA., 1988*


Now, although that is a very lovely story, the term had actually already been present in tech. For instance, in 1944 [J. Robert Oppenheimer](https://en.wikipedia.org/wiki/J._Robert_Oppenheimer), the director of the WWII atomic bomb program, used the word in his letter to [Ernest Lawrence](https://en.wikipedia.org/wiki/Ernest_Lawrence).
![Oppenheimer's letter](https://bancroft.berkeley.edu/Exhibits/physics/images/bigscience25.jpg)
*By Courtesy of UC Berkeley, 1944*

While we don't know how the word came in use into tech, Clive Thompson mentions in [his book, "Coders",](https://www.amazon.com/Coders-Making-Tribe-Remaking-World/dp/0735220565) that it was already in 1878 that [Thomas Edison](https://en.wikipedia.org/wiki/Thomas_Edison) used the word in reference to his telegraph malfunction. In a letter to his friend, he wrote:
>“You were partly correct, I did find a ‘bug’ in my apparatus, but it was not in the telephone proper."

![Edison Letter](https://dev-to-uploads.s3.amazonaws.com/i/2enckg3wx9kdvnj6159e.jpg)
*By courtesy of Swann Galleries*