teleren/devto huggingface dataset:
Django Console tip: autoload your models
Tags: python, django
Published: 2019-08-25 20:14:27


# Django console tip:  autoload your models

Several times per day I would open the Django console to check some values from my models.  I would type something like: 

```
Post.objects.filter(user=User.objects.last(), state='published').count()
```

Only to greeted with:

```
Traceback (most recent call last):
  File "&lt;input&gt;", line 1, in &lt;module&gt;
NameError: name 'Post' is not defined
```

Of course I forgot to import the required models:

```
from users.models import User
from blog.models import Post
Post.objects.filter(user=User.objects.last(), state='published').count()
4
```

Wouldn't it be nice to have it all automatically loaded when you open the console, the way it works in rails?<br>Luckily it is easy to do, all that is required is to add a few lines that execute when the console starts up:

```
from django.apps import apps

for _class in apps.get_models():
    globals()[_class.__name__] = _class
```

If you use PyCharm then you can set it up from `settings`-&gt;`Build, Execution, Deployment` -&gt;`Console`-&gt;`Django Console`

<img src="https://res.cloudinary.com/ximg/image/upload/w_732,h_500,c_limit/f_auto/whoami/4a595384/post/b5yt1Vlaj4LXkxIf.png"><figcaption>Django Console settings in PyCharm</figcaption>

And voila, from now on all your models are ready to use when you start.

```
Post.objects.filter(user=User.objects.last(), state='published').count()
4
```

<small>Originally posted at https://loftie.com/post/django-console-tip</small>
Reactgate Recap
Tags: react, javascript
Published: 2019-08-25 19:31:13

# Series of Events
0. A take on [Vue developers vs. React developers](https://twitter.com/heydonworks/status/1164506235518910464) is tweeted.
{% twitter 1164506235518910464 %}
1. A number of the deleted posts in the thread above is from Dan Abramov (defending the React community).
2. A [subtweet](https://twitter.com/tesseralis/status/1165111494062641152) (thread) directed at Ken Wheeler describes how his behavior is viewed as toxic by marginalized people.
{% twitter 1165111494062641152 %}
3. [heydonworks](https://twitter.com/heydonworks) described how Ken Wheeler played ["the circle game"](https://www.dictionary.com/e/slang/circle-game/) at a React conference. The circle game gesture is very similar to the ["Okay Hand Gesture"](https://www.adl.org/education/references/hate-symbols/okay-hand-gesture) that has become a symbol amongst white supremacists. This tweet has since been deleted.
4. Tatiana Mac calls out React developers for trying to protect React's integrity rather than listen to its users.
{% twitter 1164912554876891137 %}
4. Ken Wheeler, in [this tweet](https://twitter.com/ken_wheeler/status/1164934308366340096), tries to clear up the misunderstanding.
{% twitter 1164934308366340096 %}
5. Dan Abramov [deactivates his Twitter](https://twitter.com/dan_abramov/status/1165431134378975232).
{% twitter 1165431134378975232 %}
7. heydonworks tries to fix the damage done in the above tweet with [this tweet](https://twitter.com/heydonworks/status/1165439718512824320).
{% twitter 1165439718512824320 %}
8. [Tatiana Mac quits the industry due to all this](https://twitter.com/TatianaTMac/status/1165456607729180673).
{% twitter 1165456607729180673 %}
8. Dan Abramov [explains that he's fine on Reddit](https://www.reddit.com/r/reactjs/comments/cv3jcp/dan_abramov_deactivates_twitter_account/ey2bpab/).
9. Dan Abramov [rejoins Twitter](https://twitter.com/dan_abramov/status/1166333416272486400).
{% twitter 1166333416272486400 %}
10. Tatiana Mac [posts a factual account on, what is now termed as, #Reactgate](https://docs.google.com/document/d/1g4oh2GGZOsucZfT1YJ5wjDUSk3ntbM3RNAxVs528-NM).
{% twitter 1166348406840864773 %}
11. [#Reactgate](https://twitter.com/search?q=%23Reactgate) becomes a topic on Twitter.
🏝 Remote Work “Office Hours”
Tags: career, remotework, webdev
Published: 2019-08-25 19:28:12

---
title: 🏝 Remote Work “Office Hours”
published: true
description: Today I’m excited to announce my new initiative - Remote Work “Office Hours.” I will be dedicating 2-3 hours every week (20 min time slots) to answer your questions about working remotely as a developer. It’s completely free and aims to help everyone who wants to learn more about remote work.
tags: career, remotework, webdev
cover_image: https://tik.dev/static/0d3c7274796a8c5867d31ceaae4710d9/97f0b/tigran-hawaii.jpg
canonical_url: https://tik.dev/office-hours
---

## Who am I?

My name is [Tigran](https://tik.dev), and I’m a software engineer at [Buffer](https://buffer.com). Buffer is a remote company with no office. I’ve been working remotely for almost four years now and learned a lot about remote work. Last year I wrote a [popular article](https://medium.com/free-code-camp/reflections-on-being-a-remote-developer-757465ed1e9e) where I shared my reflections on being a remote developer. In my free time, I like playing soccer, writing, and working on my [side-project](https://cronhub.io).


## Why “office hours”?
After writing my article about remote work, I started to receive many emails asking questions about my experience of being a remote developer. I hope I can help and share everything I know and learned about remote work. I know it’s a significant lifestyle change when you decide to work remotely, and I hope to help even a little to ease that decision.

## Who should attend?
I’m a developer, and I base my remote experience on the type of work I do every day. Knowing what I know, I think I can be the most helpful to people who are in tech and especially developers.

Here is a group of people that I have in mind:
- Developers who are not sure whether remote work will be a good fit for them
- Developers who work remotely and want to be better at it
- Developers who want to find a remote job

## What’s the structure of the “Office Hours”?
Please introduce yourself first. Like any other “office hours” I expect you to come with your questions and I’ll try to answer them the best I can.

## How do I sign up?
You can grab an available time slot on my [Calendly schedule](https://calendly.com/tigranh/remote-work-office-hours-with-tigran). All calls will be video calls on [Zoom](https://zoom.us). Please make sure you downloaded and installed Zoom prior our calls. The meeting link will be in the calendar invite.

## How much time do I have?
I want to keep it for 20 minutes.

## Are you doing this by yourself?
Yes. However, I might have surprise guests on some days.

## Do I have to pay for this?
No. It’s completely free.

Thank you! I hope this is useful :)
React Run Error (solution)
Tags: react, reactnative, npm
Published: 2019-08-25 19:26:04


The react files I created recently stopped working. I've done a lot of research and finally I have a solution. Probably not the only solution. I have a lot of different solutions. I'm just gonna show you one. If there is a different solution that you know, mention it in the comments.

**Problem:**
![](https://i.stack.imgur.com/THAj5.png)
--
**Solution:**
Enter the 'Users' file in your own user file. And delete the node_modules file inside this file. Ninety percent of the problem will be solved. This is because the react library is constantly updated.
Differences between "var" and "let" keywords?
Tags: javascript, webdev, todayilearned, beginners
Published: 2019-08-25 18:52:00

_This post will be the first of a large series of small posts that will cover some questions you are likely to come across during your job interviews._

_I'll be more focused on JavaScript but there will be some posts about HTML , CSS and React JS in the future !_

Ok , let's get started !

## **_Difference nr 1!_**

**"var"** was introduced in JavaScript from the beginning while **"let"** was introduced in ES2015/ES6.

## **_Difference n 2!_**

**"Let"** has a <u>block scope</u> while **"var"** as a <u>function scope</u>

Let's see this example


```javascript
let x = function() {

  if(true) {
    var v = 2;
    let l = 1;
  }

  console.log(v);
  --> 2
  console.log(l);
  --> Uncaught Reference: l is not defined
}

x();
```

The console.log of the variable v will return 2 because of the function scope of the **"var"** keyword while the l variable will return an error because of the block scope of the **"let"** keyword.

## **_Difference n 3!_**

Variables defined with **"var"** <u>gets hoisted</u> at the top of his function while variables defined with **"let"** <u>don't get hoisted</u>.

```javascript
let x = function() {

  if(true) {
    console.log(v);
    --> undefined
    console.log(l);
    --> Uncaught Reference: l is not defined

    var v = 2;
    let l = 1;
  }
}

x();
```

In this case the variable v will return undefined while the l variable will return an error, this happens because declarations using **var** are <u>hoisted / lifted</u> to the top of their functional/local scope (if declared inside a function) or to the top of their global scope (if declared outside of a function) regardless of where the actual declaration has been made.

_That's it ! nothing too complicated but it's important to keep these concepts fresh in your minds._

_See you soon for more tips !_
NodeJS: How To Use The OS Module
Tags: javascript, node, eli5
Published: 2019-08-25 18:47:59

---
title: NodeJS: How To Use The OS Module
published: true
description: How To Use The OS Module
tags: javascript, node, eli5
series: Intro to NodeJS
---

## Intro

So we [installed NodeJS](https://dev.to/miku86/what-is-nodejs-how-to-install-it-1900) on our machine.

Now we want to learn how to get information about the operating system by using the [OS module](https://nodejs.org/api/os.html).

## Write a simple script

- Open your terminal
- Create a file named `index.js`:

```sh
touch index.js
```

- Add this JavaScript code into it:

```js
const { platform, arch, release, totalmem, freemem } = require('os');

console.log(`Your Operating System: ${release()} ${platform()} ${arch()}`);
console.log(`${((freemem() / totalmem()) * 100).toFixed(2)} % of your RAM is free.`);
```

Note: I use the most used url properties to decrease the complexity of this simple example. To see all the available properties, read [the docs of the OS module](https://nodejs.org/api/os.html#os_os). There is a lot of cool stuff.

---


## Every line explained

```js
/*
  import the os module & destructure the desired properties/functions
  similar to:
  const os = require('os');
  const { platform, arch, release, totalmem, freemem } = os;
*/ 
const { platform, arch, release, totalmem, freemem } = require('os');

// log some information about the operating system
console.log(`Your Operating System: ${release()} ${platform()} ${arch()}`);

// log some information about the memory (ram) (number is rounded to two decimals)
console.log(`${((freemem() / totalmem()) * 100).toFixed(2)} % of your RAM is free.`);

```

---

## Run it from the terminal

- Run it: 

```sh
node index.js
```

- Result: 

```sh
Your Operating System: 5.2.9-arch1-1-ARCH linux x64
18.63 % of your RAM is free. 

```

---

## Further Reading

- [OS module](https://nodejs.org/api/os.html)
- [OS properties overview](https://nodejs.org/api/os.html#os_os)

---

## Questions

- Do you have an interesting idea, what we could create with this module?
Trim Unnecessary Files From Git History ✂️🗃️
Tags: developer, git, github, tutorial
Published: 2020-06-21 07:41:45

---
title: Trim Unnecessary Files From Git History ✂️🗃️
published: true
date: 2019-08-25 18:28:00 UTC
tags: developer,git,github,tutorial
canonical_url: https://2kabhishek.blogspot.com/2019/08/trim-unnecessary-files-from-git-history.html
---

[![](https://lh3.googleusercontent.com/--G7Wq_WuQVQ/XZSGWJvWdXI/AAAAAAAALV8/Np9dtchtJy0Z7g17k9mucUYtXyN_6nwVgCLcBGAsYHQ/s640/1570014791417687-0.png)](https://lh3.googleusercontent.com/--G7Wq_WuQVQ/XZSGWJvWdXI/AAAAAAAALV8/Np9dtchtJy0Z7g17k9mucUYtXyN_6nwVgCLcBGAsYHQ/s1600/1570014791417687-0.png)
  

Here's a common scenario, You have committed a file to your git repo and have also pushed to remote. 

The file wasn't supposed to be there, maybe it was something you forgot to mention in your `gitignore` or something that was supposed to be an environment variable or maybe it was a binary not related to the project at all ( Cat GIFs? 😉).  
  
This not only raises some security concerns but also drives the  size of your repository up and simply deleting the file won't fix the problem.

  
Here's how to fix it using a few commands:  
  

1) Clone your repo and make sure all branches are up-to-date with remote.  
  

2) Identity the filename and its path that you want to remove.  
  

3) Then using git filter-branch remove the files from history   
  
```bash
git filter-branch --tag-name-filter cat --index-filter \ "git rm -r --cached --ignore-unmatch filename****" --prune-empty -f -- --all
```

4) Remove the files from the local repo.  
  
```bash
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
```

5) Push your changes to remote.  

```bash
git push origin --force --all
git push origin --force --tag
```

6) Make sure anyone else with a local clone of this repo either uses **git rebase** or a fresh clone, to avoid restoring the repo to earlier state.  
  

If this seems too much to got through you can also use a program I wrote to solve this problem : 
## Gitrim
{% github https://github.com/2kabhishek/gitrim/ %}  
  
Gitrim also has a feature to list out the objects which are taking the highest space in the .git directory.  
  

That's all, see you in the next one.
There's also other alternatives git filter-repo and BFG repo cleaner, you can look into those too.
An introduction to Coding Challenges
Tags: beginners, tutorial, go, javascript
Published: 2019-10-09 06:29:49

---
title: An introduction to Coding Challenges
published: true
tags: beginners, tutorial, go, javascript
canonical_url: https://www.codetips.co.uk/an-introduction-to-coding-challenges/
---

 ![An introduction to Coding Challenges](https://www.codetips.co.uk/content/images/2019/08/olav_ahrens_rotne_ma_x6tYr.jpg)

---

[CodeTips](https://www.codetips.co.uk) strives to help beginners, with zero or very little experience, learn to code.

We do cross-post to other sites to reach a wider audience, but why not [subscribe to our newsletter](https://mailchi.mp/92cccf7024b2/codetips) and get the newest articles straight to your mailbox? 

The original source for this content is [CodeTips](https://www.codetips.co.uk). The original content is kept up-to-date, but other sources may not be the latest version. 

---

Welcome to CodeTips newest section - Coding Challenges!

We wanted to give you an introduction to this section because it's completely different from everything we've done up to this point.

Up to now, we've covered general [beginner](https://www.codetips.co.uk/tag/beginner/) and [intermediate](https://www.codetips.co.uk/tag/intermediate/) programming concepts, and we've covered language-specific tutorials for [Go](https://www.codetips.co.uk/tag/go/), [JavaScript](https://www.codetips.co.uk/tag/javascript/) and [Python](https://www.codetips.co.uk/tag/python/).

One skill programmers must have is problem-solving, which is why you'll often find coding challenges in interviews. A big part of our role is to take a problem/requirement and find the best way to fix/implement it. That's exactly what this section is about.

In each article, we'll look at a different coding challenge, and we'll show you how to complete it using different languages.

The articles in this section expect some prior knowledge of programming, so be sure to refer to the [beginner](https://www.codetips.co.uk/tag/beginner/) and language-specific articles if you get stuck.  

If there's a specific coding challenge you'd like us to write about, you get stuck along the way, or you have any feedback about this section, you can always [get in touch with us](https://www.codetips.co.uk/contact-us/)!

---

[CodeTips](https://www.codetips.co.uk) strives to help beginners, with zero or very little experience, learn to code.

We do cross-post to other sites to reach a wider audience, but why not [subscribe to our newsletter](https://mailchi.mp/92cccf7024b2/codetips) and get the newest articles straight to your mailbox? 

The original source for this content is [CodeTips](https://www.codetips.co.uk). The original content is kept up-to-date, but other sources may not be the latest version.
Job Search Resources and Tips
Tags: beginners, career
Published: 2019-08-25 16:46:53

---
title: Job Search Resources and Tips
published: true
description: How I am tackling my job search for a junior software engineer role
tags:  beginners, career
---

As a former bootcamp graduate I have been attempting to cast a wide net in my job search. In doing so I have compiled a list of resources and tips that I have been utilizing which I hope is helpful for others in a similar position.

# Job Boards/Networks
- [Angel.co](https://angel.co/)
- [Hire Tech Ladies](https://www.hiretechladies.com/jobs)
- [Elpha](https://elpha.com/top)
- [Glassdoor](https://www.glassdoor.com/index.htm)
- [LinkedIn](https://www.linkedin.com/jobs/)
- [Unicornboard](https://unicornboard.com/)

# Skills-Based Recruiting 
- [Triplebyte](https://triplebyte.com/)
- [Hatchways](https://www.hatchways.io/#/)

# Interview Prep
- [LeetCode](https://leetcode.com/problemset/all/)
- [HackerRank](https://www.hackerrank.com/)
- [CodeWars](https://www.codewars.com/)
- [Tech Interview Handbook](https://yangshun.github.io/tech-interview-handbook/)
- [Check out my approach to technical interview post](https://dev.to/kcarrel/an-approach-to-technical-interviews-3l66)

# Tips
- [Make a portfolio!](https://kcarrel.github.io/)
- Write clear ReadMe's for projects you want to highlight
![ReadMe example for DatePlanet](https://thepracticaldev.s3.amazonaws.com/i/e4p9zusw9vrtazu7bliv.png)
- Host your projects for recruiters/hiring managers to view easily! I love using Heroku personally. 
- Write a technical blog
- Utilize the Tech Twitter network
- Join/attend local Tech Meetup groups and their slack channels
- Continue to code whether that is in the form of interview prep, personal projects or learning new skills
- Remember to take breaks. Finding a job is a full time job in itself but even then TAKE BREAKS!
- Ask developers you know if they would be willing to do a mock interview or informational interview
- Use your network! Often times you will find people happy to help in any way they can.

Do you have any tips or resources you would like to share?
How To Be A Better Developer
Tags: beginners, codenewbie, motivation, career
Published: 2019-08-25 15:04:41

## Introduction

So, if you reading this article then I can assume you are looking for ways to become a better developer and with this article, I will try my utmost to guide you on that path.

---

## Favour Solutions over Coding Skills 👨🏿‍🔧

Gone are the days when developers knew the true meaning of being called a `Developer`. A developer used to be known as an individual who tries to solve real-world problems with technology. These days, a developer is simply someone who can write code.

![solve.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1566730894281/_ABO51hCJ.gif)

Nowadays, few people are trying to solve problems with their code others are simply trying to learn and level up on the latest invoke stack so they don't get left behind. 

Now am not saying this is necessarily a bad thing, it becomes bad when it is prioritized over the problem you want to solve. Have literally seen startups argue for hours over the stack they would use to build a software and giving little thought as to how they would go about solving it.

In short, to become a better developer you need to understand that the problem you solve is far more important than the code you write.

## Strengthen Your Weakness 💪

This seems to be the most obvious right 🤷‍♂️? If you want to be a better developer then obviously the thing to do is work on your weaknesses. Well, tell that to people who call themselves `Backend-only` developers. It marvels me whenever someone tells me he is a backend/frontend only developer and that they have nothing to do with the UI / Database.

![giphy.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1566730725239/uFPSYUaCr.gif)

Now am not saying to become a better developer then you need to go crazy and master both frontend and backend, all am saying is don't neglect any one of them. There is nothing like a **backend-only** or a **frontend-only** developer, there is only a developer. 

The good news is that you have figured where your strengths lie so all you have to do is work on the area you are bad at. If it is frontend, then you can learn how to layout a page and if it is backend, learn about the MVC architecture. **Don't Neglect Your Weakness**.

## Hone Your Foundations 🏋️‍♀️

When I say foundations, I mean understand and honing your programming fundamental. This involves solving algorithmic questions and learning about other types of data structures.

A way I like to do this is by making use of [Hackerrank](https://hackerrank.com). If you don't know about them(which would be unlikely), they help you improve your coding skills by providing you with various coding challenges.

When you perfect your programming fundamental, solving a complex problem would be a lot easier for you.

![ezgif-5-c401fd73493a.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1566743027737/QEzGoziAj.gif)

# That's All Folks  🧠

So that's all we have for now, I tried to make this as short and straight forward as possible. If you have better suggestions do put them in the comments below so others can learn.
JavaScript Iterators and Generators: Synchronous Iterators
Tags: javascript, beginners, synchronous, iterators
Published: 2019-08-25 16:22:42

---
title: JavaScript Iterators and Generators: Synchronous Iterators 
published: true
description: All you should need to know about JavaScript Synchronous Iterators
tags: javascript, beginners, synchronous, iterators
series: JavaScript Iterators and Generators
cover_image: https://thepracticaldev.s3.amazonaws.com/i/jbhb1qi1uqoqcsvf5q6b.png
---

Hi, nice to meet you 😄!
You can find this article in my personal blog [here](https://andreasimonecosta.dev/series/javascript-iterators-and-generators/).
Need help for a project about part-time in tech
Published: 2019-08-25 16:01:52

---
title: Need help for a project about part-time in tech
published: true
description:
tags: 
---
Hi Dev.to :)

I am beginning to work on a project around part-time tech workers and I need your help.

Could you help me list companies which accept to hire tech workers (designers, developers, etc.) part-time (3 or 4 days per week)?

Thanks so much! It would help me a ton!
Python comparison tips
Tags: python, tips, learn
Published: 2019-08-25 15:57:26

### 1. Don’t compare boolean values to True or False using ==.
```
Yes:   if greeting:
No:    if greeting == True:
```
`Worse: if greeting is True:`

### 2. For sequences, (strings, lists, tuples), use the fact that empty sequences are false.
```
Yes: if not seq:
     if seq:
No:  if len(seq):
     if not len(seq):
```
### 3. Object type comparisons should always use isinstance() instead of comparing types directly.
```
Yes: if isinstance(obj, int):

No:  if type(obj) is type(1):
```

When checking if an object is a string, keep in mind that it might be a unicode string too! In Python 2, str and unicode have a common base class, basestring, so you can do:
```
if isinstance(obj, basestring):
```
Note that in Python 3, unicode and basestring no longer exist (there is only str) and a bytes object is no longer a kind of string (it is a sequence of integers instead).
# 4. Use string methods instead of the string module.
String methods are always much faster and share the same API with unicode strings. Override this rule if backwards compatibility with Pythons older than 2.0 is required.
Use `‘’.startswith() and ‘’.endswith()` instead of string slicing to check for prefixes or suffixes.
startswith() and endswith() are cleaner and less error prone:
```
Yes: if foo.startswith(‘bar’): No: if foo[:3] == ‘bar’:
No:  if foo[:3] == 'bar':
```