teleren/devto huggingface dataset:
[casdrop.py]: Casting media files in python to Chromecast from a desktop folder
Tags: python, linux, 100daysofcode, productivity
Published: 2021-10-21 04:37:15

&nbsp;
**[REPO_LINK.GIT](https://github.com/munazhe/casdrop.py)**
&nbsp;
&nbsp;
## What does it do? 
So, I made a python script that connects to a Chromecast and plays video & audio (.mp4 || .mp3) as soon as you drop your file in the `chromecast` folder...

The idea came when I was looking for a quick way to share files onto my TV or Google Home Max without having to need a dedicated app. So, I hacked the b*tch!

On a serious note...

&nbsp;
&nbsp;

## Here's what you need, before we get started: 

A. Know the "friendly" name of your TV `(CASDROP_TV_NAME)` and Speaker `(CASDROP_SPKR_NAME)`. 

B. Make sure your machine is running python `~> 3.9.7` (not mandatory, but you need at least python 3).

C. Install all dependencies to run this program: `pip install requirements.txt`

&nbsp;
&nbsp;

## Once that's done...

**Step1**. Open a new terminal on your unix/linux based computer 
> **NOTE**: I ran these commands in a BASH environment, so I suggest doing the same...

&nbsp;
**Step2**. Open `params.sh` and edit the `<>` with your own values. I ran into a few mistakes because I was putting in the wrong IP address.

&nbsp;
**Step3**. Run the following command in your terminal:
***ONLY RUN THIS ONCE!***

`bash params.sh #you may need to run this command with elevated privileges`

&nbsp;
**Step4**. Run the app:

	1. Start a simple HTTP server:
		`python -m SimpleHTTPServer`

	2. Run the casting service: 
		`python3 casdrop.py`

	3. Drop a file in your watch `CASDROP_WATCH_FOLDER` folder. Which in this case should be the folder we are looking to drop our files.

&nbsp;

	**At this point, your uploaded files should start streaming on the device(s).**
&nbsp;
&nbsp;
&nbsp;
A side note: I know this is very short and cut to the point. However, I did this on purpose...Most of what you need is already on the internet. With that said, feel free to ask question if you lost, in the comment section below.
&nbsp;
&nbsp;
&nbsp;
### Reference: 
- `CASDROP_WATCH_FOLDER` => A folder you drop files in, to cast to device(s)

- `CASDROP_SERVER_URL` => The `IP` address you get from `SimpleHTTPServer` a.k.a `(http://<ip_address>)`

- `CASDROP_SPKR_NAME` and CASDROP_TV_NAME=> Displayed name of devices with (Ussually shown in cast menu on YouTube or Spotify mobile app)

### Here's my sample `param.sh` file
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/suis1utat4vqnlhl42cv.png)


&nbsp;
### Features / Suggestions / TODO:

Currently you can drop a `.mp3` or `.mp4` which will cast with zero problem. However, I plan on adding more features down 
the road...

**Let me know in the comments if you'd like me to make a video explaining this is more detail**
Customize Blazor TreeGrid Toolbar Using Templates
Tags: blazor, webdev, dotnet, csharp
Published: 2021-10-21 04:28:39

Learn how to customize a toolbar in a Syncfusion [Blazor TreeGrid](https://www.syncfusion.com/blazor-components/blazor-tree-grid) using templates. 
Download an example from GitHub: https://bit.ly/3iW9M5E 

Refer to the following documentations to customize a toolbar in the Blazor TreeGrid component Create custom toolbar with drop-down list in Blazor TreeGrid Component: https://bit.ly/3v3d0Jr 

Custom control in Tree Grid toolbar in Blazor TreeGrid Component: https://bit.ly/3lzppSj 

Check out this online example of the toolbar template in the Blazor TreeGrid component: https://bit.ly/3mQiHXc 

Refer to the following documentation to work with a filter in the Blazor TreeGrid component: https://bit.ly/3BAuwqZ

{% youtube yqp_Ukr_aQs %}
Async/Await with easy to understand examples.
Tags: javascript, webdev, beginners, programming
Published: 2021-10-21 04:11:46

Let's first understand the **Async** keyword. 

Put this keyword before the function which returns a promise or which does an asynchronous task.

```js
const foo = async () => {
  return 'done';
}

foo().then((res) => console.log(res));

// done
```

If you think your function will run asynchronously (fetching data from API) then use the async keyword before that function.

Now there is another keyword **Await** that works only inside async functions.

(There is a concept of top-level await in which await keyword can be used outside of the async function.)

The Await keyword simply means it makes JavaScript wait until the task is completed.

```js
const asyncTask =  () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve('done');
    }, 1000);
  });
}

const foo = async () => {
  const res = await asyncTask();
  console.log(res);
}

console.log('Before Foo Call');
foo();
console.log('After Foo Call');
```
In the above example, I am creating a dummy function that takes one second to return its result.

There is another function foo that calls asyncTask (with await keyword) and prints the result.

I have put two logs, one is before calling foo and the second is after calling foo.

What do you think will be the output? 🤔

As you may know, whenever JavaScript encounter with await keyword it stops the execution of the current function and put it into the callback queue and start executing the next statement which is the second console log.

Here is an output of the above code.

```
Before Foo Call
After Foo Call
done
```

##### Handling errors while using async/await

In the above example, our promise resolves normally and we are printing the result on the console. 

But in case of rejection, it will throw an error so we should handle errors while working with promises. 

Using try/catch block.

```js
const asyncTask =  () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      reject('Something not working!');
    }, 1000);
  });
}

const foo = async () => {
  try {
    const res = await asyncTask();
  	console.log(res);
  } catch (err) {
    console.log(err);
  }
  console.log('After calling AsyncTask');
}

foo();
```
Now, If our asyncTask function throws an error control will go into catch block and simply prints the error message then it will start to execute the next statements.

Output
```
Something not working!
After calling AsyncTask
```

Very clean. Isn't it?

Now, try to use async/await instead of then/catch in your next project.

If you like this article like, share and mark 🔖 this article!

🏃‍♂️ You can follow me on 👇

🕊 Twitter : https://twitter.com/nehal_mahida

👨‍💻 Github: https://github.com/NehalMahida

####Support 🤗
If you are enjoying my articles, consider supporting me with a coffee.☕
<a href="https://www.buymeacoffee.com/nehalmahida"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=nehalmahida&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff"></a>
How to add custom error pages with Nuxt Js
Tags: nuxtjserrorpage, customnuxterrorpage, nuxtjs404
Published: 2021-10-21 14:19:59

---
title: How to add custom error pages with Nuxt Js
published: true
date: 2021-10-21 04:00:00 UTC
tags: nuxtjserrorpage, customnuxterrorpage, nuxtjs404
canonical_url: https://postsrc.com/posts/how-to-add-custom-error-pages-with-nuxt-js
---

Error pages are very important to have and to add them to your Nuxt Js application, it's very straightforward and easy to implement. What we essentially need is an "error.vue" file inside the layouts folder and the code should be as follow.  
  
**Error template**

```
<template>
  <div>
    <h1 v-if="error.statusCode === 404">Page not found</h1>
    <h1 v-else-if="error.statusCode === 500">Internal Server error</h1>
    <h1 v-else>An error occurred</h1>
    <NuxtLink to="/">Home page</NuxtLink>
  </div>
</template>

<script>
  export default {
    props: ['error'],
    // layout: 'error' // you can set a custom layout for the error page
  }
</script>
```

The code above should be named "error.vue" and this is a special template that Nuxt has set and it will accept a prop with error as its name. To know more of the available properties, do console log the error object or refer to this documentation of [Nuxt Error Page section](https://nuxtjs.org/docs/2.x/internals-glossary/context#error).
Python + JavaScript = 🔥🔥🔥
Tags: javascript, node, python, programming
Published: 2021-10-21 03:40:30

When in comes to **Web Development** nothing beats **JavaScript**. But sometimes we have to do a bit more demanding task, for example *analyzing big pile of data*. In that case **Python** might be a superior option. But that's just one function of our website. Do we want to switch to Python just because of that one feature? Probably not.
## So what if we could build our backend mostly using NodeJS and only use Python when we have to.
That would be awesome right? We can use `child process` in Node.JS to run a python script when needed.
```js
const spawn = require('child_process').spawn
app.get("process_data", (req, res) => {
    spawn('python3', ['script.py'])
})
```
```py
# script.py
doSometing()
```

And if we want we can **pass data to our python script** also.
```js
const spawn = require('child_process').spawn
app.get("process_data", (req, res) => {
    const msg = "Hello"
    spawn('python3', ['script.py', msg])
})
```
In Python in order to be able to read the data you **must import** the **sys** module.
```py
import sys, json

def main():
    msg = sys.argv[1]
    doSometing(msg)

if __name__ == '__main__':
    main()
```

Now instead on passing data while spawning the Python process, lets send data in stream.
```js
const spawn = require('child_process').spawn,
const py = spawn('python3', ['script.py'])
const data = {
    msg: "Hello"
}

py.stdin.write(JSON.stringify(data)) //we have to send data as a string, so we are using JSON.stringify
py.stdin.end()
```
```py
import sys, json

def main():
    lines = sys.stdin.readlines()
    data = json.loads(lines)
    doSometing(data['msg'])

if __name__ == '__main__':
    main()
```

Finally we can send response back to our nodejs from the python script
```js
const spawn = require('child_process').spawn
const py = spawn('python3', ['cscript.py'])

py.stdout.on('data', function(res){
   let data = JSON.parse(res.toString())
   console.log(data)
})
```
```py
import sys

# You will have your own implementation of get data. In this case lets assume it returns a dict/json
res = getData()
print(json.dumps(data))

sys.stdout.flush()
```

So this article has come to an end. But make sure you check out my other articles. {% link https://dev.to/0shuvo0/i-will-be-notified-if-you-click-this-7df %}
{% user 0shuvo0 %}
Halloween Event! What's on your workspace?
Tags: halloween, workspace, opensource, embedded
Published: 2021-10-21 03:32:51

Halloween Event! What's on your workspace?

- Take a picture of your workspace
- Share the picture below

The most liked comment counted on this Feed and [RT-Thread Club](https://club.rt-thread.io/ask/question/88.html) Feed will receive a special Halloween Gift.

The winner will be announced on November 1st.

Make sure that you're following the open source RT-Thread [Facebook](https://www.facebook.com/RT-Thread-IoT-OS-110395723808463), [Twitter](https://twitter.com/rt_thread), or [Linkedin](https://www.linkedin.com/company/73004322) so you'll be updated with the winner announcement!

Happy Dev's Halloween!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/buarpl5ea2rs8bkpcmix.jpg)
Hactoberfest-2021
Tags: hacktoberfest
Published: 2021-10-21 03:28:53

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->


### [Intro Heading]
Hi, I am Suman. Always Wanted to know how things work in the tech world. I came up with some youtube resources about hactoberfest 2021. I registered and created 4 vaild pull requests and successfully won the hactoberfest 2021.

### Background
Well of course i am new in opensource. I recently got to know about opensource from some youtube videos. I got involved in coding from the past few months and i am currently exploring about different things mainly DSA, WEB D.

### Progress

Well the process is a bit simple and it's a good initiative for the open source overall growth. 

### Contributions

Well I can't provide the projects link. may be if you want to know then you can visit my github profile. I chose some beginner projects so that it will be easy for me to contribute.


### Reflections
Well I learned a lot of things related to github in general. It was my really nice and cool experience. I will definitely participate in the coming years also.
code every day with me
Tags: javascript, 100daysofcode, programming, algorithms
Published: 2021-10-21 03:14:00

**--DAY 3--**
Hi, I am going to make #100DaysOfCode Challenge.Everyday I will try solve 1 problem from leetcode or hackerrank. Hope you can go with me until end.
**Now let's solve problem today:**
-Problem: Time Conversion
-Detail: https://www.hackerrank.com/challenges/time-conversion/problem
-My solution (javascript):
```
function timeConversion(s) {
    let check=s[s.length-2];
    s=s.substr(0, s.length-2).split(':');
    if(Number(s[0])==12) {
        if(check=='A') {
            s[0]='00';
            return s.join(':');
        }
        else return s.join(':')
    }
    if(check=='P') s[0]=(Number(s[0])+12).toString();
    return s.join(':');
}
```
-->*If you have better solution or any question, please comment below. I will appreciate.*
Open Source Friday Recap: Slinkity and TinaCMS
Tags: opensource, slinkity, tinacms, jamstack
Published: 2021-10-21 02:59:03

_Typically, developers don’t push to production on Fridays, which is why Friday is the perfect day to contribute to Open Source. Every Friday at GitHub, we stream Open Source Friday on Twitch with host Brian Douglas and the maintainer of a rising open source project. It’s an opportunity to learn how they built the tool and how you can contribute._

## Slinkity
On Oct 8, 2021, we chatted with Slinkity’s author and owner, Ben Holmes.

### What is it?
Slinkity is a plugin that can extend any 11ty site. If you’re not familiar with 11ty, it’s a static generator site. Ben describes Slinkity as the glue between 11ty and Vite. With Slinkity, you can use shortcodes to insert React components and quickly transform HTML files into JSX files. Currently, it is available as an early alpha version, so it’s not ready for production just yet, but stay tuned for frequent updates.  

### Why was it made?
During quarantine, Ben rewrote his personal website using 11ty but wished for an easy way to insert components into his site, so he created a way to do it. He credits the launch of his project to members of various Discord communities for encouraging him to just “ship it.”  

**Watch the video below to learn more about Slinkity:** 
{% youtube DqUGJyuX8m0 %}

**Explore the codebase and contribute to Slinkity:**
{% github slinkity/slinkity %}

## TinaCMS
On Oct 15, 2021, we chatted with James Perkins, a Developer Advocate for TinaCMS.

### What is it?
TinaCMS is a visual editing experience for content stored as Markdown, JSON, or MDX (which is coming soon). The team recognized that while popular content management systems like WordPress allow you to edit and see your content before publishing, many JAMStack tools don’t. 

TinaCMS provides content writers and editors with immediate visual feedback by enabling developers to edit and rearrange content around as needed on JAMStack applications. 

### How does it work? 
To install TinaCMS and create an easy visual editing experience for your site, you only need to install the npm package into your application with this one line: `npx @tinacms/cli init`. This line will generate all files and tools needed to use TinaCMS.Under the hood, a GraphQL layer powers the content editing experience.

**Watch the video below to learn more about TinaCMS:** 
{% youtube qjIuwGbjmqM %}

**Explore the codebase and contribute to TinaCMS:**
{% github tinacms/tinacms %}

**Comment below if you have or know of an Open Source project that you would like us to feature!**
Cara Mencari Sinyal K-Vision
Published: 2021-10-21 02:16:18

<p>K-Vision adalah salah satu TV satelit berlangganan terbaik yang ada di Indonesia. Bagi yang baru pertama kali menggunakan parabola pasti kebingungan tentang bagaimana <b>cara mencari Sinyal K-Vision</b>.</p>
<p>Hal ini sangat wajar karena faktanya walaupun terlihat gampang namun lock sinyal dari satelit itu sangat sulit kalau belum pernah pegang antena berbentuk seperti wajan ini</p>
<p>Diambil dari <a href="https://www.wajanterbang.com">wajanterbang</a>, hal pertama yang harus dilakukan untuk mendapatkan siaran K-Vision adalah menambahkan satelet Telkom 4 untuk C-band dan Measat 3a untuk Ku-band di pengaturan receiver</p><p>Setelah itu kita pasangkan semua alat tempur mulai dari antena, LNB dan Kabel ke konektor dibelakang receiver.</p><p>Arahkan parabola menuju satelit yang dimana siaran mengudara, arah yang tepat dapat dicari dengan aplikasi android pencari sinyal seperti Satfinder.</p><p>Setelah semua terpasang dan sudah diarahkan, cek pergerakan sinyal. Ingat jika alat tempur terpasang benar dan masih dalam kondisi baik, intensitas sinyal pasti sudah naik, sebaliknya jika rusak ya tidak ada perubahan. Silahkan cek mana yang error lalu diperbaiki.</p><p>Hal lain yang perlu diperhatikan adalah kualitas sinyal, idealnya harus di atas 70% agar siaran stabil dan bening. Kalian bisa meningkatkan dengan mengeser geser parabola sambil terus mengecek perubahan di layar TV.</p><p>Terakhir kalian tinggal melakukan scan buta dan pastikan pilihan "Hanya FTA" dijawab tidak. Ingat bos siaran K-Vision itu bukan Free to Air namun terenkripsi. Yang dapat membuka hanyalah receiver rekomendasi yang sudah diaktivasi dengan akun pelanggan. Beberapa siaran ada yang berbayar dan harus dibeli sebagai paket premium.</p><p>Setelah itu seharusnya semua tayangan FTV dari seluruh TV Nasional cling dan bisa ditonton seperti biasa. Jika kesulitan tidak ada salahnya berbagi rejeki dengan para teknisi.</p><p>Nah bagaimana jika sinyal K-Vision tiba-tiba menghilang? Jika hilang semua kemungkinan parabola bergeser, ada kerusakan alat, kabel longgar, hujan lebat sehingga menurunkan kualitas sinyal, gangguan penyiaran satelit atau pindah satelit seperti yang terjadi pada tahun 2020.</p><p>Pada dasarnya cara mencari sinyal K-Vision yang hilang untuk Bromo dan Cartenz itu sama saja. Bedanya hanya satelit yang harus dilock, arahnya sedikit berbeda yang semua bisa dicari dengan sangat mudah.</p>
<p>Sumber:</p>

https://www.wajanterbang.com/2019/06/cara-mencari-sinyal-k-vision-yang-hilang.html
使用序列化在兩個 Rails 站台間傳遞物件
Tags: ruby, rails, serialization
Published: 2021-10-21 01:20:10

一般 REST API 傳遞大多是用 HTTP post 發送 JSON、YAML、XML，不過這裡講的不是 client - server 的傳遞，而是 server - server 的傳遞，情境是 production 站與 staging 站間的物件傳遞，雖然說 Rails 有 seed 可以用來建資料，不過有時候開發上還是需要拿一些比較真實的資料來驗證，或者單純因為懶惰。

簡單解釋做法，就是把 production 上的物件序列化成檔案，再從 staging 站台抓下來還原城物件。在 Ruby 的世界，已經內建有 Marshal 模組來做序列化的工作，並且使用簡易。

練習隨機挑一個 book 物件，使用 Marshal 把它序列化後存到 Rails 的 public 位置：

```Ruby
b = Book.find(Book.ids.sample(1)[0])
File.open(Rails.public_path.join(Book.id, 'wb+') do |f|
  f.write(Marshal.dump(b))
end
```

然後切換到 staging 站台，去 production 站抓檔案，反序列化後存入資料庫：

```Ruby
f = open('http://10.100.99.72/619204')
f = Marshal.load(f)

b = Book.new
b.attributes = f.attributes
b.save
```

注意，直接跑 `f.save` 是沒用的，一定要建新的物件再指定 attributes。

可以再驗證一下：

```Ruby
b.reload
b
```

應該就可以看到有正確存入了。

不過 Marshal 也不是萬能的，牽扯到一些 IO 操作的物件或資料庫關聯的物件就會遇到一些問題了。
Python challenge_10
Tags: challenge, python, programming, beginners
Published: 2021-10-21 00:22:23

##Min-maxing
###level of challenge 3/10

Min-maxing

- Define a function named largest_difference 
- that takes a list of numbers as its only parameter.
- Your function should compute and return the difference 
- between the largest and smallest number in the list.

For example:

- the call largest_difference([1, 2, 3]) 
- should return 2 because 3 - 1 is 2.

You may assume that no numbers are smaller or larger than -100 and 100.

Hint:

- Split the problem up into sub problems:
- First find the smallest number.
- Then find the largest number.
- Then compute their difference and return it.
- To find the smallest number you can use the min() built-in. 
- Alternatively you can set smallest = 100 and loop over each number in the 
  input list. Whenever you see a smaller one, set smallest to it.

```
# My solution

def largest_difference(numbers):
 sm_number = numbers
 la_number = numbers
 smaller = min(sm_number)
 largest = max(la_number)
 return largest - smaller

print(largest_difference([1, 2, 3, 5, 6]))

```

```
# short solution

def largest_difference(numbers):
  return max(numbers) - min(numbers)

```

```
# Another solution

def largest_difference(numbers):
 smallest = 100
 for n in numbers:
  if n < smallest:
   smallest = n

 largest = -100
 for n in numbers:
  if n > largest:
    largest = n

 difference = largest - smallest
 return difference

```
Cassidy asked if I had written anything, so here it is
Published: 2022-01-02 18:58:48

---
title: Cassidy asked if I had written anything, so here it is
published: true
date: 2021-10-20 23:40:35 UTC
tags: 
canonical_url: https://alex.party/posts/2021-10-20-cassidy-asked-if-i-had-written-anything-so-here-it-is/
---

Look, let's be honest. You aren't really here for some earth shattering information. You saw a very clickbaity title that I made to troll [Cassidy Williams](https://cassidoo.co) and quite honestly, I don't think she was ACTUALLY expecting this.

As long as you are here though, I should write up some interesting links that I've found over the past few days that caught my attention.

## [Building The SSG I’ve Always Wanted: An 11ty, Vite And JAM Sandwich](https://www.smashingmagazine.com/2021/10/building-ssg-11ty-vite-jam-sandwich/)

Ben Holmes has an amazing write up of his time over the last almost 2 years of his adventures in making his own static site generator setup. It's a great read, and honestly is so much fun.

## Netflix Can do Better

The story of the week in my news feed is surrounding Netflix and the new Dave Chappelle special. I have even had a very long phone call with a friend about this. Rather than attempt to pontificate, I'll link to the 2 articles I have read from the people who are living this story:

- [Terra Field - "It Was Never About Dave"](https://rainofterra.com/it-was-never-about-dave-9aee8b765978)
- [NYT - "Netflix workers plan a walkout as the fallout over Dave Chappelle continues."](https://www.nytimes.com/2021/10/19/business/media/netflix-dave-chappelle-employee-walkout.html)

I have yet to watch the Chappelle special, but I will be so that I can speak from an informed place about it.

## [Alpha Paintlet](https://daverupert.com/2021/10/alpha-paintlet/)

Dave Rupert talks about using houdini to make custom CSS properties with more magic. I love new web technology and the unlimited terrible things you can do with it.

And that's all. There, Cassidy. I wrote something. Your move.

Originally Posted as [Cassidy asked if I had written anything, so here it is](https://alex.party/posts/2021-10-20-cassidy-asked-if-i-had-written-anything-so-here-it-is/) at alex.party
About me
Tags: javascript, webdev
Published: 2021-10-20 23:07:39

I am a former high school teacher that taught business classes. My passion for app building for my students led me into coding. 

I also used to run a small business manfacturing surfboards out of a garage. That's the pic you see on this thread.

Right now, Im looking for JavaScript developers who are also good instructors / good people. I built a network for coaches to provide expertise to other dev's that have bugs or just want to learn.

The website is p-pl.com 
Check it out