teleren/devto huggingface dataset:
Singly Linked List: A Python Implementation
Tags: python, computerscience
Published: 2019-11-22 20:33:40

Recently in my computer science course I implemented a singly linked list for an assignement. To solidify the concepts, I'm going to rebuild it in python. And for your benefit, I'm going to write about it.

A singly linked list is composed of nodes, each of which points to another node. The only exception is the last node, which instead points to `None`. The nodes also contain a value. This can be just about anything, but for this demonstration I'll just use integers.

The first thing to do is define a class.

```python
class SLLNode:
    """
    A node in a singly linked list.
    Attributes:
        value - the value to be stored and displayed, integer
        next - a reference to the next Node in the list
    """
```
Here I've defined the class and sketched out my plans for it. But I still need to implement it. To do that we need an initialization method. At least, we need the initialization method to do it neatly.

```python
# indented with class SLLNode:
    def __init__(self, value=None, next_node=None):
        self.value = value
        self.next_node = next_node
```
There's a bit to unpack here, but first let's check and see what it does. We'll do this by using the following code:
```python
node = SLLNode(7, None)
print("Node with value {} and next node {}.".format(node.value, node.next_node))
```
And the output from that is:
```
Node with value 7 and next node None.
```
So what happened?
When I called `SLLNode(7, None)`, it ran the `__init__()` method with the arguments `7` and `None`. This stored `7` to the attribute `value` and `None` to the attribute `next_node`.

What do we have so far? We have a way to create a node, and a convenient way to print the key information about that node, which will be helpful for debugging going forward. That's a pretty basic start, but it's where I'll end it for now.
More to come in this series as I build out the list.

The code for this project is available [here on GitHub](https://github.com/erik-kristofer-anderson/singlylinkedlist). I'll be updating it gradually as I write this series. I'll be sure to commit at least as often as I post, so you can back up and see that code as it was when I published a given post.

EDIT: The next post is now available [here](https://dev.to/erikkristoferanderson/singly-linked-list-part-2-str-method-21k3).
What Status Page Provider or Project Do You Recommend?
Tags: discuss
Published: 2019-11-22 19:56:46

---
title: What Status Page Provider or Project Do You Recommend?
published: true
description: What status page provider or project do you recommend?
tags: discuss
---

Hey everyone!

I am in the process of trying to hook up a status page for DEV so you all can stay up to date on any incidents DEV may have. Of course, ideally, there won't be any since I am here now but gotta be prepared! 😉

What do you use? Do you like it? How much does it cost? 

+1 for links
+1 for anything that is open source
+1 for companies that offer open source discounts

Tell me what you think!!!!
Elixir Phoenix vs. Serverless Node
Tags: elixir, phoenix, node, serverless
Published: 2019-11-22 19:34:40

---
title: Elixir Phoenix vs. Serverless Node
published: true
description: Looking for more practical advice comparing these two.
tags: elixir, phoenix, node, serverless
---

So this is not another comparison post, I've read enough of those to understand the basic differences between these two. This is basically an open discussion for anyone familiar with both of these technologies.

But first, why write anything other than javascript if you are a web engineer? I know this sounds super naive on it's face but after writing javascript for nearly a decade it's very hard to justify building new projects with all the pain that comes from fumbling through an unfamiliar language. Most of the time, I'm more excited by the idea itself than the technology I'm going to use, so having a half completed project in elixir is more heartbreaking than a complete one in javascript.

But alas I think I'm getting tired of being fluent in one language and have an idea that can benefit from something else. I've also grown frustrated with a few things in javascript over the years.

1. No type safety
2. a single error can just tank the entire system
3. Runs hot on memory
4. Not great at concurrency

Here's where elixir phoenix comes in. 

1. Functional/immutable patterns deal with type safety
2. Resilience, errors kill a process without taking down the entire app
3. Runs lighter on memory
4. A beast at concurrent tasks

But of course I've not yet dove in and while the setup was easy, I know there is much pain to come on this route.

So here's my javascript angel on my shoulder saying just come back to what you know.

1. Typescript gives you back type safety
2. If you use typescript in strict mode you should avoid most common errors
3. You can go serverless here and use lambda functions to mitigate the issues of the old node monolith and memory problems.
4. Serverless functions effectively spin up a new process for each call so really you would get the advantages of elixir phoenix concurrency.

Here's where you come in. Have you built apps in both of these types of setups? Am I correct in thinking there isn't much difference in the load a serverless node setup and elixir can handle? Anyone test any of these? And lastly but more generally, how do you resist the urge to just fall back on good ol' javascript when the learning gets tough?
Dissecting azure storage cost for an analytical workload
Tags: azure, analytics
Published: 2019-11-22 18:09:15

Azure Storage is cheap to just store data. For example 1 Terabytes of data storage cost starts from ~£15 per month. 

But in reality we wanted to read/write and do some analytics on top of it (i.e. do some operations on the data). When you embark on an analytical project it is important we have decent estimate for storage and compute cost.

For this example I am only going to focus on *read* operation. The following API calls are considered read operations ReadFile, ListFilesystemFile

As per [azure pricing doc](https://azure.microsoft.com/en-gb/pricing/details/storage/data-lake/) - reading a 4MB data is considered as 10,000 operations.

So if I read 8MB data **once** then 8MB/4MB = 2 chunks of 4MB, 2 x 10,000 = 20,000 operations

So if I read 16MB data **once** then 16MB/4MB = 4 chunks of 4MB, 4 x 10,000 = 40,000 operations

So if I read 500MB data **once** then 500MB/4MB = 125 chunks of 4MB, 125 x 10,000  = 1,250,000 operations

As per the azure pricing doc £0.0042 is the unit cost per 10,000 operations/per read operation.

£0.0042 x 125 operations (1,250,000/10,000) = £0.525 for reading 500MB data **once**.

Say if I have spark or azure databricks script which is scheduled every 15 mins and reads this 500MB of data every time. The price per day (1440 minutes) for reading 500MB data will be,

Cost per 15 minutes = £0.525
Cost per day (we have 96 15 minutes per day) 96 x £0.525 = £50.4

That's £1,512 per month to read 500MB data every 15 minutes.

The above calculations were helpful for me to estimate true cost of an analytical workload. Based on this, if possible we can tweak and apply optimisations such as partition pruning, projections or selections on the workload/scripts so we read only the data we need.
Status Update: 2019-11-22
Tags: phalcon4, status, update
Published: 2019-11-22 19:17:50

---
title: Status Update: 2019-11-22
published: true
date: 2019-11-22 18:55:45 UTC
tags: phalcon4,status,update
canonical_url: 
---

A quick update for this week and the next one regarding v4 and what we have been up to since our last blog post, brought to you by the Phalcon Team :)

### v4

Business as usual. Work is continuing on bugs, minimal functionality and testing. Many thanks to our contributors who via GitHub or Discord reported issues with v4.0.0.RC3.

We already have addressed inconsistencies with interfaces and additional bugs found. As you can see in our [CHANGELOG](https://github.com/phalcon/cphalcon/blob/4.0.x/CHANGELOG-4.0.md) we already have 10 fixes there :)

3 more cards need to be checked and fixed (if found to be bugs) to finish outstanding issues (unless we get any additional reports).

![](https://blog.phalcon.io/assets/files/groot.gif)

### Docs

The documents are nearly done!! Remaining:

- `DevTools` document which will be done after our DevTools is fully compatible with v4.
- `REST API Advanced`. A tutorial based on our [REST API](https://github.com/phalcon/rest-api) application (in progress)
- `Firewall`

We have been correcting some of the documents as we find typos or inconsistencies.

Of course, everyone is welcome to review our documentation and offer suggestions, ask questions, point out inconsistencies and omissions etc.

Our documents for v4 are live here:

[https://docs.phalcon.io/4.0/en/introduction](https://docs.phalcon.io/4.0/en/introduction)

The status of the documentation project can be seen [here](https://github.com/phalcon/docs/issues/2322). If you wish to issue a pull request with corrections, please visit our [docs](https://github.com/phalcon/docs) repository and issue your pull request for the English language only (`en` directory).

### Holidays

To all of our friends in the US, we wish you all a Happy Thanksgiving for next week!

Nikos will be taking a week off and will be returning next weekend. Ruud and Serghei will be around.

### Thank you

Once again a huge thank you our community! If you find bugs, please report them in our [Github Issues](https://github.com/phalcon/cphalcon/issues) page. Alternatively you can always join us in our [Discord server](https://phalcon.io/discord) or our [Forum](https://phalcon.io/forum).

* * *

Chat - Q&A

- [Discord Chat](https://phalcon.io/discord)
- [Forum](https://phalcon.link/forum)

Support

- [OpenCollective - Support Us](https://phalcon.io/fund)
- [Store - Merchandise](https://phalcon.io/store)

Social Media

- [Telegram](https://phalcon.io/telegram)
- [Gab](https://phalcon.io/gab)
- [MeWe](https://phalcon.io/mewe)
- [Parler](https://phalcon.io/parler)
- [Reddit](https://phalcon.io/reddit)
- [Facebook](https://phalcon.io/fb)
- [Twitter](https://phalcon.io/t)

Videos

- [BitChute](https://phalcon.io/bitchute)
- [LBRY](https://phalcon.io/lbry)
- [YouTube](https://phalcon.io/youtube)

![](https://assets.phalcon.io/phalcon/images/emoji/heart.png) Phalcon Team
Charming the Python: Boolean & Operators
Tags: python, beginners
Published: 2019-11-22 18:54:31

*If coding tutorials with math examples are the bane of your existence, keep reading. This series uses relatable examples like dogs and cats.*

---
## Boolean & Operators

 - Boolean
 - Operators
	 - Arithmetic
	 - Comparison
	 - Logical

### Boolean
`True` or `False` are the only possibilities with a boolean. However, you can use them for yes/no questions and many other things too.
```python
is_dog = False
is_coding = True
is_programmer = True
is_cat = False
is_human = true  # this is true, but will error because it isn't capitalized
```

`True` and `False` are constants with the values 1 & 0

```python
True == 1
False == 0
```

### Operators
> Operators are the constructs which can manipulate the value of operands. -[reference](https://www.tutorialspoint.com/python/python_basic_operators.htm "link to reference of this quote")

```python
+ - * / % // **  # math or arithmetic operators
== != < > <> >= <=  # comparison operators
and or not  # logical operators
```

#### Arithmetic Operators
I gave a bunch of examples in the post below.
{% post https://dev.to/vickilanger/charming-python-day-1-of-30-4coo %}

#### Comparison Operators

you can compare numbers, words, lists, and more

| Operator | What it is | Example |
|--|--|--|
| == | equals | `2 == 2` |
| != | does not equal | `2 != 7` |
| > | greater than | `9 > 2` |
| >= | greater than or equal to | `9 >= 9` or `9 >= 7` |
| < | less than | `4 < 6` |
| <= | less than or equal to | `4 <= 7` |


#### Logical Operators
`and` `or` `not` are useful for making decisions

```python
dog_needs_exercise = True
is_awake = True

if dog_needs_exercise and is_awake:
    print("Take dog for a walk")
```

```python
dog_hungry = False
is_dinner_time = True

if dog_hungry or is_dinner_time:
    print("Feed dog")
```

```python
# getting paid this week?

a = "go to work"
b = "get work done"

if a and b:
    print("You get paid")  # because you did both

if a or b:
    print("You won't get paid")  # because you didn't do both
```

{% twitter 1188749430020698112 %}

---
Series based on {% post https://dev.to/asabeneh/30daysofpyton-challenge-43ii %}
Setting Up CORS On A Rails App
Tags: rails, cors, api, react
Published: 2019-11-22 18:44:56

---
title: Setting Up CORS On A Rails App
published: true
description: Setting up CORS on a Rails API to allow communications with a front end app.
tags: Rails,  CORS, API, React
cover_image: https://images.unsplash.com/photo-1555066931-4365d14bab8c?ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80
---

# Problem

I was trying to integrate a Rails API with a React front end when I encountered an error message:
`Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://immense-savannah-47088.herokuapp.com/api/v1/books. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing`.

# Solution

In an effort to solve the problem I tried several suggested solutions including this one I saw in a [Medium](https://medium.com/@admatbandara/setting-up-cors-to-my-rails-api-a6184e461a0f) article that requires the use of the `rack-cors` ruby gem.

## 1. Add rack-cors Gem
In your *gemfile* you should add the following line or in some cases, it is commented out, you just need to uncomment it:

`gem 'rack-cors', :require => 'rack/cors'`

## 2. Bundle install
After adding the `rack-cors` gem you will need to run the following command, to install the gem:

 `$ bundle install`

## 3. Add the configuration in the Application.rb
Add the following lines of code to your `application.rb` file:

```
module YourApp
  class Application < Rails::Application

    # ...

    config.middleware.insert_before 0, "Rack::Cors" do
      allow do
        origins '*'
        resource '*', :headers => :any, :methods => [:get, :post, :options]
      end
    end
  end
end
```
This should work as long as you won’t be using Heroku or other services that use Rack-based servers but if you intend to use Heroku then you will do this instead of the number three-step above.

## 4. Add the configuration in the Config.ru
Add the following lines of code to the end of your `config.ru` file:

```
# ....
 
require 'rack/cors'
use Rack::Cors do
 
 # allow all origins in development
 allow do
   origins '*'
   resource '*',
       :headers => :any,
       :methods => [:get, :post, :delete, :put, :options]
 end
end
```

Check the [Ruby documentation](https://www.rubydoc.info/gems/rack-cors/0.4.0) for more information on using `Rack middleware` and the [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) to learn more about `CORS`.
tsconfigs
Tags: typescript, tsconfig, configuration, extend
Published: 2019-11-22 18:43:38

---
title: tsconfigs
published: true
description: Reusable TypeScript configuration files to extend from.
tags: TypeScript, tsconfig, configuration, extend
---

Hey TypeScript users! Don't write your own `tsconfig.json` from scratch. Instead, extend from [tsconfigs](https://www.npmjs.com/package/tsconfigs). Wow.
Dart Variable And DataTypes
Published: 2019-11-22 18:33:36

Dart provide us various built in data types in Dart.

Numbers
int
double
As contrast to Java or C++ Dart does not have anything like float or long. Dart offers just two types of number *Int and *Double.

Strings
Booleans
Lists
Maps
Runes
Symbols
====================================== Code ================================
void main() {
  
  String fName = 'Awais';
  var lName='Rehman'; // It is inferred as String automatically 
  
  int taxNo=123456;
  var houseNo=405;   // It is inferred as int automatically 
 
  bool isEmployed =true;
  var isWorking = true; // It is inferred as String automatically 
  
  print(fName);
  print(lName);
  print(taxNo);
  print(houseNo);
  print(isEmployed);
  print(isWorking);
   
}
Notes on Getting to Gatsby
Tags: gatsby
Published: 2019-11-22 18:15:11


First I read that Gatsby.js is a “great point of entry for learning to code websites”. 

I’m excited. I normally build simple sites with WordPress and only know a bit of PHP & Javascript.

I read that React and GraphQL are crucial for Gatsby, but if you don’t know them, Gatsby is an excellent tool to learn them. (I don't know them).

<h2>What is Gatsby.js</h2>

From https://www.gatsbyjs.org/ I read that “Gatsby is a free and open source framework based on React that helps developers build blazing fast websites and apps.”

Gatsby is a “static site generator” - it doesn’t depend on a web server.
https://www.staticgen.com/ - A List of all Static Site Generators

Gatsby grabs your data from other sources: Markdown, JSON, CMS, APIs. Then, at build time, it creates an internal GraphQL server of this data.

Gatsby CLI is a published npm package. Command Line Interface (CLI) is a text based way of interacting with your computer. npm is the world’s largest software registry. https://docs.npmjs.com/about-npm/

I'm following instructions for setting up my development environment here: 
https://www.gatsbyjs.org/tutorial/part-zero/

Homebrew is not happy about my late 2009 iMac with OS Sierra.
I receive this message:
==> You are using macOS 10.12.
==> We (and Apple) do not provide support for this old version.
This installation may not succeed. After installation, you will encounter build failures with some formulae. Please create pull requests instead of asking for help on Homebrew's GitHub, Discourse, Twitter or IRC. You are responsible for resolving any issues you experience while you are running this old version.

I also have an outdated version of core-js@2.6.10
I ran:
npm install --save core-js@^3
To update - but it did not update.

I have permissions problems and read this below but now I am getting discouraged, I'm thinking I can't do this, my computer is too old.
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

I keep googling.

I read about not using sudo with npm
https://medium.com/@ExplosionPills/dont-use-sudo-with-npm-still-66e609f5f92

I still couldn’t get Gatsby CLI to install so I tried
npx gatsby new gatsby-site
from https://www.gatsbyjs.org/docs/quick-start
I get this message:
Your new Gatsby site has been successfully bootstrapped. Start developing it by running:

  cd gatsby-site
  gatsby develop

I run gatsby develop but it's not found
-bash: gatsby: command not found

So, despite article about not using sudo, I use it anyway and run
sudo npm install -g gatsby-cli --unsafe-perm

Next thing, I see the words:
<h3>Success!</h3>
<em>Welcome to the Gatsby CLI! Please visit https://www.gatsbyjs.org/docs/gatsby-cli/ for more information.</em>

On my browser I enter http://localhost:8000/

Wow, there it is, my first little starter Gatsby site.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/lplijf9gxl1mdnjxvuw6.png)
Why I Transferred My Domains From Godaddy to Namesilo
Tags: tech, cloud, technology, hosting
Published: 2019-11-29 22:39:04

---
title: Why I Transferred My Domains From Godaddy to Namesilo
published: true
date: 2019-11-22 18:09:52 UTC
tags: tech,cloud,technology,hosting
canonical_url: https://medium.com/@geeksamu/why-i-transferred-my-domains-from-godaddy-to-namesilo-e231912e4466
---

### **Why I Transferred My Domains From GoDaddy to Namesilo**

![](https://cdn-images-1.medium.com/max/1024/1*KD0PWlRKFuUnpk92CnT9Uw.png)

> 2 Gifts at the end of the Article.

I have been using Godaddy for more than 6 years, I bought more than 100 domains on it. Before I left I had 10+ domains on Godaddy. Here’s the receipt of the first domain I bought from Godaddy

![](https://cdn-images-1.medium.com/max/1024/1*i4BYH1Rgkb6VosFef8ttzQ.png)

It’s 6 years and 2 months ago. That Domain cost me about $1 at that time with a coupon (about 8EGP in my country's currency at that time).

At the time of this receipt, the regular price of a .com domain was $10 and the same for the renewal. I noticed that Godaddy is increasing the renewal price of domains every year but It didn't matter to me till I found that it was increasing by %20 over the 2018 price of$14.99.

In February 2019 I renewed a .org domain for $21.17, I thought It was expensive because it's a 3 letter domain. But when I tried to renew my .com normal domains I found it will cost me $18.17.

I made a google search and found out that only GoDaddy was increasing its prices.

So I had to look for a better and cheaper provider after checking many reviews I found that [NameSilo](https://bit.ly/349Ra8U) is the best one and cheaper than Godaddy and even other providers. Check the prices at NameSilo here: [NameSilo Pricing](https://bit.ly/35rF7Ea)

Here are some comparisons between [NameSilo](https://bit.ly/349Ra8U) and Godaddy:

### Pricing

{% gist https://gist.github.com/geeksamu/4eefbd814b92a003005288b2189aa2d7 %}

What really matters to me from this comparison:

- Price of registration.
- Price of renewal.
- WHOIS Privacy.
- 30 Days period for renewing expired domains.
- Accepts Bitcoin

This will save me about 40% of the cost for each year as I pay for many domains renewal.

### The First Gift

The good part here and the gift for you guys is that you can transfer your domain at that low price and a $1 discount for each domain all you need is to use one of these coupons

medium1usd

or

mediumcoupon

So now If you are going to buy a.com domain from [NameSilo](https://bit.ly/349Ra8U) you will save $7 per domain with the discount coupons medium1usd , mediumcoupon

### The Second gift

If you’re looking for free hosting for your websites here’s a [$50 in FREE Hosting Credit on DigitalOcean](http://bit.ly/2B5ReJR)