teleren/devto huggingface dataset:
Gulp Runner - Dipping my toes into Github Actions
Tags: actionshackathon
Published: 2020-09-14 15:56:33

## Hello Github Actions

GitHub actions are something that I was always curious about but never really explored, thanks to this hackathon I took a dive and was able to come up with something that actually solves one of my problems.


### Gulp Runner

Like many of us, I have a [personal site](https://2kabhishek.github.io) deployed on GitHub Pages. 🌐

It uses SCSS so I have to convert it to CSS pre-deployment, I also like to have my scripts and styles minified.
While building the site I used gulp for these tasks and everything worked as it should.

The only issue is when I have to make some quick updates to the styles or scripts on a new machine or on my phone, I have to setup the local dev environment along with node, npm and lots of node modules.

While reading up on GitHub actions this is the problem that came up to my mind, that can be fixed quite easily using a simple workflow. 🤔

What this action does is, on push events it looks at changes in the script and styles file. If it does find any changes It runs and carries out the gulp tasks (sass -> css & minifying) and makes a new commit.

Thus allowing me to tweak my site from anywhere without worrying about node or npm at all. 📱😁


### Submission Category: 

- Phone Friendly
- DIY Deployments


### gulp-runner.yml

```yaml
name: Run gulp tasks

# Controls when the action will run.
on:
  push:
    # On which branch
    branches: ["master"]
    # On which files
    paths: ["scripts/scripts.js", "styles/styles.scss"]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # Job name
  build:
    # Runner name
    runs-on: ubuntu-latest

    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
      # Sets up node
      - uses: actions/setup-node@v1
        with:
          node-version: 12
      - run: npm ci
      - run: gulp
            
      - name: Commit files
        run: |
          git config --local user.name  ${{ github.actor }}
          git add -A
          git commit -m "Update gulp output files"
      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.REPO_GITHUB_TOKEN }}
          # force: true

```


### Additional Resources / Info

My portfolio site's repo, using this workflow
{% github 2kabhishek/2kabhishek.github.io %}

My unsuccessful attempt to turn it into a reusable action, need some more reading, If anyone knows what I'm doing wrong please help me out. 🙏🏼
{% github 2kabhishek/gulp-runner %}
Sorting with ls in Linux
Tags: linux, beginners, ubuntu, devops
Published: 2020-09-14 15:56:33

Almost every person uses Linux knows the command `ls`. However, most stopped at `ls -l`, `ls -lh`. However, `ls` is much more powerful than that. Let me show you some simple options/flags you can use with `ls` to sort the result so you can exactly what you need.

### Sort by file name
To sort list by file name, simply type:
`ls -l`
The default sort order is from 0 to 9, a to z.

### Sort list by file size with `S`
You can use the following command to sort the result by file size, from large to small:
`ls -lS`

![list file by file size](https://dev-to-uploads.s3.amazonaws.com/i/mgs914b2ddhnpbk1sh8j.jpg)

If you need a more readable result, use `h`
`ls -lhS`
![list file by file size with readable size](https://dev-to-uploads.s3.amazonaws.com/i/9kw4s5gyo5iqijpw6umq.jpg)

### Sort list by modification time
To sort the list by modification time (the time a file was modified), from newest to oldest, simply add `t`:
`ls -lt`

![Sort list by modification time](https://dev-to-uploads.s3.amazonaws.com/i/jkdkr2z99f9btrxuygx1.jpg)

### sort list by access time
If you want to sort the list by access time (the time a file is accessed, for example, you run `cat` on that file), use this:
`ls -lut`

![Sort list by access time](https://dev-to-uploads.s3.amazonaws.com/i/64q6ef83ofs5lm3o3gdg.jpg)

As you can see in the example, the first time I ran `ls -lut`, `poem.txt` is at the top. However, after I ran `cat er.txt` (which accessed the file er.txt), then ran `ls -lut` again, `er.txt` is shown at the first position.

Hopefully, this post has helped you use `ls` in a more efficient way. Comments are highly appreciated.
What's the Latest Project You're Working On?
Tags: productivity, discuss, career, showdev
Published: 2020-09-14 15:54:54

If you haven't read my [post](https://dev.to/jeannienguyen/do-you-have-your-own-website-portfolio-26al) about having your own website/portfolio, I've been looking for inspiration to build mine.

I'm currently finishing up my website and a music project right now! Side projects are fun, because I can build on any idea that I have.

I'm really curious to see what all the bright minds are up to! What's one project (feel free to share more than one) you're working on right now that you're really proud of? Which stack are you using to build it? What's the most difficult error or problem you've run into on that project?

If you've already launched your project, feel free to share it below too.
Output of 'Math.max() < Math.min()' ?
Tags: javascript, webdev, codenewbie, beginners
Published: 2020-09-14 15:52:54

```
console.log(Math.max() < Math.min()); // true
```

The default value for `Math.max()` is `-Infinity` &
the default value for `Math.min()` is `Infinity`

Hence, `-Infinity < Infinity => true`

---

**Thanks for reading 💙**  
Follow **@codedrops.tech** for daily posts.  
[Instagram](https://www.instagram.com/codedrops.tech/) ● [Twitter](https://twitter.com/codedrops_tech) ● [Facebook](https://www.facebook.com/codedrops.tech/)

Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript  
**[codedrops.tech](https://www.codedrops.tech/)**
Recording E2E Test in React with Cypress & GH Actions.
Tags: actionshackathon, testing, react
Published: 2020-09-14 15:30:56

On my path to learn TDD, and making robust, resilient app I finally learned end to end testing. I added e2e test cases to the React Login Mock app using cypress.io.

> I would like to add that cypress provide great developer experience.

This what a recording looks like. In the recording below I am running two test case 

- Successful login attempt with valid user credentials.
- Error handling when server responds with an error.


![Cypress Recording](https://res.cloudinary.com/stud2design/image/upload/v1600189666/cypress-run_jnmg99.gif)


### My Workflow

After adding end to end test cases to my project using cypress and developing the app with confidence I wanted to make sure that every code change that is happening in my project is also e2e tested. Thanks to Cypress headless run I was able to e2e test my code for every code push and pull request using Cypress Github Action.

```yml

...

- name: Cypress run
        uses: cypress-io/github-action@v2
        with:
          browser: chrome
          headless: true
          record: true
          start: npm start
          wait-on: http://localhost:3000
        env:
          CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

...

```

Cypress Github Action also let you record your test run and upload it to your cypress dashboard.


### Submission Category: 

Maintainer Must-Haves, DIY Deployments


### Link to Code

You can find the project along with the cypress test cases at

{% github dreamer01/react-login-mock no-readme %}



### Additional Resources / Info

{% github cypress-io/github-action no-readme %}

[Cypress.io blog post on Github Action](https://www.cypress.io/blog/2019/11/20/drastically-simplify-your-testing-with-cypress-github-action/)
How Java sustained Two Decades 
Tags: java
Published: 2020-09-14 15:27:48

Java is one of the few programming languages that survived in the industry for more than 20 years. *Often criticized for being too clumsy and difficult, Java is still widely used across industries.* Most people know that it is the primary language for Andriod and so we can say that it is the main language of these age smartphones. It is also used in many back-end web developments, building mobile apps as well as in many software systems worldwide. In this post, I tried to explain how java surviving even after python & javascript are here and why can also learn it in 2020.
##1) Java can do EVERYTHING
This is by far the major reason for java to stay alive and strong today. You can build android apps, software desktops apps by just learning one language. Java seems to be the most promising language in the new world of the Internet of Things (IoT) and is used by all the leading service providers like Google and Microsoft. Java is an object-oriented language, and most companies prefer people with a fair knowledge of the OOPs concept.
##2) Java has a Big COMMUNITY
Java has one of the strongest communities in the world of computer programming, (while [javascript has the biggest](https://www.sitepoint.com/javascript-remains-the-queen-of-programming-languages) but the experience count in more for java). Moreover, when you encounter any other problem, you can easily find the solutions online or ask in any forum & you will get a quick reply. It provides an open-source library and meets all your needs. Since it is decades old, there are many free resources and courses online as well. You can also get a [java tutor online](https://favtutor.com/java-homework-help) to get solve all your queries or get help with your homework or assignment. Though it is not essential for aspiring programmers to be well equipped in Java, if you are going into the programming world for a lifetime, learning this will surely help you.
##3) Java EVOLVES
It is an ultra-fast language with a scalable platform that has adapted itself to the IT world. After Java 9, Oracle decided to adopt a new lifecycle for Java release, which guarantees new features and additions to the language.Java programming provides developers an extremely rich API to create graphical interfaces for the desktop, manage multithread programming, perform network operations, and access databases without any external code libraries. The recent launch of Java 14 bears witness to the evolution of the language.
I think these are all very big reasons for java to sustain and stay strong for such long. I personally was once so much critical of it, but now I understand that Java had and is doing so much in the current world, that no one can think about how the world would be if there is no Java.
EC2 Tagging MKII
Tags: aws, bash, linux, devops
Published: 2020-09-14 15:27:01

A few weeks ago I posted about a crude bash script to [tag your EC2 resources](https://dev.to/paulmicheli/easy-ec2-tagging-47od), I have since tweaked the script to use the instance ID to find the `volumes` and `snapshots` associated with each instance ID.

It will also dynamically pull in account to use from your AWS config file.

Have Fun

```bash
#!/bin/bash

## Functions

tag_rescources () {
aws --profile=$profile --region=$region ec2 create-tags --resources $1 \
    --tags Key="COST CENTRE",Value="$cost" \
      Key="APP",Value="$app" \
      Key="ENVIRONMENT",Value="$environment" \
      Key="OWNER",Value="$owner" 
}

get_volumes (){
aws --profile=$profile --region=$region ec2 describe-volumes \
  --filters Name=attachment.instance-id,Values=$1 \
  --query "Volumes[].VolumeId" --output=text
}

get_snapshots(){
aws --profile=$profile --region=$region ec2 describe-snapshots \
  --filters Name=volume-id,Values=$1 \
  --query "Snapshots[].SnapshotId" --output=text
}


## Script
echo "Use this script to tag EC2 instance in the desired account"
echo "Multiple can be enter at once seperated by a singe space."
echo "Below resources are supported using the ID"
echo "            Instance ID"
echo "            Security Group ID"
echo "            Elastic IPs Allocation ID"
echo " "
echo "----------------------------------------------------------- "
echo "Please choose AWS Account Profile"
select profile in `grep '^\[' ~/.aws/config|sed -r 's/\[|\]//g'|awk '{print $2}'`
do
   echo "Please choose AWS Region"
   select region in eu-west-1 eu-central-1 us-east-1
   do

   echo "Please list EC2 Instance ID"
   echo "Multiple can be entered at once, seperated by a singe space."
   read instance
   echo "Please Enter COST CENTRE"
   read cost
   echo "Please Enter APP"
   read app
   echo "Please Enter ENVIRONMENT"
   read environment
   echo "Please Enter OWNER"
   read owner

   ## Tagging EC2 Instances
   for i in $instance
   do
      tag_rescources $i
      echo "Tagging EC2 Instances $i"
   done

   ## Tagging Volunmes
   #! a nested loop is used as the get volume function can only filter one volume at a time
   for i in $instance
   do
         for j in `get_volumes $i`
         do
            echo "Tagging Volume $j beloning to Instance $i"
            tag_rescources $j
         done
   done

   ## Tagging Snapshots
   #! a nested loop is used as the get snapshot function can only filter one volume at a time
   volumes=`get_volumes $instance`
   for i in $volumes
   do
         for j in `get_snapshots $i`
         do
            echo "Tagging SnapShot $j belonging to Volume $i"
            tag_rescources $j
         done
   done

   echo "If no error's above tagging complete"
   break
   done
   break
done

```
Guide to Hacking Hardware Maintenance (as a developer)
Published: 2020-09-14 15:03:14

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

My laptop is 3 years old. I paid $1,426 on a Prime Day sale shipped overseas. It was not the best laptop but my Surface Book needed to be sent back for warranty (battery expansion issue) and the replacement could only ship to Australia... so I needed a new laptop (with a decent CPU and GPU) shipped to Thailand. 

First the battery stopped holding a charge and was expanding, so I just pulled it out, but in the last month first the CPU fan and then one of the GPU fans started to make a LOUD buzzing noise. Normally I would go to Aliexpress and buy replacement parts (which takes upto a month to deliver)... but because I am living in covid-cheap hotels/AirBnB's have no fixed address, buying new is also not an option and had to think outside the box.

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

Before we get into the specifics I wanted to share a lesson from the whole MAX-Q shift. Basically CPUs and GPUs generate a MASSIVE amount of heat the closer to maximum ability so using the same hardware and aiming lower results in great performance (just not the best) with less heat and power usage.

Here are 1 hardware and 3 software hacks that are keeping my poor old laptop alive:

1. More fans (hardware)
Running a i7-6700HQ + GTX1060 gets hot, Thailand's climate doesn't help with a comfortable temp at 24-25C (75-77F) in air conditioned room so the hardware hack is CoolerMaster U3 ($28.73). What makes it special from the million other cooling pads is you can position the fans directly below the intakes. This actually solved the CPU fan noise problem because the fan balance is restored (apparently).

2. Undervolting
ThrottleStop undervolt set to 0.118 V has been the sweet spot and whenever you can hear the fans always check if its working.

3. AfterBurner
Down clocking from +116 MHz to -83MHz did the trick, keeping the GPU cool enough most of the time to not need fan power, thus the annoying buzzing sound.

4. Change "Advanced Power Settings"
This one surprised me but you can right click on the battery icon, click Power Options, Change Plan Setting, Change Advanced Power Setting, find Processor Power Management, then change the Maximum Processor State <100% (I am no 90%) for quite a large thermal improvement

4. The Great Suspender
Let's face it, Chrome is what a developer has running all the time. What The Great Suspender does is wait an hour then suspend any inactive tabs taking massive load off the GPU in my case from the "Desktop Window Manager". This leads to less GPU usage, less heat and no need to buy parts ;)

Bonus. Find out what is using so much resources and Google how to fix it. I recently fixed a Dreamweaver usage issue going into Regedit and deleting some Temp Files folder, now it works fine...
Does not remember git commands a bad thing?
Tags: help, question, discuss, git
Published: 2020-09-14 15:03:06

I've been using git extension in Vscode for a long time so just clicking (to commit, push,...) I do only use commands if it's something complicated that I look for and follow, but now I found myself kind of don't remember the basic commands of git and it's kind of disturbing me a little bit and I don't know if there are people in my case? or is it for you a bad thing or it doesn't matter?
The less known API for Console input in Java
Tags: java, console, api
Published: 2020-09-14 15:00:21

These days with the presence of numerous GUI based and Web based apps, receiving input and data via console has reduced. However, there are applications that require and run in a console. Java applications are not an exception to this. 

Getting input from the user was not as simple in Java as in other languages like `scanf` in C, `cin` in C++ and the `input()` method in Python. In the early days one had to write code like this

```
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
br.read(...)
``` 

The `BufferedReader` construct is itself enough to scare the newbie programmer of Java. 

However, from Java 6 - yes you heard me Java 6 - we had a new API that made getting console input much easier, but the programmer world mostly stuck to the old way and this was least known.

`String input = System.console().readLine();`

which is less scary than the previous one. In addition it also provides a C like format string based input reading as well for interactive input, so you could do something like

```
Console console = System.console();
String name = console.readLine("Please enter your name: ");
System.console().readLine("Where do you live %s?", name);
```

When we run the code, we would see something like this 

```
Please enter your name: Gordon
Where do you live Gordon?:
```

The other wonderful method of the console class is the `readPassword()` that enables to receive a password from the user with the echo disabled when the user types the password.

The Console class also provides the Reader object to read the usual way and also the Writer object. However, the catch is that it requires a terminal to run the main program. If it is run by a background task, the `System.console()` method returns null.

Happy coding!

Image Credits: [Pixabay](https://pixabay.com/users/Clker-Free-Vector-Images-3736/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=311845)
COVID-19 is the greatest thing happened to me in 2020
Tags: productivity, personalstory
Published: 2020-09-14 14:46:22

I like learning and creating new things. I have a list of ideas and personal projects I want to create. The list is getting longer everyday but I procrastinated working on and not complete one of the projects. Because after my full-time job, I was exhausted. I tried to work a bit every night. Someday I didn't do anything. My project had a little progress but I almost felt like giving up and moving to a new thing. I knew that was not good and I would create nothing in the end

Suddenly, COVID-19 pandemic came and everything changed. I heard news about death everyday. People had to work from home. Some lost their job or had pay cut. I was lucky to keep my job and get full salary. I didn't have to work from home. Everyday I not only wished the pandemic to end early but also thought about me. I wondered what if this pandemic continues and I would lose my job, what if I die due to COVID-19 tomorrow and can not complete my projects. I thought about these scenarios so much. It may happen to me. 

Until one day, my grandpa got sick and almost died (he is not infected COVID-19). I thought I would lose him. Fortunately, he recovered and be in good health now. At that time, I decided I would quit my job. I made that decision because I wanted to spend more time with my grandpa as well as my family. I also wanted to focus on executing my ideas and creating projects.

Before I sent the resignation letter, I was afraid that I couldn't afford the life. I still clicked the send button because if I continued thinking about it, I couldn't do anything I want in my life.

It has been exactly 2 month since I left my company, I am learning new things not only programming knowledge but also other skills like video editing, content creation. I create a CSS library called [VN.css](https://vncss.vercel.app/). I create programming tutorials and share them on my [Youtube channel](https://www.youtube.com/channel/UCXykqt3V2-9bYXKWZRcH0rA). I also write [blog posts](https://phongduong.dev/blog) to share my stories. I enjoy doing these things and write down every thought in my mind and share them.

COVID-19 pandemic may be the bad thing to people but it is the greatest thing happened to me in 2020. It is a reminder that I don't have time to waste and procrastinate doing what I want. Now I value every second. 

Thank you for reading this post. I wish you and your family stay safe.
The server-side web app
Tags: discuss, development, watercooler
Published: 2020-09-14 14:42:25

Back when I started developing the internet was so small and most of my coding was simply done to remove glitches or get past a boss on my Amiga 1200. I remember the day I got my 256kbs AOL line and how I suddenly had this wealth of information at my fingertips. I started my journey with HTML, CSS, and Javascript, slowly moving into PHP to help serve some data to my websites. It worked! It flowed and it worked. 

SEO was never a problem, responsive frameworks were not needed, this was pre-2008 and pre Steve Jobs with his iPhone. This was CRT screens and making websites and sometimes using GIFS to animate. The biggest thing doing interactive sites was Adobe Flash, I could never get into that myself but some friends loved it.  But again Steve Jobs and his iPhone changed that game and flash is no more.

But we still built great content and readable great code. The sites were stable, we used four languages, sometimes a little JQuery was thrown in the mix but it worked and delivered good content. The other fact was developers knew what developers had to do, there was no divide, no my framework is better than yours, we all had a job and we got it done.

This isn't a rant about modern web tactics or me walking down memory lane, it's me asking does the server-side four language site still have a home. Is there a need for it, or will be forever poly filling the latest framework to do what we did 20 years ago.

What are your thoughts?