teleren/devto huggingface dataset:
I Did My Own Small Benchmark. C# - List of Int vs Array of Int
Tags: csharp, programming, benchmarking
Published: 2021-03-07 00:21:41

I consider myself an easy going guy. I like coffee, the simple things in life. Lists in my programming. 

But after doing some reading and reading some debates online, I decided to run a small benchmark myself on Lists vs Arrays. 

I did this with an extremely small set of data. I started the C# Stopwatch class and ran the clock over setting up the data structure, populating it, and then looping through those items in it. 

Both sets of data held integers 1 through 10. 

It took 00:00:00.0230056 seconds to process the list.
It took 00:00:00.0008005 seconds to process the array.

That is a ridiculously smaller amount of time to process the array. 

CRAZY. 

I wrote more on medium if you want to follow the article there. 

Thanks! 

[My Medium Account](https://coryharkins.medium.com/c-code-performance-list-vs-array-cf134b603774)
A word of npx-advice
Tags: npm, yarn, dependencies, nx
Published: 2021-03-07 00:19:36

Node.js dependency managers like `NPM` and `YARN` does support the easy execution of `starter-kit-packages` to bootstrap or create the boilerplate of many kinds of projects, like [create-npm](https://www.npmjs.com/package/create-npm) which bootstraps a package by running:
```
npm create npm github-user/my-pkg

yarn create npm github-user/my-pkg
```

These packages starts with [create-*](https://npm.io/search/create) and the `create` command forwards any `<args>` to the binary, so
```
yarn create nx-plugin my-workspace --pluginName my-plugin
```
is equivalent to
```
yarn global add create-nx-plugin
create-nx-plugin my-workspace --pluginName my-plugin
```


I do usually use [create-nx-workspace](https://npm.io/package/create-nx-workspace) and recently I wanted to re-take my experiments with `Nx` so I created a new workspace with `npx create-nx-workspace --preset angular` and I got an outdated setup.

I was wondering if the package was not being maintained properly (which was very unlikely) but then I realized that I installed it globally many months ago for some reason, and I didn't update it since then... 

## Best Practice

Try to not install packages globally which gets easily outdated, and please never install a `starter package` globally. Just run the latest version with `npm create` or `yarn create` or `npx`.

We have to get used to run the local dependencies via `npm run command` or `yarn command` instead having global dependencies that can give us headaches after some time.
Distro hopping
Published: 2021-03-07 00:12:13

How many of you keep several Linux distributions installed on one or more computer systems?

I've been doing it for 20+ years and I have had as many as 12-13 distributions installed at the same time on one system.  I'm currently running 6-8 on my main laptop with an 8 TB disk drive and 8 GB of system memory.

I also have a few old (10 years+) systems that are good for testing "efficient" systems with minimal hardware requirements and support for aging hardware.

Lastly I have a recent generation smart phone and a current generation Chromebook so I can risk "breaking" something, though it seldom happens; I have to be either tired, careless or both.

Oh, I'm retired now so this is my stay at home hobby; my other hobby is water aerobics exercise.
Kentang Goreng Spiral
Tags: kentanggoreng, kentanggorengspiral
Published: 2021-03-05 12:27:11

Pengen bikin kentang goreng yang lain dari biasanya???
Kentang goreng sangat digemari oleh semua kalangan terutama anak-anak. Kentang Goreng sangat cocok dijadikan sebagai cemilan saat santai atau saat nonton televisi bersama keluarga tercinta di rumah.

Kentang goreng spiral adalah solusi membuat kentang goreng yang lain dari biasanya. Penggemar kentang goreng, wajib coba !!!! 
Dijamin, pasti ga akan beli kentang goreng lagi di luar karena kentang goreng yang satu ini teksturnya lebih garing dan dijamin enak.

Resep kentang goreng spiral
Bahan-bahannya:
3 buah kentang ukuran sedang
3 sdm tepung maizena
3 sdm susu cair full cream
2 sdm keju parmesan (bisa diganti cheddar parut)
1 butir telur
1 sdt merica bubuk (kalau ga suka bisa skip)
1 sdt kaldu bubuk 
secukupnya garam ( aku skip karena kejunya sudah asin)
Daun bawang, peterseli (sesuai selera)

Cara membuat kentang goreng Spiral :
Rebus kentang hingga matang. Biarkan dingin setelah itu kupas kulitnya. Hancurkan kentangnya menggunakan garpu hingga halus. Tambahkan tepung maizena kemudian aduk hingga tercampur dan menyatu dengan kentang. Setelah itu tambahkan keju, susu, telur beserta bumbu-bumbu. Aduk sampai semuanya tercampur merata. 

Panaskan minyak (gunakan sedikit saja minyak) dan sebaiknya goreng menggunakan teflon.
Gunakan piping bag (palstik segitiga) ini untuk mempermudah membuat bentuk spiralnya. Masukan kentang kedalam plastik segita kemudian gunting bagian ujung plastik.
Cetak di atas minyak yang sudah panas.
Goreng hingga berwarna kuning keemasan kemudian angkat dan tiriskan.

Untuk lebih jelas tentang resep dan cara membuat kentang goreng yang enak, bisa klik link video dibawah ini.
https://youtu.be/Gg6IVL4hbLs

Kentang goreng spiral ini bisa dijadikan sebagai ide usaha di rumah,disajikan bersama saus sambal atau mayonaise.


Source: https://ceritatipsdanresep.blogspot.com
How to print the full webpage using JavaScript?
Tags: javascript
Published: 2021-03-07 00:00:00

---
  title: How to print the full webpage using JavaScript?
  published: true
  tags: JavaScript
  date: Sun Mar 07 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/print-full-webpage-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-a4edb65a11d0e39967ce68c90faaedaa.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/print-full-webpage-javascript)
  
To take a printout of the full webpage in JavaScript, you can use the `print()` method in the global `window` object.

```js
// Print full webpage 🖨
window.print();
```

- Invoking the `window.print()` method will open the print dialog to print the full webpage.

See the working code on [JSBin](https://jsbin.com/zuweyuyulo/2/edit?js,console)

### Feel free to share if you found this useful 😃.

---
Heterogeneous Smart Home Lighting (Part 1)
Tags: smarthome, iot, homeautomation, hass
Published: 2021-03-07 18:24:30

---
title: Heterogeneous Smart Home Lighting (Part 1)
published: true
date: 2021-03-07 00:00:00 UTC
tags: smarthome,iot,homeautomation,hass
canonical_url: https://rendered-obsolete.github.io/2021/03/07/hetero_smart_home_part1.html
series: Smart Home
---

I’ve been messing around with my [“smart home” setup for a while now](https://rendered-obsolete.github.io/2019/11/22/home_assistant.html). I started with [Philips Hue](https://www.philips-hue.com/en-us) for no other reason than it seemed to be the leader or de-facto standard for smart lighting. But, let’s be honest- Hue isn’t cheap, even for the white (non-colored) bulbs; they’re 12-18 EUR or 12+ USD a piece depending on the bundle.

The other day I came across [this post](https://www.the-ambient.com/how-to/ikea-smart-bulbs-on-philips-hue-app-255) about using Ikea brand “Trådfri” smart lights (which start at 10 EUR/USD) alongside Hue. On a whim I picked up a few different models and following the guide:

1. Hue App > ⋯ > Light Setup > Add light
2. Power-cycle the light 6 times

They all showed up like a charm and worked like the rest of my Hue lights. Even the [LED Power Supply](https://www.ikea.com/us/en/p/tradfri-driver-for-wireless-control-gray-10356189/). I was able to add them to existing rooms, and they even went straight into Home Assistant.

However, complications arose when I tried to use non-Zigbee devices (e.g. bluetooth/Wifi devices by [Wiz](https://www.wizconnected.com/en/consumer/), etc.), or non-lights like [Ikea power control](https://www.ikea.com/us/en/p/tradfri-wireless-control-outlet-30356169/) or Xiaomi motion sensor.

The [Ikea Trådfri motion sensor](https://www.ikea.com/us/en/p/tradfri-wireless-motion-sensor-white-60377655/) is a bit odd because while you **can** pair it with 1 or more lights that it simply turns on, that hardly qualifies as “smart”. I’d like to use them like more generalized sensors. I’m particularly excited by the Wiz motion sensor because while larger than some of the other options it can use standard AA rechargeable batteries instead of obnoxious batteries like CR2032:

![](https://rendered-obsolete.github.io/assets/wiz_motion_sensor_eneloop.jpg)

Turns out a lot of these failings can be solved with software (hurray!), but I leave that for my next post.
ORMs complicate your application
Tags: orm, database, sql
Published: 2021-03-12 08:50:53

---
title: ORMs complicate your application
published: true
date: 2021-03-07 00:00:00 UTC
tags: orm, database, sql
canonical_url: https://jhall.io/archive/2021/03/07/orms-complicate-your-application/
---

I remember the first time I was introduced to an Object-Relational Mapper (ORM). It was Perl’s [DBIx::Class](https://metacpan.org/pod/DBIx::Class), which was the default database access layer with [Catalyst](http://www.catalystframework.org/) MVC framework.

At first it seemed cool. It was sexy! I could magically convert my boring relational data into native Perl objects!

But within a year or so, I was bumping into some problems. A typical conversation between my and my work colleague would go something like this:

> **Me:** I have this SQL query that works perfectly. But the ORM is making it really slow. How do I get the ORM to do the right thing?
> 
> **Colleague:** Don’t use the ORM.
> 
> **Me:** Yeah, but…

I’m a stubborn guy. It took a while. But eventually I gave in. I started writing these performance-sensitive queries in straight SQL. Of course, I’d still use the ORM everywhere else.

Then one day I was debugging why the home page of our web app took minutes to load for one customer.

The culprit? The ORM was doing a separate query for every item in a database table, rather than a single join.

![](https://jhall.io/images/picard-facepalm.jpg)

I eventually came around to my current view on ORMs, which I summarize as:

> ORMs make easy things easy, and difficult things impossible.

In other words: The places where where ORMs are easy to use are already easy without an ORM. These are things like <tt>SELECT * FROM users</tt> or <tt>INSERT INTO users VALUES (?,?,?,?)</tt>.

And when the needs are more complex, you end up either doing the wrong thing (like making thousands of queries instead of one), or writing very convoluted ORMish (the language/syntax used to interact with your ORM library) to get your ORM to do the right thing.

As a rule, I now avoid ORMs, and have for the last 10+ years. I’ve never missed an ORM. Not once.

* * *

Ted Neward has expanded on this at _much greater length_, if you enjoy pain, and/or US warfare history, in his article [_The Vietnam of Computer Science_](http://blogs.tedneward.com/post/the-vietnam-of-computer-science/). For a much shorter summary, you can read Jeff Atwood’s summary, [_Object-Relational Mapping is the Vietnam of Computer Science_](https://blog.codinghorror.com/object-relational-mapping-is-the-vietnam-of-computer-science/).
Publishing Code Coverage in Azure CI Pipeline
Tags: devops, angular, azure, beginners
Published: 2021-03-08 00:11:15

---
title: Publishing Code Coverage in Azure CI Pipeline
published: true
date: 2021-03-07 00:00:00 UTC
tags: devops,angular,azure,beginners
canonical_url: https://www.rupeshtiwari.com/blog/publishing-code-coverage-in-azure-ci-pipeline/
cover_image: https://i.imgur.com/oaeFs3U.jpg
---

> Do you want to show **Angular** Code Coverage Report in Azure CI Pipeline then read this article and follow the steps.

## IstanbulReporter in Karma.conf.js

Go to `Karma.conf.js` of your angular project and confirm you have **cobertura** reporter.

```
 coverageIstanbulReporter: {
      dir: require("path").join(
        __dirname,
        "../../coverage/fsms-angular-pubsub"
      ),
      reports: ["html", "lcovonly", "text-summary", "cobertura" 👈 //required],
      fixWebpackSourcePaths: true,
    },

```

## Running Test with Code Coverage Flag

While running test using angular cli make sure you pass `--code-coverage=true`.

```
ng test --code-coverage=true

```

![](https://i.imgur.com/XXYxtHz.png)

## Adding Code coverage Task in Azure Pipelines

Next use `PublishCodeCoverageResults@1` task from azure DevOps to publish the`cobertura` report.

```
- task: PublishCodeCoverageResults@1
  enabled: true
  displayName: Code Coverage
  inputs:
    codeCoverageTool: "Cobertura"
    summaryFileLocation:
      "./coverage/fsms-angular-pubsub/cobertura-coverage.xml"
      # 👆 put your coverage file path
  condition: |
    succeeded()

```

## Showing Code coverage in Azure Pipeline

Now run you pipeline and notice you will see the code coverage report on the pipeline summary.

![](https://i.imgur.com/6LFMWCN.png)

![](https://i.imgur.com/zIGEJDF.png)

![](https://i.imgur.com/qn4sNuG.png)

Thanks and you are all set.

## Become full stack developer 💻

I teach at [Fullstack Master](https://www.fullstackmaster.net). If you want to become full stack developer and grow your carrier as new software developer or Lead Developer/Architect. Consider subscribing to our full stack development training programs. You can enroll to All-Access Monthly membership plans to get unlimited access to all of our video courses, slides, source code & monthly video calls.

- Please subscribe to[All-Access Membership PRO plan](https://www.fullstackmaster.net/pro) to access current and future angular, node.js and related courses.
- Please subscribe to[All-Access Membership ELITE plan](https://www.fullstackmaster.net/elite) to get everything from PRO plan. Additionally, you will get access to monthly live Q&A video call with Rupesh and you can ask doubts/questions and get more help, tips and tricks.

> You bright future is waiting for you so visit today[FullstackMaster](www.fullstackmaster.net) and allow me to help you to board on your dream software company as a Developer,Architect or Lead Engineer role.

**💖 Say 👋 to me!** Rupesh Tiwari [www.rupeshtiwari.com](https://www.rupeshtiwari.com) ✉️[Email Rupesh](mailto:fullstackmaster1@gmail.com?subject=Hi) Founder of [Fullstack Master](https://www.fullstackmaster.net)
Book Review: Accelerate
Tags: bookreview, practices, teamorganization, continuousdelivery
Published: 2021-03-07 21:00:48

---
title: Book Review: Accelerate
published: true
date: 2021-03-07 00:00:00 UTC
tags: BookReview,Practices,TeamOrganization,ContinuousDelivery
canonical_url: https://hceris.com/book-review-accelerate/
---

[![Accelerate](https://hceris.com/static/ff96e8788dc4deefed09b9eb53abfc43/e75d0/cover.jpg "Accelerate")](/static/ff96e8788dc4deefed09b9eb53abfc43/e75d0/cover.jpg)

This seminal book aims to answer one simple yet fundamental question: What makes an organization that develops software successful? This is a topic that has been explored in depth by many, many authors. The key difference is the comprehensive body of research that the authors have compiled. Like, they’re using actual science for this, man.

As could be expected, it is a mixture of product development, practices, organizational alignment, and technical practices. The book is not exploring the topics comprehensively, but it’s definitely a good start.

It comes down to [Continuous delivery](https://continuousdelivery.com/), in the end. Who would’ve thought? Rapid iteration, automation, loose coupling, enablement. You might be familiar with some, or all of these concepts already. However, the key message that I took out of this book is that Continuous delivery is a _business artifact_. It’s not about figuring how what makes developers happy. It’s about delivering more value, using practices that are repeatable.

### The four key metrics

The research they conducted shows a direct link between organizational performance and software delivery performance. Assessing an organization boils down to [four key metrics](https://www.thoughtworks.com/radar/techniques/four-key-metrics).

- Lead time
- Deployment frequency
- Mean time to restore
- Change fail percentage

Any organization doing well in all four is able to deliver quickly in a safe and sustainable way. Intuitively, it was always clear to me that this was the case, but this book brings strong evidence to confirm it. Measuring these metrics in some way is something that any team can do.

## Verdict

This book is an absolute must-read if you have any interest in delivering value through software for an organization. It’s a compact and digestible book. I not only recommend reading it but advocate for it to be read across any organization that you’re part of. It’s a clear ⭐⭐⭐⭐⭐ stars.
Why did I choose software engineering ? 
Published: 2021-03-06 23:42:29

It’s been a while since I was able to sit in front of my laptop and just code. I chose this career field over 15 years ago back in 6th grade when my teacher Ms. Matthews had introduced me into Mouse Squad and showed me the ins and outs is some of the first generation MacBooks. She introduced me to a program called Scratch and from that moment forward I was HOOKED. 

I continued into high school / vocational school for computer science and it all just came to me naturally. Unfortunately even tho it came to me naturally I wanted to try to pursue a career in Psychology when I got accepted in college, and Boy was I wrong in changing fields. 
Don’t get me wrong I love Psychology but I missed Coding/Programming so much that I decided to switch majors, that’s when I got into CUNY Hunter College. 

Now everything was going perfect! I was learning Python and was on the road to getting my BA in Computer Science. But others plans less that astray.

Now after 3 years out of college, I am trying my hand again at completing this goal of mine and finally becoming a Software Engineer. 

I will get through Flatiron School and find my dream job! 

First Mile Down. Rest of the program here I come!
Deploying Node.js app with Heroku config vars
Tags: node, heroku, todayilearned
Published: 2021-03-06 23:30:50

I tried to deploy my Node.js project via Heroku and got the following error message:

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6xbx3btawj33nzu3xk0y.png)

To see more details, I `cd` into the project’s directory and enter `heroku logs --tail`. The error is `Cannot find module '../../config'`.

## config.js file 🧾
I have a config.js file at the project root (and is included in `.gitignore` so secrets not exposed!!):

```
var config = {};

config.baseUrl = "http://teamcity:8111/app/rest";
config.apiKey = "XXX";
  
module.exports = config;
```

## Function before 
My code looked like this (striped out irrelevant bits):
```
const axios = require('axios'),
    config = require("../../config"); // ✨

exports.getAll = (req, res) => {
    axios({
        method: "get",
        url: `${config.teamCityBaseUrl}/builds`,
        headers: { 'Authorization': config.teamCityApiKey }
    }).then(response => {
        res.send(response.data);
    }).catch(error => {
        console.log(error);
    });
};
```

## Solution ✅
Add your new config vars in Heroku and then access them in your code like `process.env.TEAM_CITY_BASE_URL`.

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x141z9sl4774ofwy80iq.png) 

## Function after
```
const axios = require('axios');
 
exports.getAll = (req, res) => {
    axios({
        method: "get",
        url: `${process.env.TEAM_CITY_BASE_URL}/builds`,
        headers: { 'Authorization': process.env.TEAM_CITY_API_KEY}
    }).then(response => {
        res.send(response.data);
    }).catch(error => {
        console.log(error);
    });
};
```

## 🤩 Website loads perfectly with no errors 🤩
A modern and ready-to-use avatar package for Flutter
Tags: flutter, development, software, mobile
Published: 2021-03-06 23:11:37

---
title: A modern and ready-to-use avatar package for Flutter
published: true
description: An avatar widget that uses the best available data source among those provided (social images, gravatar, name initials, custom)
tags: flutter, development, software, mobile
cover_image: https://pub.dev/static/img/pub-dev-icon-cover-image.png
---

A complete avatar widget with a priority & fallback system which allows you to specify multiple image sources like socials (Facebook, Instagram, GitHub, Gravatar) and custom providers (assets and network) or to use text (name initials or custom values).

Find more here: [https://pub.dev/packages/avatars](https://pub.dev/packages/avatars)
Custom Switch in Android
Tags: android, switch, mobile
Published: 2021-03-06 22:51:33

In this tutorial, I will show you how to take control of a switch and change its appearance.

We can change the track and the thumb of our switch by creating new drawable objects.

## Track

Below is an example code for the track.
#### **`switch_track.xml`**
```xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="false">
        <shape android:shape="rectangle">
            <solid android:color="@color/salmon_pink"/>
            <corners android:radius="1dp"/>
        </shape>
    </item>

    <item android:state_checked="true">
        <shape android:shape="rectangle">
            <solid android:color="@color/green"/>
            <corners android:radius="1dp"/>
        </shape>
    </item>
</selector>
```
We defined a selector that selects an appropriate object (one of two) depending on the switch state (android:state_checked).

Then it is needed to assign our newly created track to the switch. 
We do that by putting this line of code in switch definition. 
```XML
 <androidx.appcompat.widget.SwitchCompat
   ...
   app:track="@drawable/switch_track"/>
```

##Thumb
It is very similar to changing track - creating a selector that shows the appropriate thumb depending on the switch state.

#### **`switch_thumb.xml`**
```xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/switch_thumb_unchecked" android:state_checked="false" />
    <item android:drawable="@drawable/switch_thumb_checked" android:state_checked="true" />
</selector>
```


And below is an example code for thumb in checked switch.
```xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape>
            <solid android:color="@color/green" />
            <corners android:radius="7dp" />
        </shape>
    </item>
    <item
        android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/white"/>
            <corners android:radius="5dp"/>
            <size android:height="30dp" android:width="60dp"/>
        </shape>
    </item>
</layer-list>
```

Passing thumb to the switch.
```xml
 <androidx.appcompat.widget.SwitchCompat
    ...
    android:thumb="@drawable/switch_thumb" />

```

## The result
The possibilities are endless. You can create a switch that will perfectly fit your application.
![final result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9esx61vlcwfxq48ahu7b.gif)