teleren/devto huggingface dataset:
Using find and execute a command
Tags: bash, shell, django
Published: 2020-11-16 14:36:28

---
title: Using find and execute a command
published: true
date_time: 16/11/2020 21:43:29 UTC
tags: bash,shell,django
canonical_url: https://jinyuz.dev/posts/snippets/Using-find-and-execute-a-command
---

I mostly work on django projects and as a dev who likes shortcuts, I wanted to have an alias of `pm` for `python manage.py`.

I could’ve just added

```shell
alias pm="python manage.py"
```

inside of my config but I was working on different projects where `manage.py` was located in different folders. Typical projects have it located under root while some projects have it under `src/manage.py`.

What I needed was a way to find where the `manage.py` was located and use that so I can do

```shell
$ pm runserver # OR
$ pm shell # OR
$ pm <command>
```

Here’s my first attempt:

```shell
$ find . -type f -name "manage.py" -exec python {} \; -quit
```

What this does is `find` under the current directory `.` a type of file `-type f` with a name of `manage.py` `-name "manage.py"`. And then, for the file you found execute a command `-exec` The `{}` is the current file name returned by `find` command.

In our case it’s gonna be:

```shell
$ python ./src/manage.py
```

The `-quit` is optional in most cases of using the `find exec` command since it it exits immediately after the first match.

But there’s a problem with that approach. If we just do:

```shell
$ alias pm="find . -type f -name "manage.py" -exec python {} \; -quit"
$ pm runserver
```

We get:

```shell
$ find: runserver: unknown primary or operator
```

In order to fix that, we have to wrap it inside a function so that it could take arguments:

```shell
$ alias pm='f(){ find . -type f -name "manage.py" -exec python {} "$@" \; -quit; unset -f f; }; f'
```

The `$@` stands for all other arguments you passed. You can add that inside of your `.bashrc` or `.zshrc`.

If you are using `fish` like me, I have this file inside my `~/.config/fish/functions/pm.fish`

```shell
function pm --description "Find and execute manage.py"
    command find . -type f -name "manage.py" -exec python {} $argv \; -quit
end
```

Now it works fine!

```shell
$ pm runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (2 silenced).
November 16, 2020 - 06:16:50
Django version 2.2.17, using settings 'myproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
```
TIL about the Dodecathorp
Tags: todayilearned, todayisearched, unicode
Published: 2020-11-16 14:20:42

We all know and love the octothorp (`#`, aka number sign, aka hash, aka hashtag, aka pound, aka sharp, aka octothorpe with an e, aka ...).

But today, I wondered, are there other thorps? Searched it up and what do you know? [There is!](https://superuser.com/questions/1588064/does-a-dodecathorpe-unicode-character-exist) Meet the dodecathorp: 

# `⩩ Dodecathorp ⩩`

Next in line from the octothorp, `#`, it has three vertical and three horizontal lines: ⩩.

For the curious, the next three thorps in order would be `hexadecathorp` (a 4x4 with 16 points), `icosithorp` (a 5x5 with 20 points), and `icositettarathorp` (a 6x6 with 24 points). But I haven't been able to find any unicode characters for these thorps... And if you really need a big thorp, I would choose the massive 10 by 10 `tessaracontathorp`.

![Title "Therapist: Tessaracontathorp isn't real, it can't hurt you; Tessaracontathorp:" l; Image showing ten vertical and ten horizontal black lines on a white background](https://dev-to-uploads.s3.amazonaws.com/i/jihql0snvwk0ipiy8yy4.jpg)


And now I could not complete my train of thought without extending my thorps in the other direction... should the symbol with one vertical and one horizontal line (`+`) be called a `tetrathorp`? 🤔
Domain records made less weird with `host`
Tags: webdev, bash, linux
Published: 2020-11-16 14:09:20


I've been hosting my websites and my domains with different providers for a long time. Same goes for emails. In order to connect your domain to your provider or to your email address, you need do 🚨Domain Verification🚨. And that means doing a few obscure DNS operations like changing name servers and whatnot.

You set this up on your domain registrar's website. It's usually hidden behind various clunky UIs. Frustrating is an understatement.

Do you know what the worst part is? After you find the hidden thing, paste the random blob, and sear never to do it again, you can't tell for sure that it worked.

That's where the `host` command comes in. It lets you inspect the DNS records on your domain from your terminal. It probably does other stuff but that's all I ever needed. With this command, you can finally see what your wrangling with the UI did.

Here are a few examples:

Show TXT records

```bash
host -t txt alvin.codes
```

Show A records

```bash
host -t a alvin.codes
```

Show CNAME

```bash
host -t cname alvin.codes
```

Show Name Servers

```bash
host -t ns alvin.codes
```

The `host` command is similar to the `dig` command, but it's a lot simpler and easier to remember. I know which one I prefer between typing `dig alvin.codes +noall +answer` and `host -t a alvin.codes`.

## Bonus: Gitlab & GitHub

Speaking of hidden settings... Here's a bonus for you. Here's what you need to do to connect Gitlab or Github pages to a custom domain.

**For Gitlab**, 2 things need to be set:

- A record set to `35.185.44.232`. (Until their IP changes 🤷‍♂️.)
- A TXT record set to `gitlab-pages-verification-code=[Your Verification Code]`

**For GitHub** you need to create a `CNAME` file at the root of your repository. You can use with the GUI to set it up with the correct values for your domain.

Then, you need to set the following A records:

```c
185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
```

Feel free to reach for this article next time you have a domain to set up, I sure will.

Good luck,
Alvin
Do you use GIT ?  Let me see your code! 
Tags: opensource, github, php, python
Published: 2020-11-16 14:05:43

Note: only public repo which is not associated with any organization. It must be your repo only 


You can simply write the git repo(public) here. I'll be glad to take a look at those codes. I'll also give "star" in return 😊

// exclude .asm/.exe direct code

Thanks!
Python Library Developed
Tags: python, programming, github
Published: 2020-11-16 13:55:28

Hello Dev,
I wanna show you to I developed a python library that contains my public profile and portfolio.
Go and check out [Yogesh-Nile](https://pypi.org/project/Yogesh-Nile/)

Here some example of my library
```python
from Yogesh_Nile import resume

obj = resume()

intro = obj.get_Introduction()

print(intro)
```

```python
from Yogesh_Nile import resume

obj = resume()

link = obj.get_Links()

print(link)
```

Hope you like it, Also check out my [github profile](https://github.com/yoeshnile). 
 - In github I have upload lot of python related repo. You will definitely learn something new.
Use your favorite VSCode theme on iTerm2
Tags: vscode, showdev, themes, productivity
Published: 2020-11-16 13:54:56

---
title: Use your favorite VSCode theme on iTerm2
published: true
description: Introducing ditto, a CLI to convert VSCode theme to iTerm2 ANSI colors
tags: VSCode, showdev, themes, productivity
cover_image: https://user-images.githubusercontent.com/6417910/99180829-a8a1ae80-274f-11eb-9b19-ef8ed796bc83.png
---

Ever had to scour the web to find an iTerm2 theme to match your VSCode theme, to keep your development environment in the same palette?

Introducing "ditto", a small CLI to convert any installed 
VSCode theme(s) to importable iTerm2 Color Scheme(s). 🎨😌

The CLI is open-sourced on Github!

{% github campvanilla/ditto %}

Here's a quick preview on how this works,

<img src="https://user-images.githubusercontent.com/6417910/99155780-1662c180-26e1-11eb-92b8-7ae6c2fb22a2.gif" />

Would love to hear feedback on this. 🙂
Underrated JavaScript Array Methods – Part 2
Tags: javascript, webdev, beginners
Published: 2020-11-16 13:51:52

![Alt Text](https://res.cloudinary.com/lindaojo/image/upload/v1605043758/undderrated_js_f6zyb7.png)

Last week, we looked at a few JavaScript Array Methods which you can read about in my last article: <a href="https://www.lindaojo.com/blog/underrated-java-script-array-methods-part-1/" target="_blank" class="link">Underrated JavaScript Array Methods – Part 1</a>. We are rounding up this week with a few more methods.

<h3>- flat()</h3>

This method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.

Syntax – <strong class="code-word">array.flat(depth?)</strong>

<strong>Note: Arguments followed by a question mark are optional.</strong>

```js
const array = [ [1, 2], [3, 4], [[5, 6]] ];

const flattenedOnce = array.flat();
const flattenedTwice = array.flat(2);

console.log(flattenedOnce);
// expected output: Array [1, 2, 3, 4, [5, 6]]

console.log(flattenedTwice);
// expected output: Array [1, 2, 3, 4, 5, 6]
```

<h3>- reduceRight()</h3>

The <strong class="code-word">reduceRight()</strong> method applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value. This method comes in pretty handy when you want to specify items in a left-to-right manner but execute them in a right-to-left manner.

You could use <strong class="code-word">reduceRight()</strong> method to replace <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce" target="_blank" class="code-word"> Array.reverse().reduce()</a>

```js
const numbers = [[0, 0], [1, 1], [2, 2]];

const modifiedNumbers = numbers.reduceRight( (a, b) => a.concat(b) );

console.log(modifiedNumbers);
// expected output: Array [2, 2, 1, 1, 0, 0]
```

<h3>- lastIndexOf()</h3>

The <strong class="code-word">lastIndexOf()</strong> method returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at <strong class="code-word">fromIndex</strong> if this argument is available. The <strong class="code-word">lastIndexOf()</strong> method is case-sensitive.

Syntax – <strong class="code-word">array.lastIndexOf(searchValue,  fromIndex?)</strong>

```js
const names = ['John', 'Bolanle', 'Dwight', 'Mary'];

console.log( names.lastIndexOf('Dwight') );
// expected output: 2

// -1 is returned if the searchValue is absent in the Array 
console.log( names.lastIndexOf('Tiger') );
// expected output: -1
```
See you next week 💙
2020-11-15 | Backup Progress
Tags: learninpublic, beginners, webdev, career
Published: 2020-11-16 08:56:04

---
title: "2020-11-15 | Backup Progress"
description: "Summary of my day"
published: true
tags: ["LearnInPublic", "Beginners", "Webdev", "Career"]
series: "miku86 Diary"
canonical_url: "https://miku86.com/blog/day-2020-11-15"
---

I got my new 64GB USB stick. You can read about my backup story [here](https://dev.to/miku86/2020-11-06-my-new-backup-approach-4nc6) and [here](https://dev.to/miku86/2020-11-07-firefox-for-privacy-backup-with-rsync-and-7zip-soccer-220i).

The script is fairly simple:

```sh
#!/bin/sh
now=$(date +%Y-%m-%d_%H-%M-%S)
user=miku86
backup_source=/home/$user
backup_dest_local=/home/$user/BACKUP/ # do not forget to exclude this
backup_dest_external=/run/media/$user/HOMEBACKUP/$now

rsync -h --progress --stats -r -tgo -p -l -D --update --delete-after --delete-excluded \
# ... many lines of exluding folders, e.g. cache, node_modules etc.
$backup_source $backup_dest_local &&
cp -r $backup_dest_local $backup_dest_external
```

Every some days I move the data from the USB stick to my external long-term backup after some cleaning.
My #100daysOfCode Challenge - Python 100 projects in 100 days - Journal Entries - Day 4
Published: 2020-11-16 13:34:37

Day 4 - Rock, Paper, Scissors game

import random



rock = '''
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
'''

paper = '''
    _______
---'   ____)____
          ______)
          _______)
         _______)
---.__________)
'''

scissors = '''
    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)
'''
game_image = [rock, paper, scissors]

user_choice = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n"))
print(game_image[user_choice])

computer_choice = random.randint(0, 2)
print("computer chose:")
print(game_image[computer_choice])


if user_choice >= 3 or user_choice < 0:
  print("You typed an invalid number, you lose!")
elif user_choice == 0 and computer_choice == 2:
  print('You Win!')
elif computer_choice == 0 and user_choice == 2:
  print("You Lose!")
elif computer_choice > user_choice:
  print("You Lose!")
elif user_choice > computer_choice:
  print("You Win!")
elif computer_choice == user_choice:
  print("Draw game!")

Key Takeaways:

1. Learned about Randomisation adn Python List
User Level v/s Kernel Level Threads | Operating System - M01 P12
Tags: linux, beginners, devops, codenewbie
Published: 2020-11-16 13:16:53

**This is a multipart blog article series, and in this series I am going to explain you the concepts of operating system. This article series is divided into multiple modules and this is the first module which consists of 12 articles.**

_In this article you will the difference between **User level** and **Kernel level** threads in an operating system. Here, we are talking about **multiprocessing/multitasking** environment._

Remember one thing that, user level thread and kernel level thread always share code, file and data while they have different stack and registers, that’s why these are known as _Light weight processes._

We will see the difference in between these with the help of a table.

User level thread | Kernel level thread |
--- | --- |
User level threads are managed by user level libraries. It means that it is the responsibility of application to create user level thread. | Kernel level threads are managed by operating system. We have to use system calls for it. |
User level threads are typically fast. | Kernel level threads are slower then user level threads. |
Context switching is faster. | Context switching is slower. |
If one user level thread performs blocking operations then entire process get blocked. | If one kernel level thread blocked, no affect on others.

### Hybrid environment

![Untitled Diagram.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1605532397660/nAjW-GcVO.png)
- At present we use hybrid environment, which means that we have both user level thread and kernel level thread.
- Generally we use two user level threads and map it with one kernel level thread.
- We can map it by using _many to one_, _one to many_, _many to many_ method. Just like Linux base operating system in general use _one to one_ method, to map user level thread and kernel level thread.

> Context switching time: Process > KLT > ULT

_This was all about kernel level thread and user level thread. Hope you liked it and learned something new from it._

If you have any doubt, question, queries related to this topic or just want to share something, then please feel free to contact me.

### 📱 Contact Me

[Twitter](https://twitter.com/r_mishra10)
[LinkedIn](https://www.linkedin.com/in/rahul-mishra-66210b185)
[Telegram](https://t.me/rahul_mishra10)
[Instagram](https://www.instagram.com/rahul_mishra10/?hl=en)

### 📧 Write a mail
<rahulmishra102000@gmail.com>

#### 🚀 Other links

[GitHub](https://github.com/rahulMishra05)
[HackerRank](https://www.hackerrank.com/rahulmishra10201)
In love with the new Chrome CSS Overview Tab 😍
Tags: css, layouts, devtools, devs
Published: 2020-11-16 13:15:48

---
title: In love with the new Chrome CSS Overview Tab 😍
published: true
description: 
tags: #css #layouts #devtools #devs
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/4iscw95knz456k9h7edi.png
---

I recently switched on the **Experimental** **CSS Overview** tab in Chrome Devtools and it looks like an awesome feature for both the designers and developers.

###How to use? 

Open **Settings** of DevTools, navigate to **Experiments**, and check **CSS Overview** as seen below.

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

Now reload the Devtools and click on **CSS Overview** tab.

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

That's it.

>You can also click on each color/option to see where it has been used throughout your files.

Will **SWITCH IT ON** or **NOT**? Let me know in the comments below.

Happy Debugging! 


[Codedmails - Overview Tab Source](https://codedmails.com)
Where to learn Android Application Development in Kotlin from?
Tags: kotlin, android, discuss, help
Published: 2020-11-16 13:13:21

---
title: Where to learn Android Application Development in Kotlin from?
published: true
description: Where to learn Android Application Development in Kotlin from?
tags: kotlin, android, discuss, help
cover_image: https://images.unsplash.com/photo-1514417034809-c7b296354f07?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2551&q=80
---

Hi all, does anyone here know a good android development course with Kotlin? One of my college juniors want to learn android development in Kotlin. Any other resources (books, blogposts) are also appreciated.
Simpler Solutions
Tags: csharp, visualstudio
Published: 2020-11-16 13:12:56

I am currently working on my college project where I need to create a web based application or a web site. Its theme is project workflow management system and I need simpler solutions about about how the dashboard after the user logins to the site should look like. It  would be great if you guys could give me simpler answers about how you would like to see the dashboard after you login to a remote management system based site.
Daily Developer Jokes - Monday, Nov 16, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-11-16 13:00:14

---
title: "Daily Developer Jokes - Monday, Nov 16, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Monday%2C%20Nov%2016%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258b2d77d4.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ What's the second movie about a database engineer called?

___A:___ The SQL.
 -->
3 Lessons I Learnt from being a Lazy Programmer
Tags: productivity, programming, python, opensource
Published: 2020-11-16 12:59:32

> I will always choose a lazy person to do a difficult job because a lazy person will find an easy way to do it."

-- **Bill Gates**


![A lazy programmer sleeping instead of coding](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzr0vk6hw3sm9f2iusag.jpeg)


Although working hard works, but working smart saves time. This lazy attitude of programming is all about taking the most efficient route in order to get an optimal result. Some call it "lazy" while those doing it call it "smart". Regardless of what it is called, let's now dive into 3 lessons I learned when I joined the club.

## __1. JOIN THE MOVING TRAIN.__ 🚆
For some of us, when we started programming, we pledged our allegiance to the first programming language we had an affair with. We promised to stick with it till the end, learn every ins and outs of it, and become a master in it.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/pgahytg3l82zd9kvml1r.jpeg)

But when it was time to compete, then I realized that I brought knives to a gunfight. And after losing the battle, I went shopping for guns. _(And I found python)_
The point here is to go with the technology that works best for you.
**But HEY!** Don't keep jumping from one train to another, if not your fall will be greater than Humpty Dumpty's.

## __2. DON'T REINVENT THE WHEEL__ ⚙️
Trust me, the bird-eye view you get while standing on the shoulders of giants is so fantabulous. Though it's really tempting to want your own version of "a", meanwhile problem "b" to "z" are still pending.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3c2cn0udclxcv0qmda2w.jpg)

One doesn't have to redo the heavy lifting that some other developer has spent hours perfecting. Instead, just add those shiny batteries to your engine to fire up your project in less than no time. The best part is that there is a free store called _"open-source"_ that you can grab as many batteries as possible for your project.
Using these batteries _(already-made packages)_ allow one to concentrate on what's most important: "giving birth to Your Unique Idea".
**But HEY!** Make sure you properly inspect those batteries you are adding to your project, so you don't blow off your baby.

## __3. DRIVE TOWARDS A GOAL__ 🎯
There is usually a whole lot to learn, a whole lot to fix, and a whole lot to solve. But unfortunately, there's only one tiny brain sitting inside our head. So we can't do them ALL.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/d7svafkdgw4ci8roew6o.jpg)

Although the best way to address this is by focusing on a particular goal at a time and getting the best out of it. This allows one to filter out those noisy projects, that don't lead anywhere. Defining goals always save gas in every developer's journey.
**But HEY!** "Only what matters matter, until it doesn't matter".

---
_**Now for those who haven't joined the lazy club, I advise you to hop in ASAP!**_

If you like the post, please click the like button and if you don't like the post, still click the like button. 🥂
Markdown Madness
Tags: markdown, readme, jupyter, dillinger
Published: 2020-11-16 12:41:28

I first met Markdown when I was learning Python. I was using Jupyter Notebooks, and it was incredibly mindblowing to me that you could write code snippets and have images and text to document and explain the same code snippets, then run the code and see the results of the run code AT THE SAME TIME. WHAT?!

So I learnt a few tricks here and there.

Then life happened.

As I got more into coding, I was driven to text editors and CLI, etc... etc. So I stopped using markdown for a while.

Recently, however, I've been getting more serious about pushing to GitHub, and I realized that if you're interested in getting people to know what your repo is all about, YOU BETTER HAVE A GREAT README.md!

I honestly didn't want to have to be struggling to get my Markdown to look great, and if you've ever used LaTex, you probably understand what I mean.
That's when I met [Dillinger](https://dillinger.io/).
AWESOME!
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/k5ts827mb1sh6hgj01wa.png)

SO if you are struggling with learning and remembering Markdown for whatever reason, just hop on over. Then you can practise HERE on Dev.to. Because that's what I'm using to type MY FIRST POST :hearts:

And if you want to learn more about Markdown head over to [Markdown Guide](https://www.markdownguide.org/).



P.S. Emojis are fun in Markdown -> https://gist.github.com/rxaviers/7360908

Sidenote: Recommended LaTex Editor -> [Overleaf](https://www.overleaf.com/)