teleren/devto huggingface dataset:
Django: Moving away from project vs app dichotomy
Tags: django, python
Published: 2018-04-08 05:43:49

---
title: Django: Moving away from project vs app dichotomy
published: true
description: Project vs App is unnecessary confusion introduced very early without much tangible benefit.
tags: django, python
---

I was looking at one of exercise of a developer learning how to build app using Django. His directory structure look like this:-

```
ceri main manage.py ...
```

`ceri` is the chosen name for this project. But looking deeper in each directory, you'll see that `ceri` contain only `settings.py` while in `main` there's `views.py`, `models.py` etc. Directory `main` basically the meat of this application. I'm baffled looking at this.

They probably following Django tutorial and start with:-

```
django-admin startproject ceri
```

Since the "project", at business level is called "ceri", it's logical for this developer to run `startproject` using "ceri" as well. But then he came to next thing the tutorial ask him to do:-

```
django-admin startapp ...
```

My guess is the dev will stuck for a while thinking for the appropriate name. Giving up, he just pick "main" for the name.

This "app" vs "project" IMHO is unnecessary to the beginner. There's nothing that prevent you from putting all your views and models in `ceri` directory but newbie to Django will be given impression that these "project" vs "app" is required thing. The argument for this is to encourage writing reusable apps from the beginning. If you write your "app" generic enough, you can just plug that app into another project.

But 80% of the time, you'll just writing app that specific to that project. Most often, people will pick a generic name for their apps such as "user", "order", "customer" etc, convulating the top namespace. I bet that they will hit situation where third party package they want to use clash with their generically named app first than a situation where they want to reuse their app.

It's not that developer should be discouraged from writing generic app but this can be introduced at later chapter. We can reduced confusion and this kind of [question](https://stackoverflow.com/questions/19350785/what-s-the-difference-between-a-project-and-an-app-in-django-world) at Stackoverflow.
let over const
Tags: javascript, programming, discuss
Published: 2018-04-08 03:11:39

---
title: let over const
published: true
description: 
tags: js, programming, discuss
---

What is the difference between let and const and when should we use one instead of other?

I was seeing a thread on twitter of folks discussing about that... Have a look at those pictures and pls help to understand...

![](https://thepracticaldev.s3.amazonaws.com/i/889o0sw7coj18cbdbdxe.jpg)

![](https://thepracticaldev.s3.amazonaws.com/i/r8t95dbb5aj885vm6b4n.jpg)
Possible dev.to bug: Can't comment on mobile
Tags: bug, platform, feedback
Published: 2018-04-07 21:11:51

---
title: Possible dev.to bug: Can't comment on mobile
published: true
description: iOS Safari is broken 💔
tags: bug, platform, feedback
---

Hey dev.to team, I can't really comment on my phone. What are the best steps to take?

Just left out formalities so you see my point straight, I hope you are having a great weekend.

I'm on iOS latest (beta) - ~11.3 and the Safari coming with that version.
Commenting works fine on my computer, I tried logging in and out on my phone but no luck. What do I do wrong? Is it only broken for me?

Thanks for the help in advance, I hope this is the best way to report bugs, if not let me know how.
RESTful Security: Plug the Leaks!
Tags: rest, api, security
Published: 2018-04-07 21:03:02

---
title: RESTful Security: Plug the Leaks!
published: true
description: Don't leak information through HTTP error codes.
tags: rest, api, security
---

TL;DR: Don't leak information through HTTP error codes.

Here is a possible vulnerability that is probably not very serious but easy to overlook.  Suppose we get hired to redo a local bank's website.  Being the hip coders that we are, we decide to make a nice RESTful API.

One of our API's operations is the following:

```
GET /api/accounts/{acctId}
```

Of course, this operation succeeds only if an account with ID `acctID` exists and the request contains valid credentials for the customer that owns that account.  If one of these conditions does not hold, we return an appropriate HTTP error code.

What should that error code be?  We know that RESTful APIs return the most appropriate status code for the situation.  So, it seems to make sense to return 404 when the account doesn't exist, and 401 when it does but the user is unauthenticated or isn't its owner.  

But this may well be a bad idea, because an unauthenticated user can now do something like this:

```
$ for i in `seq 300 305`; do curl -sI https://exammple.com/api/accounts/${i} | head -n 1; done
HTTP/1.1 404 Not Found
HTTP/1.1 401 Unauthorized
HTTP/1.1 401 Unauthorized
HTTP/1.1 404 Not Found
HTTP/1.1 401 Unauthorized
HTTP/1.1 404 Not Found
```

This unauthenticated user has now learned something: that there are no accounts with IDs 300, 303, and 305, but there are with IDs 301, 302, and 304.  And of course running this command with a wider range of IDs would reveal even more information.

How bad is this?  That depends on a lot of other things; at this point, the most we can say is that it is not obviously terrible.  But still, this could be used to learn other things --- for example, the rate at which new accounts are created, which might be interesting to a competitor.

The important point is that this API leaks information to users that have no legitimate reason to have it.  And it is easy to fix: we should just return 404 even if the account does in fact exist.

## Conclusion

While we focus on the obvious security concerns --- keeping account balances secret, preventing unauthorized transactions --- it is easy to overlook how the behavior of our system leaks sensitive information.

An attacker's goal is to gain information about the state of our system by observing its behavior.  So our job is to make sure that the system behaves (from the attacker's point of view) identically regardless of its state.  And remember: unauthenticated users are not the only potential attackers.  Even logged-in customers should get 404 in response to requests for accounts that they don't own.
Sorry about some brief down time 😵
Tags: meta
Published: 2018-04-07 19:59:05

---
title: Sorry about some brief down time 😵
published: true
description: 
tags: meta
---

We had the site go in some regions down for about 30 mins but if you're reading this, we're back online now.

{% tweet 982705651615870977 %}

Have a nice Saturday!
ASP .NET Core shared Current User
Tags: beginners, netcore, aspnetcore, csharp
Published: 2018-04-07 16:57:38

---
title: ASP .NET Core shared Current User
published: true
description: ASP .NET Core shared Current User example
tags: beginners, netcore, aspnetcore, csharp
---

As a quick update to the previous article explaining how to set up [JWT and Identity](https://dev.to/coolgoose/setting-up-jwt-and-identity-authorizationauthentication-in-asp-net-core-4l45) I've updated the `currentUser` method to use dependency injection.

```csharp
namespace Craidd.Extensions {
    public static class IHttpContextAccessorExtension
    {
        public static async Task<User> CurrentUser(this IHttpContextAccessor httpContextAccessor)
        {
            IUsersService users = httpContextAccessor.HttpContext.RequestServices.GetService(typeof(IUsersService)) as IUsersService;
            return await users.UserManager.GetUserAsync(httpContextAccessor.HttpContext.User);
        }
    }
}
```

In my case, IUsersService is a wrapper that contains dbContext, UserManager and SignInManager.

```csharp
namespace Craidd.Services
{
    public class UsersService: IUsersService
    {
        private readonly AppDbContext _dbContext;
        private readonly UserManager<User> _userManager;
        private readonly SignInManager<User> _signInManager;

        public UsersService(
            AppDbContext context,
            UserManager<User> userManager,
            SignInManager<User> signInManager
        )
        {
            _dbContext = context;
            _userManager = userManager;
            _signInManager = signInManager;
        }

        public UserManager<User> UserManager => _userManager;
        public SignInManager<User> SignInManager => _signInManager;
    }
}
```
Now in your controller you can easily access the method by injecting httpContext. 
I'm currently using it to quickly return the logged in user data for the [Nuxt.js Auth Module](https://auth.nuxtjs.org/)

```csharp
[HttpGet]
public IActionResult Index()
{
    return Json(new { user = _httpContext.CurrentUser() });
}
```
Which Payment Platform is suitable for a hobby dev project ?
Tags: askdev
Published: 2018-04-07 16:53:37

---
title: Which Payment Platform is suitable for a hobby dev project ?
published: true
description: 
tags: askdev
---

I am developing a  project in my free time, that requires a subscription based service . 

To start a production ready payment gateway interface, Companies like Stripe and Razorpay requires Business license .

The currently working thing is PayPal. I'm looking for alternatives.


My question is
 **Is there any payment gateway that doesn't require Business license and also supports payments for International Transactions ?**
How do you deal with burnout and low motivation? 
Tags: career, discuss, motivation
Published: 2018-04-07 14:42:55

---
title: How do you deal with burnout and low motivation? 
published: true
description: 
tags: career, discuss, motivation 
---
The past few months have been a no-code zone for me. I've literally gotten nothing done with Java. Most of that attributes to my being so busy writing papers for school, and my degree will be complete after my current course. It focused mainly on the documentation rather than actual code. I've been a bit overwhelmed and when I did have time to code, I just didn't. I was burned out. My candle was down to the nub.

I had a much needed break and am motivated again, but is there  any advice for preventing this burnout from happening again? I don't want to waste another 3 months ever again.
8 Types of Sensors that Coalesce Perfectly with an IoT App
Tags: blog, internetofthings, iot, iotapp
Published: 2018-04-12 11:51:51

---
title: 8 Types of Sensors that Coalesce Perfectly with an IoT App
published: true
tags: Blog,Internet of Things,IoT,IoT App
canonical_url: 
---
![](https://www.itfirms.co/wp-content/uploads/2018/04/Types-of-Sensors-that-Coalesce-perfectly-with-an-IoT-App.jpg)
What is that one factor that separates a human from normal living beings? Or what is that one factor that insisted humans to make the machines smarter? Well, it is their curious thinking that made them imagine, experiment and innovate with existing technologies and develop new ones. As roses will never remain same without thorns, likewise an IoT network cannot remain unarmed with sensor troops. Take a look at how various sensors are cockled together in IoT universe: [https://www.itfirms.co/8-types-of-sensors-that-coalesce-perfectly-with-an-iot-app/](https://www.itfirms.co/8-types-of-sensors-that-coalesce-perfectly-with-an-iot-app/)
How Does Jotting Down Behavioral Policy Refine Android App Development?
Published: 2018-04-07 11:21:10

---
title: How Does Jotting Down Behavioral Policy Refine Android App Development?
published: true
description: 
tags: 
---
![](https://www.itfirms.co/wp-content/uploads/2018/03/How-does-Jotting-down-Behavioral-Policy-Refine-Android-App-Development.jpg)
Change is inevitable but needs to be propelled in the right direction. Cheat the competition before they get a chance to knack you. The customer is king. Mobile App Developers have to provide them what they need in just the right proportion at just the right time. More: [https://www.itfirms.co/how-does-jotting-down-behavioral-policy-refine-android-app-development/](https://www.itfirms.co/how-does-jotting-down-behavioral-policy-refine-android-app-development/)
Benefits of Outsourcing To a Web Development Company in India
Published: 2018-04-07 11:14:32

---
title: Benefits of Outsourcing To a Web Development Company in India
published: true
tags: 
---
![](https://www.itfirms.co/wp-content/uploads/2018/03/Benefits-of-outsourcing-To-a-Web-Development-Company-in-India.jpg)
When someone is looking for outsourcing for web development then why India is the best for the same. Here the answer: [https://www.itfirms.co/benefits-of-outsourcing-to-a-web-development-company-in-india/](https://www.itfirms.co/benefits-of-outsourcing-to-a-web-development-company-in-india/)
How to install the latest stable PHP 7.2 in Ubuntu Linux.
Tags: howto, internet, linux, opensource
Published: 2018-04-07 09:16:33

---
title: How to install the latest stable PHP 7.2 in Ubuntu Linux.
published: true
tags: HowTo,Internet,Linux,open source
canonical_url: https://fossnaija.com/install-php-7-in-ubuntu-linux/
---

In this post I’m going to show you how to install PHP 7.2 in Ubuntu 16.04 system. Beginning with Ubuntu 16.04, PHP 7 has replaced PHP 5 as the default PHP version in the Ubuntu software repository. And can be installed by simply using the command: sudo apt-get install php7 But PHP 7.2 is the… [Read More »](https://fossnaija.com/install-php-7-in-ubuntu-linux/)

The post [How to install the latest stable PHP 7.2 in Ubuntu Linux.](https://fossnaija.com/install-php-7-in-ubuntu-linux/) appeared first on [Foss Naija](https://fossnaija.com).
How to avoid (or escape) async/await hell
Published: 2018-04-07 05:32:52

---
title: How to avoid (or escape) async/await hell
published: true
description: have you started using async/await? If so be careful as you may have unknowingly crippled the performance of your application.
---


have you started using async/await? If so be careful as you may have unknowingly crippled the performance of your application. See if this is the case [here](https://medium.freecodecamp.org/avoiding-the-async-await-hell-c77a0fb71c4c)
How do you think about javascript framework (or library) scaling?
Tags: discuss, javascript, react, vue
Published: 2018-04-07 05:25:17

---
title: How do you think about javascript framework (or library) scaling?
published: true
tags: discuss, javascript, react, vue
---

I'm Japanese developer.
In Japan, the popularity of `Vue.js` is increasing.

I have experience that created some web application with `React` in production environments (sometimes with `Redux`).

Recently, I used `Vue.js` too.

In I created application with `Vue.js` , thought of this in this time.

"`Vue.js` is not easy to create (and maintained) with many people or large scale code?"

I feel `React` has good as scalable and robustness.
`Redux` has some dull point (redundancy, boilerplate) but it's make even if anyone writes it will be a similar code. 
In addition, `React` is so friendly to typed system (like flow or typescript).

`Vue.js` is very easy to setup, and it's provide some implement patterns, like $computed, $el, mixin, emit, `Vue.use`, directive, etc. 
It's make　flexibility, but it's enable to make confusable in the team if with a number of developer.
I feel that if we developed `Vue.js` with multiple people, we have to set many of the rules.

I don't know about `Angular`, but it's feel large scale is good but it's hard to small application.

How about do you think about javascript application scaling in production?
And if you can, tell me your generated production application scale (code size, number of developer, etc..).
How CSS Specificity Works🤹🏼‍♀️
Tags: css, javascript, webdev, beginners
Published: 2018-04-07 02:49:47

---
title: How CSS Specificity Works🤹🏼‍♀️
published: true
description: how CSS specificity works and css weights
tags: css,javascript,webdev,beginners
cover_image: https://cdn.pixabay.com/photo/2018/02/06/21/56/animal-3135791_960_720.jpg
---



We already know CSS stands for the cascading style sheets.

What the  **Cascading** really mean is the browser first resolves the which stylesheet need to be applied to the HTML.Like we see blue color to the 
links which come by the browser default.

Let's talk about the **Specificity**

**Specificity** is the weights applied to the CSS when we declared.

Weights really mean how we are applying a style to the particular HTML 
element.

Like we are using id attributes to target the Html element or  we used
class attributes sometimes we used direct element name like h1, p to apply
the styles.

Here the specificity comes in we are applying the styles using different selectors.
But browser applies styles to an element based on their weights.

**In weights**
- First is inline CSS 
- Second id 
- Third class  
- Fourth Elements/Pseudo classes/Pseudo selectors

If We apply styles to the element with any selectors we have.If we just place an inline CSS it overrides the all styles which are before applied by using id, class, element.

# (Important is never recommended)
If we add !important to the any of our selectors. Important overrides all of the other styles before we added to that element.

Check out in code pen I showed it clearly fork this pen and see the changes by removing important, inline CSS, id etc...


{% codepen https://codepen.io/saigowthamr/pen/KorNZa %}


[Find me on Twitter](https://twitter.com/saigowthamr)
Mastering sales as a CTO
Tags: learning, career, leadership
Published: 2018-04-07 02:02:07

---
title: Mastering sales as a CTO
published: true
description: Most careers turn into sales jobs when you get senior enough. Here is what I learned in sales.
tags: #learning, #career, #leadership
---

_Read the full article at my [site](https://jjude.com/cto-sales/)_


Two years back, I became a CTO of an offshore IT services company. Part of the job is to get on sales calls to build trust in the minds of prospects to do business with us.


When I started attending sales calls, I thought I could just say we are a well established IT services company and prospects will just sign-up for our services. How naive!

Now I prepare relentlessly. **Preparation builds confidence and confidence wins trust**. I prepare by asking questions. Here are some questions that help me prepare for sales calls.

* What are we selling?
* How are we different?
* What are the objections?
* Have we practiced together?
* Who is the prospect?
* Do we have examples?
* What can go wrong?

Once I'm prepared, I am ready for the calls. I take a note and a pen with me for calls. As the call proceeds, I take notes. **I listen for signals**. I scribble anything that will help me during the course of the call.

After every call, I write notes about the call. I note down what went well as well as what went wrong.

The more we prepare, play, and retrospect together, we get better together.

When we strive together, we thrive together. And then we become lucky. Because one-half of life is luck; the other half is preparation.
Explain Pseudocode
Tags: pseudocode, help
Published: 2018-04-06 21:15:21

---
title: Explain Pseudocode
published: true
description: I have some questions about pseudocode... can anyone explain?
tags: pseudocode, help
---

Okay. I've just started learning Python, and I'm finding it way easier to understand than pseudocode. This post is less of a serious debate, and more of a search to satisfy my curiosity.

Normally I come up with an idea and jump into coding it without much planning, so before now writing pseudocode was an unknown to me. I've done a bit of googling, and the basic concept is simple enough - "pseudo" (fake) code, written in plain English, so that it can easily be converted to almost any language by developers. Makes sense.

Now, my problem is the syntax. Does it actually have any agreed upon / recommended syntax, or is it literally just write whatever? If it does have recommended syntax that the majority of devs agree on, then what would that be? Most things I've found online have maybe one or two sentences about pseudocode and are mostly about flowcharts, or seem to be in complete disagreement with each other.

Take, for example, this simple Python script that flips a coin:
```py
# import modules
import random
import time

# flip coin
def flip():
    coin = ''
    rand = bool(random.getrandbits(1))
    if rand:
        coin = 'heads'
    else:
        coin = 'tails'
    return coin

# allow for multiple games
playagain = 'Y'
while playagain.lower() in {'y', 'yes', ''}:
    print('The coin spins in midair...')
    time.sleep(1)
    print('...and lands on \033[1m' + flip() + '\033[0m!')
    playagain = input('\nDo you wish to flip the coin again (Y/N)? ')
```

I've attempted to write some pseudocode for this. Which one of the below would people say is better? Could anyone demonstrate how they would write pseudocode for this?
```
# attempt 1

set playagain to yes
while (playagain is y, yes, or an empty string (ignoring capitalisation)) do
    tell user the coins spins in midair
    wait 1 second
    run function "flip"
        set rand to a randomly generated booleen (true/false)
        if (rand is true)
            set coin to heads
        else (rand is false)
            set coin to tails
        return coin
    tell user what the result of "flip" was
    ask user if they want to play more games and set playagain to user response

# attempt 2

FUNCTION flip() =
    rand = random booleen
    if (rand)
        coin = heads
    else
        coin = tails
    return coin

playagain = yes
while (playagain == y, yes, or an empty string (ignoring capitalisation)) do
    output "The coin spins in midair..."
    sleep 1 second
    ouput "...and lands on " flip()
    output "Do you wish to flip the coin again (Y/N)?"
    playagain = input
```

This may seem ridiculous to the majority of you, but I would appreciate any help!
Testing this stuff
Tags: test, ceotryingdevto, development
Published: 2018-04-06 19:58:43

---
title: Testing this stuff
published: true
description: Let's start blogging here like a pro. Or something like that.
tags: test, ceo trying dev.to, development
---

I wanted to try blogging in general and blogging on this platform a lot for a while. My guess is this is the moment of truth when I get to do this because I have a little free time.

I just realized how beautiful the font in the text editor of dev.to looks. Lucida Console is something I'll have to use later on in some of my projects too for sure.

See you guys with a bit more in-depth update the next time. This looks fun, I should really build this into my morning routine.
Should I go for JS or Python in long run in my career?
Tags: javascript, python, discuss
Published: 2018-04-06 18:31:20

---
title: Should I go for JS or Python in long run in my career?
published: true
description: 
tags: javascript, python, discuss
---

I've been preparing for jobs in mostly web development here in India, and I've been learning DS & Algorithms with Python also Library & frameworks like Node.js and jQuery So I wonder should I go with JavaScript full way or Python (sometimes I think I like Python a bit more over JavaScript, though I know JAVA and C as well.
Suggestions for using `...arguments` while working with functions in javascript.
Tags: discuss, javascript, webdev, codingpractice
Published: 2018-04-06 17:29:22

---
title: Suggestions for using `...arguments` while working with functions in javascript.
published: true
tags: discuss, js, webdev, codingpractice
---

In many situations, using `arguments` to pass the function args would lead to bugs as we totally unaware the actual args. When to use these such notations and when not to?