teleren/devto huggingface dataset:
Git Diff Cached
Tags: git
Published: 2020-07-14 13:53:48

---
title: Git Diff Cached
published: true
date: 2020-07-13 16:08:44 UTC
tags: git
canonical_url: https://www.miketmoore.com/post/git-diff-cached/
---

Recently, I've been doing some semi-experimental UI work, where I know what changes I need to make but some of the details aren't clear to me. So, I end up making the changes, but I've changed more files than I want to include in a single commit. Using git, there are a few different ways to pick and choose which changes should be staged for a commit. One of the most common methods I use goes like this:

1. make changes
2. stage _some_ of the changes for commit (using `git add`)
3. reviewing the staged (added) changes
4. making the commit

In this post, I am briefly going to explain how I do step #3 above, "reviewing the staged (added) changes".

Basically, if I have just staged changes using `git add`, then a normal `git diff` won't show me those changes. It will only show me the changes that have _not_ been staged. So, I add the `--cached` option:

```
git diff --cached
```

...and, voila! I can see the diff of the changes that are currently staged for commit.

If you are new to git, this is how you can scroll up and down, and exit the diff, using the following keyboard shortcuts:

- <kbd>j</kbd> scroll down
- <kbd>k</kbd> scroll up
- <kbd>q</kbd> quit

So, if I'm satisfied with the changes, I can go ahead and commit:

```
git commit -m 'my commit message'
```

...or, if I realize that the changes should not be combined, I can "un-stage" them:

```
git reset HEAD .
```

From the official docs:

> This form is to view the changes you staged for the next commit relative to the named <commit>.

https://git-scm.com/docs/git-diff#Documentation/git-diff.txt-emgitdiffemltoptionsgt--cachedltcommitgt--ltpathgt82308203
Python Zero to Hero - Ep.14 - Python iterators
Tags: python, tutorial, iterator, video
Published: 2020-07-13 17:18:16

---
title: Python Zero to Hero - Ep.14 - Python iterators
published: true
description: In this tutorial, we will investigate Python's iterators. Whenever you are doing a for-loop, an iterator is created under the hood. Let's have a closer look at this mysterious Python object.
tags: python, tutorial, iterator, video
---
In this tutorial, we will investigate Python's iterators. Whenever you are doing a for-loop, an iterator is created under the hood. Let's have a closer look at this mysterious Python object. If you have any questions or any suggestions about which Python topics to cover, please leave your comment at my [Twitch channel](https://www.twitch.tv/cheukting_ho)

You can get the slide deck [here](https://slides.com/cheukting_ho) and the example code and homework form [GitHub here](https://github.com/Cheukting/python02hero). Ask questions at my [Twitch channel](https://www.twitch.tv/cheukting_ho)
My Soapbox About Resource-Hungry Chrome
Tags: chrome, cpu, ram, performance
Published: 2020-07-13 17:09:32

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

I don't need to speak too much on this, actually. It's just that no one speaks about this. I keep hearing, "Gaah, don't use Chrome now. It is resource hungry. It drains your battery! Use a Chromium-fork, Firefox, or Safari." Okay, geniuses, let's build 2 apps. Let's make app A use less CPU and less RAM. Let's make app B use more CPU and more RAM. Guess which one will run faster? Nine times out of 10, app B will run faster. Now, what do people want MOST out of their browser? Faster page load times. So, sure, go ahead and switch your browser to one that dedicates less resources. Not me. I'll stick with one that makes my web pages load faster -- Chrome and Chromium.
GNU timeを知った
Tags: linux
Published: 2020-06-17 10:15:49

[High Performance Python 2nd Edition](https://www.oreilly.com/library/view/high-performance-python/9781492055013/)を読む中で、
timeはGNU版と簡易版の二つがあることを知った。

### time（シェル組み込み）
bashやzshのプロンプトでパスが通っている `time`はシェル組み込みのtimeで、簡易版らしい。

```
# zsh
$ time sleep 1
sleep 1  0.00s user 0.00s system 0% cpu 1.004 total
```

### GNU time
`/usr/bin/time`にインストールされたコマンドはGNU版で、上記よりもリッチな情報を出すことができる。

macの場合は`brew install gnu-time`で`gtime`としてインストール可能。

```
$ gtime --verbose sleep 1
        Command being timed: "sleep 1"
        User time (seconds): 0.00
        System time (seconds): 0.00
        Percent of CPU this job got: 0%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.00
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 612
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 297
        Voluntary context switches: 0
        Involuntary context switches: 17
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0
```

`Major (requiring I/O) page faults`は、スワップの発生を意味しており注意すべきメトリクスである。
Backdrop Filter effect with CSS
Tags: css, filter, html, webdev
Published: 2020-07-13 16:59:45

Yesterday i came upon a really cool looking effect on a website and tried to reproduce the effect for a new web app i was developing. It had a transparent container create a filter backdrop on the background image behind it and it was really neat. 

Here's the effect:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/js572vt4pnpd3yqc7t7x.png)

I tried the usual css property filter: blur(10px) but that only blurred the container itself and not the background behind the element. After some research i found a super simple one line css property to do just that. Since then i've been using it in every app or design i created (where appropriate).

here it is:

```CSS
.container {
    backdrop-filter: blur(10px);
}
```
I had no idea that CSS property existed!

Now add a background image behind your container and watch the magic. Pretty cool right?

Note: Some browsers may not support the property. But the major ones like chrome, firefox and edge do.

Try it out and let me know what you think. Till next time!
What do developers want?
Tags: discuss, serverless, kubernetes
Published: 2020-07-13 16:59:18

It's now been over 14 years since AWS launched the Simple Storage Service (S3), Simple Queue Service (SQS) and Elastic Compute Cloud (EC2). These three services ushered in the modern era of *cloud* as a set of utility services that developers can build on top of.

Since then, we've seen attempts to redefine cloud in terms of *Platform as a Service (PaaS)* starting with Heroku and Google App Engine (GAE) in 2008. *PaaS* has been through several iterations, but Kubernetes is currently the most popular tool for building *PaaS*-like services. It has garnered a huge amount of developer mindshare, vendor support, open-source contributions and attention.

We've also seen the *serverless* revolution kicked off with AWS Lambda in 2014. *Serverless* has been massively popular with a subset of developers, and also has lots of community support, educational resources, and so-on.

But while working at AWS and as part of the EC2 team, I realized that lots of the design choices and APIs in the cloud are driven by what is feasible to build. Sure, AWS tries to "work backwards" from the customer, but many AWS APIs seem like they are **working forwards** from design or physical constraints. Why do Lambda functions need to mess with networking and IP addresses? Why is AWS billing so complicated? Why does AWS need 200+ services? Why is DNS so hard?

If the current set of cloud services is not the end of the road, then what comes next? Will containers, or EC2 be like the humble array or class, and be taught to new developers for decades to come? Or, will they be like the FORTRAN programming language, mostly consigned to the dustbin of history? Or, will they be like the C programming language, used for low-level tasks, but not by the majority of developers?

Will so-called NoCode or low-code solutions be the future? Will it be platforms like [Glitch](https://glitch.com/) targeted at specific languages or communities?

I'm curious what people think.
Use recoil in react custom hooks
Tags: react, recoil, state, hooks
Published: 2020-07-13 16:58:26

[Recoil](https://recoiljs.org/) is a hot new state management tool from Facebook that handles the state sharing problem gracefully with a minimal API. I recommend everyone check it out. It's an amazing tool that feels very react-y and require little to little to no boilerplate code. I'm not going to cover it too much in this article. Check out the [official documentation](https://recoiljs.org/) for more information.

As amazing as it is, the library do have its own limitations. One of the biggest limitation is that the `useRecoilState` and `useRecoilValue` hook does not work properly in custom hooks. Since recoil only subscribe and update those values inside react component. We will have to update the value by ourselves.

How? You may ask. It's magic time, let's use `useRef` 

**Voilà**

```typescript
import { useEffect, useRef } from 'react';
import { useRecoilState } from 'recoil';
import { someAtom } from './recoilstates/someState';

const yourCustomHook = () => {
  const [someState, setSomeState] = useRecoilState(someAtom);
  const latestSomeState = useRef(someState);
  
  useEffect(()=> {
    latestSomeState.current = someState;
  },[someState]);
  
  // I use useEffect here as an example,
  // custom hook can contain any React hooks
  useEffect(()=>{
  	// your custom hook logic here
    // use latestSomeState.current for latest value
  });
}
```

 By using useRef, and useEffect, the react component which this hook is used in will be subscribed to recoil state changes. Therefore, you can get the latest version of the state value in the hook.
Colour emotes :)
Tags: colour, design, uiweekly, ux
Published: 2020-07-13 16:55:45

#Disclaimer ⚠ 
This blog does not teach you the colour theory

#Storytime 🎤
I have been fascinated by colours because from every element in the design forum, colour is the concept I find reflecting mood most precisely and instantaneously for obvious psychological reasons. I was branding (SVACH- A natural-soap company)[https://www.behance.net/gallery/100529153/SVACH] as a personal project so I wanted it to reflect a mood of Nature🍂, like making it connected to nature as much as possible. So I went for shades of Brown(soil) and Green(trees), both signify nature pretty well, they do right?
![Colour panel to show the use of colours](https://dev-to-uploads.s3.amazonaws.com/i/elx7novy7fz78pi0s9cz.png)

#Learning 🙌
I tend to find the mood, personality, the attitude the respective design wants to reflect and then just relate that emotion to the colours if I am not able to find something or I am confused then researching a bit helps every time. For instance, I was trying to put a colour for an error field in a form which should be less aggressive as red comes in as fearful, we get scared a bit when we see that bright red in an error field so I choose to use orange-ish as an error field which did not come in not as aggressive and served the purpose of stating an error.
![The error field](https://dev-to-uploads.s3.amazonaws.com/i/pjvd33em2lt81jfv6144.PNG)

Once I find the correct colour(s) to signify the mood it is then when I start using the colour theory and curate a palette to be used for the respective design system

#Conclusion 👋 
If you choose the correct colour(s) 'with' proper design elements(they are equally important to signify the design personality) like typography, imagery, etc your design will help to reflect the ideas it is meant to :)

#Read my previous blogs 🔊
{% link https://dev.to/devanshgajjar/research-design-b6d %}
{% link https://dev.to/devanshgajjar/why-is-it-difficult-to-be-a-designer-graphic-hci-in-india-53oi %}

#Connet with me 🙏
Twitter [@gajjar_devansh](https://twitter.com/gajjar_devansh) you can have a look at my designs on Behance [@devanshgajjar](https://www.behance.net/devanshgajjar)
When to render on node vs Vue?
Tags: javascript, node, vue, discuss
Published: 2020-07-13 16:47:07

So, I already know Vue and I just finished up a course on learning node. The part I am having trouble getting a grasp on right now (as I try to put this into practice) is when should I use node for rendering the pages vs using something like Vue to just connect to a node API? Are there any hard guidelines to this? Would love to hear what the community's approach is to this. Thanks!
Open Letter to Lutris, Act Like Adults
Published: 2020-07-13 16:43:33

> Update: They made a public apology, thank you, Lutris!
> ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bcbydwusqqlr12mjfbep.png)

Dear Lutris,
I need to complain over a recent Tweet with two words while mentioning a company. This Tweet is dangerous, as it will hurt Linux gamers overall.

![@LutrisGaming Tweet "Fuck you @riotgames"](https://dev-to-uploads.s3.amazonaws.com/i/igfcm9fwmy3mlc009mif.png)

I did reply to the Tweet with the [@UbuntuLumina](https://twitter.com/ubuntulumina) account, but the character limit would not give me the power of voice I need.

![@UbuntuLumina reply "This is dangerous"](https://dev-to-uploads.s3.amazonaws.com/i/yeinmez6r252cm5hko4q.png)

Here is my concern. Lutris is a powerful platform for gaming on Linux. It is the most popular, and until now probably the most respectable. While you may or may not have reason to hate RiotGames over the inclusion of the Vanguard anti-cheat, you are only hurting Linux overall. While I hate the anti-cheat changes myself, only you are in the wrong.

The Linux community needs Lutris to act like adults, not children. The Linux community needs Lutris to act professional, not rude. The Linux community needs Lutris to be aggressive, not dismissive. Give RiotGames a reason to care about Linux, not a valid reason to ignore it.

I understand the game developer is pushing against Linux users, but saying "Fuck you" to the company isn't going to help. All you are doing is hurting the Linux community, and while you do a lot of good work, this Tweet has a lot of power against the Linux community. This might not hurt the Linux community now, or maybe soon, but it will if attitudes like this keep up. Linux can never grow if we yell at the people who push away our platform. We need to work with these corporations, and not insult them. You gave our enemies ammo. If you do not publicly apologize, if you don't even delete the tweet, so be it. Just don't come crying to the community when you yourself refuse to make changes to the attitudes that hurt the whole community.

- Kai Lyons
Javascript vs Ruby
Tags: javascript, ruby
Published: 2020-07-13 16:33:37

<p>Being a complete novice in `Javascript` and having some very limited exposure to `Ruby` I can already point out some distinctions and similarities of syntax and overall logic in two languages. </p>
I'm guessing that my list will cover only 5% of overall differences and similarities between the two, however this is strictly a description of my personal experience and attitude overall.
As in `JS` in `Ruby` the `Strings`, `Numbers`, `Booleans`, `Arrays` and Objects are the same. However Objects are called Hashes in Ruby and are dealt with slightly different. Another, pleasant surprise for me was that a lot of  built-in methods are the same and have  same, or almost same name. For Example: `.length` `.forEach` `.push` `.pop` `.unshift` etc.
However, right now, on my second week of learning `Javascript` my biggest challenge is dealing with the syntax and overall layout of the code, mostly this - `"{"` thing. What in Ruby dealt with "end" statement, `JS` puts in `"{"` that, for me personally, makes it harder to trace one piece of logic, it's starting and ending point.
Another very interesting thing for me, was that you can add a `"String"` to a `"Number"` or a `"null"` to basically anything. Ruby will immediately protest such a behavior giving out:"TypeError: no implicit conversion from `nil` to `integer`". In Ruby you cannot concat any type of data to another type without convert it to the same. 
~~~js
21 + "21" === "2121"
// in Ruby will look like this
21.to_s + "21" == "2121"
~~~

There are many more differences between two languages that I am very anticipated to explore
Browser routing with canvas GSPA
Tags: javascript
Published: 2020-07-13 16:27:09

Recently, I decided to try writing a designer for games with a component approach based on JSX and PIXI.JS
{% link https://dev.to/tetragius/jsx-for-graphics-173p %}

{% youtube 9kd0ry7RW08%}

I have added route support to my project. You can now navigate using the [history](https://github.com/ReactTraining/history#readme) library while only `hashHistory` is supported.
Should you unit test?
Tags: unittest, webdev, productivity, tech
Published: 2020-07-13 16:21:48

"I've always avoided it because it seems like so much extra work" - Tommy Williams

Once you learn about unit testing, and how it works, the natural question is: Is it worth it? When you learn about the other types of testing, specifically End-to-End, which REALLY makes sure that your application works, then why bother with unit testing? As my friend Tommy above so eloquently put it…it just seems like so much extra work.

Well, I think we can quickly go over some really good information about why unit testing truly is a good idea.

I'm going to focus on two of the very many benefits of unit testing.

**First: Finding Hidden Deficiencies**

In order to understand this benefit, I'll use an analogy. Let's say you are building a car, and you want to test that the car is working properly. An End-to-End test is basically taking that car out for a drive and seeing if it works properly. That seems like that's all you need right? If the car is good, then you're good yes?

Well, let me tell you a short story about the two cars I bought last year. Both of them had hidden cracks in the header, which showed up only after a while. They were devastating flaws that basically made the cars worthless.

Now let's look at how a unit test could have helped. If I had been able to extract just that one part and look at how it was operating in isolation, I could have found the deficiency. Any experienced developer will tell you that a working system still definitely has bugs. Hidden away, just waiting to come out at an inopportune time.

**Second: Improved Architecture**

In order to do unit tests, you have to be able to extract a single unit, and "exercise" it in isolation. This requires that the unit is easily isolated from its dependencies and collaborators. If you can do this, then your unit follows several best practices for good design and architecture. Simple.

But wait, you say what if I just write my code that way anyway? Then I don't need unit tests. Well, recognize that in this case, the unit tests are actually a test of good architecture. They don't rely on you THINKING that you have followed these principles of good architecture. They only work if you really HAVE followed these principles.

That way it's a check on your implementation of these principles.

These are just two of the many reasons to write unit tests for your code, but they are in my opinion two very compelling reasons.

Happy coding!

Signup for my newsletter [here](https://thinkster.io/?previewmodal=signup?utm_source=devto&utm_medium=blog&utm_term=shouldyouunittest&utm_content=&utm_campaign=blog).
Visit Us: [thinkster.io](https://thinkster.io?utm_source=devto&utm_medium=blog&utm_term=shouldyouunittest&utm_content=&utm_campaign=blog) | Facebook: @gothinkster | Twitter: @GoThinkster
How to protect your JS ?
Tags: help, discuss, security
Published: 2020-07-13 16:20:51

Hi,

I am looking for a way to secure my JS code.

`Edit: I do not want my code to be run by others in their local by cloning my API behaviour. Secondly, if Obfuscation is OK, is there any best practices other than going to an online obfuscator` 

I know there is Obfuscating JS. But, I do not know how safe it is.

It'd be great if someone can answer these for me.

 - Is Obfuscation safe ?
 - How to properly Obfuscate your JS ?
 - Are there any techniques to secure JS apart from Obfuscate ?
ASP.NET Community StandUp : FAST Framework
Tags: webdev, javascript, dotnet, css
Published: 2020-07-13 16:12:26

[FAST](https://fast.design) is a collection of JavaScript packages centered around web standards, designed to help you efficiently tackle some of the most common challenges in website and application design and development.

In this episode, Rob Eisenberg sits with us to run through a number of the components, a [Blazor web assembly](https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor?WT.mc_id=blog-devto-shboyer) example and answer questions about the what and why and talk about the roadmap for FAST!

{% youtube sYTH_xYH3iA %}

Be sure to subscribe to the [.NET Foundation Channel](https://www.youtube.com/channel/UCiaZbznpWV1o-KLxj8zqR6A) for more great .NET Content

### Links from the show

* [Jon's Community Links](https://www.theurlist.com/aspnet-standup-2020-07-07)
* FAST - https://fast.design
* [FAST Github repository](https://github.com/microsoft/fast/)
* [FAST Component explorer](https://explore.fast.design/components)
1 line of code to check all your code documentation
Tags: codequality, python, machinelearning, productivity
Published: 2020-07-13 16:11:37

If { 
   ✅ you have code in Python
   ✅ you are not sure which documentation of the code is reliable
   ✅ don't have time to check for it manually 
   }

Then : definitely look for [codeBERT library](https://github.com/autosoft-dev/code-bert)

codeBERT is an open-source package to automatically check if your code documentation is up-to-date. codeBERT uses Machine Learning on code to classify the docstring of functions. 
Given a function f and a doc string d a code-bert predicts whether f and d are matching or not.

{% twitter 1280287022041698306%}

So far the accuracy of the library is pretty stable around 93-95% when it comes to detect if a docstring is outdated.
🔥  My Favourite All in One Note Taking App Notion ( With Templates).
Published: 2020-07-13 16:03:34

Notion, A new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team.

🎉 Notion is free now! If you would like to try out the pro plan, feel free to use this referral link, where you'll get a $10 credit towards Notion Pro.

https://scrolltest.com/notion

FREE Templates: https://notionpages.com/



[![ Productive As Software Tester](https://i.imgur.com/Dlw5APl.png
)](https://youtu.be/qeE-Sn_3Abk "Productive As Software Tester")

-----------------------------------------------------
👪 Join our Community - http://bit.ly/learntesting2019
✅ Automation Tester Community - https://thetestingacademy.com
🐦Follow us on Twitter  - https://twitter.com/itstechmode
📖 Like us on Facebook - https://www.facebook.com/scrolltest
🎤  Listen to our Podcast - https://anchor.fm/thetestingacademy
------------------------------------------------------


--
Be sure to subscribe for more videos like this!

[![ TheTestingAcademy](https://dev-to-uploads.s3.amazonaws.com/i/r7vcy6wbvyjbk1y1uu0o.png
)](https://www.youtube.com/TheTestingAcademy?sub_confirmation=1 "TheTestingAcademy")