teleren/devto huggingface dataset:
My Favorite Ruby Gems For Development
Tags: ruby, rails
Published: 2019-01-28 10:13:40

---
title: My Favorite Ruby Gems For Development
published: true
tags: [ruby, ruby on rails]
canonical_url: https://scottw.com/my-favorite-ruby-gems-development
---

There are many Ruby Gems you can use on a project. The following are my favorites for improving the development experience, primarily on Rails apps.

[Faker](https://github.com/stympy/faker) - Generates fake data such as emails, business names, etc. It makes it easy to add some variety to your test data and gives you one less thing to think about

[rack-mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler) - Middleware profiler for rack apps. It does quite a bit, but my primary use case is to stay on top of database queries in a given request. Its hidden superpower is it is safe to also use in production if you need help tracking down a bug.

[pry](http://pryrepl.org/) and [pry-rails](https://github.com/rweng/pry-rails) - Amazing alternative to IRB. I have used it every day for years and still feel like I only 20% of its’ power. For better or worse, my best debugging is with a series of `binding.pry` statements.

[pgsync](https://github.com/ankane/pgsync) - Makes it easy to sync data between two databases. My primary use case is grabbing specific subsets (groups) of production data for easy local debugging (without the need to download the entire database).

[xray-rails](https://github.com/brentd/xray-rails) - With a keyboard short-cut (cmd+shift+x) you get a visual representation of the layout, view, and partials used on the current page. Also, you also get the controller + action. Finally, you can click on any of them and quickly jump into the code and markup. One caveat is it depends on jQuery, so I have not been able to use on some recent projects.

[RSpec](http://rspec.info/) - Every time I start a new project I tell myself I am going to stick with conventions and not use RSpec. Then 30 minutes later, I go back to it. This in no way means RSpec is better than Rails built-in testing. I am just more comfortable with RSpec, and it has a large and established community.

[factory-bot](https://github.com/thoughtbot/factory_bot) (and [factory-bot-rails](https://github.com/thoughtbot/factory_bot_rails)) - Similar to RSpec, this is not a knock against the built-in fixtures, I find the API and workflow more appealing.

[Guard](https://github.com/guard/guard) - Automates common tasks, usually related to a file change. to the spec is changed. There are 100s of plugins for various other tasks.

[Timecop](https://github.com/travisjeffery/timecop) - Makes it easy(ier?) to test dates:

> A gem providing “time travel”, “time freezing”, and “time acceleration” capabilities, making it simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call.

If I am missing others, please let me know at hi@scottw.com or [@scottw](https://twitter.com/scottw) on Twitter.
DEV-only tooling for Web Applications
Tags: help, javascript, webpack, tooling
Published: 2019-01-22 11:44:48

---
title: DEV-only tooling for Web Applications
published: true
tags: help,js,webpack,tooling
---

Hi All,

At work, I am working on a quite complex web application that presents the user with a flow with a series of pages that gather user data. If the user wants to reach a page, she has to go through all the flow to reach it. Sometimes this can mean as much as 10 pages, with 4-10 seconds of saving time with the backend between pages.

We, developers, used to have to go through the same process every time we wanted to make a change to one of these pages. So you can imagine the pain of revisiting a page on the flow multiple times.

I came up with a tool that allows you to refresh the page in place, by copying the user data in `sessionStorage` and recreating the flow up to the very step where you left it. This happens almost instantly and saves us many hours of combined time.

My problem is that the tool is hard to set up and this makes other devs reluctant to use it. I have in a separate branch, but it requires tweaking files that get constantly modified, causing merge conflicts every time we want to merge it with our actual code.

I have thought of using webpack and a variable replaced at compilation time based on environment, so we can have it available only in our locals. The problem is that the code would need to be there along with the Production code, even if deactivated.

I struggle to find a better way to make it easier to maintain and use. Does anybody have a strong argument against not merging dev-only code along with production code? What could go wrong? Are there any alternatives to the branch-based approach?

Thank you.
How to Use Async Functions
Tags: asyncawait, javascript, promises
Published: 2019-03-02 15:43:14

---
title: How to Use Async Functions
published: true
tags: asyncawait, javascript, promises 
canonical_url: https://www.kahlillechelt.com/2019/01/22/how-to-use-async-functions/
---

[This article](http://2ality.com/2016/10/async-function-tips.html) by Dr. Axel Rauschmayer was exactly what I needed to wrap my head around how to use async functions without confusion.

Because I was just using them intuitively so far and because of their synchronous style I got confused about when to `try-catch`. I also attempted to call an async function without `await` in front of it while using `await` in its body, fully expecting it will be executed synchronously.

It’s important to remember that the foundation of async functions is Promises.

The most interesting parts of Axel’s article to me, were these:

- [Async functions are started synchronously, settled asynchronously](http://2ality.com/2016/10/async-function-tips.html#async-functions-are-started-synchronously-settled-asynchronously)
- [Parallelism](http://2ality.com/2016/10/async-function-tips.html#parallelism)
- [Immediately Invoked Async Function Expressions](http://2ality.com/2016/10/async-function-tips.html#immediately-invoked-async-function-expressions)
Giving Go another chance
Tags: go, timetracking
Published: 2019-01-22 10:35:08

---
title: Giving Go another chance
published: true
description: I'm writing a simple time tracking tool and rediscovering Go at
             the same time.
tags: go, golang, time tracking
series: Making a time tracking tool in Go
---

I decided to start tracking the time I spent on tasks a bit better than with a pen and a piece of paper. After a bit of searching I came across this [list](https://www.linuxlinks.com/timetrackers/). I tried all of the tools on it and I stuck with [timetrap](https://www.linuxlinks.com/timetrap/) for a while. But some things bugged me about it.

First of all I'd like to be able to add tags without additional parsing or relying on `grep`. I also would like to be able to backup the database to something centralized or even better use a git repo as a backend. And most of all I wanted to scratch an itch and write a simple tool in a new (sort of) language.

I started to poke around Rust a little while ago and I thought it would be a great fit. But after looking for crates (libraries) that I would need, I decided to give Go another chance. I used it before at work at some point and it kinda worked and was a good fit there. I also remember to have a bitter taste in my mouth after using it back then. So I'm gonna try it again and see how it feels a few years later.

I'm gonna document my steps and track the time I spent on the tasks. Let's start!
Hot to fix Let's encrypt error Deserialization error: Status not recognized. 
Tags: letsencrypt, ssl
Published: 2019-01-22 10:34:04

---
title: Hot to fix Let's encrypt error Deserialization error: Status not recognized. 
published: true
description: 
tags: letsencrypt, ssl
---
I've got an error when testing renew certification.

```
$sudo certbot renew --dry-run

Saving debug log to /var/log/letsencrypt/letsencrypt.log
-------------------------------------------------------------------------------
Processing /etc/letsencrypt/renewal/mydomain.com.conf
-------------------------------------------------------------------------------
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator nginx, Installer nginx
Starting new HTTPS connection (1): acme-staging-v02.api.letsencrypt.org
Renewing an existing certificate
Attempting to renew cert (mydomain.com) from /etc/letsencrypt/renewal/mydomain.com.conf produced an unexpected error: Deserialization error: Could not decode 'status' (u'ready'): Deserialization error: Status not recognized. Skipping.
All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/mydomain.com/fullchain.pem (failure)
-------------------------------------------------------------------------------
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates below have not been saved.)
All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/mydomain.com/fullchain.pem (failure)
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates above have not been saved.)
-------------------------------------------------------------------------------
```
At the first time, renew command finished successfully, but return errors at the second time.
This error seems to occur on certbot which version is lower than 0.25.
To fix this error update certbot package.
```
sudo yum update certbot -y
```
How to improve my programing logic?
Tags: discuss, javascript, programing, logic
Published: 2019-01-22 10:01:46

---
title: How to improve my programing logic?
published: true
description: Discussion about how I can improve my logic in programing.
tags: discuss, javascript, programing,logic
---

Hello DEV community 💖💖

I always wonder how I can improve my thinking and logic in programing? When I face a new challange I always freeze for a long time before I came up with the solution and start to code. I'm not thinking, I'm FREEZING. How to think and plan for my code?
How do I define a method with input parameters in an interface?
Tags: android, oop, beginners, help
Published: 2019-01-22 10:01:02

---
title: How do I define a method with input parameters in an interface?
published: true
description: 
tags: #android #oop #beginners #help
---

I was following a tutorial at this link: <https://info448.github.io/fragment-viewpager.html> that covers making an app that allows the user to slide across fragments.

I managed to complete the app but only with partial understanding. I don't understand the part where the fragment communicates with the containing Activity via an interface defined in the Fragment class.

From the Fragment class:

	
~~~~
    interface OnSearchListener {
        // allow the Fragment to pass the entered search term to the Activity
        void onSearchSubmitted(String searchTerm);
    }

    OnSearchListener mListener;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View rootView = inflater.inflate(R.layout.fragment_search, container, false);

        mButton = (Button) rootView.findViewById(R.id.btn_search);
        editText = (EditText) rootView.findViewById(R.id.txt_search);

        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mListener.onSearchSubmitted(editText.getText().toString());
            }
        });

        return rootView;
    }
	
~~~~

https://thepracticaldev.s3.amazonaws.com/i/ixjgidx1jw7v4iubj0n7.png

From the Activity class:

	
~~~~
    @Override
    public void onSearchSubmitted(String searchTerm) {
        mSearchTerm = searchTerm;
        numberOfPages = 2;
        // simply creating a different Fragment will not
        // cause the Adapter to change—you need to let the
        // Adapter know that the model it is adapting into has changed!
        adapter.notifyDataSetChanged();
        viewPager.setCurrentItem(1);
    }
	
~~~~


https://thepracticaldev.s3.amazonaws.com/i/h686v5sxwgfxea0gdk76.png

How making an instance variable of the interface in the Fragment class, and then calling its method onSearchSubmitted(editText.getText().toString()) in the onClick method, allow the input parameter to be transferred to the containing Activity.

To explore this, I went to look at other @Override methods that had input parameters which seemed to have been dealt with in the origin interface such as 
onCreate(Bundle savedInstanceState). However, I could not find where in the framework savedInstanceState had already been instantiated and fed into the interface.

I also could not find YouTube tutorial or article that gave examples of implementing interface in this manner i.e having a method with input parameters that a developer is not required to change.

Please help and thank you for reading my post.
Build AWS Lambda function with typescript only use parcel-bundler
Tags: typescript, lambda, parcel
Published: 2019-01-22 09:52:37

---
title: Build AWS Lambda function with typescript only use parcel-bundler
published: true
description: 
tags: typescript, lambda, parcel
---

In general, we need like tools like serveless or apex when use typescript on AWS Lambda.
But it's so heavy for light use.

I found way to build with only parcel-bundler

First, install typescript

```
yarn add -D typescript
```

and install parcel and parcel-plugin-zip

```
yarn add -D parcel parcel-plugin-zip
```

Create `handler.ts`

```typescript
export const handler = async (): Promise<any> => {
  console.log('Hello World!');
  return {};
}
```

And we build this function for aws with below command.

```
$ yarn parcel build handler.ts --target=node --global handler -o index.js --bundle-node-modules --no-source-maps
```

Finally, setup build command to `package.json`.

```json
// package.json
"scripts": {
  "build": "yarn parcel build handler.ts --target=node --global handler -o index.js --bundle-node-modules --no-source-maps",
  "deploy:aws": "aws lambda update-function-code --function-name my-special-function --zip-file fileb://./dist.zip",
  "deploy": "yarn build; yarn deploy:aws",
}
```

We can now build and deploy lambda function with `yarn deploy` (may need setup aws credentials) !

# References

* https://scotch.io/@nwayve/how-to-build-a-lambda-function-in-typescript
* https://github.com/parcel-bundler/parcel/issues/192#issuecomment-366032738
What Is The Worst Comment In Your Code?
Tags: discuss
Published: 2019-01-22 09:47:27

---
title: What Is The Worst Comment In Your Code?
published: true
description: We all have skeletons in our closets.
tags: discuss
---

Inspired by the thread [Software developers of Reddit, what is the most shameful "fuck it, it works" piece of code you've ever written?](https://www.reddit.com/r/AskReddit/comments/ai9eql/software_developers_of_reddit_what_is_the_most/), I wanted to ask what horrible/funny comments you have in your code.

In my main code base, 1000 lines in to a 2.5k line file, sits this beauty:

```
//================YOU ARE ENTERING HELL ON EARTH=======================
//======================THE PAIN STARTS HERE===========================
```
I tried to refactor it once or twice, but I think I just got myself more jumbled as a result.

What signposts lie in the dark tunnels of your code to guide any unfortunate souls who had to venture that deep?
Smart Commit
Tags: git, smart, commit, gitcommit
Published: 2019-01-22 08:33:25

---
title: Smart Commit
published: true
description: Create commit with current branch name.
tags: git, smart, commit, git-commit
---
To those who works with Jira, we have a convention to prefix commit name with ticket number. This repo solves that tedious task.

Story: I searched for command that could print the current branch(our branch name = Jira ticket number) and decided to concat it with hyphens, colons and user’s input message.  

Have a look.
 ![Tutorial smart commit](https://thepracticaldev.s3.amazonaws.com/i/lq5hoe75ktbu4liet5ak.jpg)

[Smart commit github link](https://github.com/sbimochan/smart-commit)
Back to 980px GitHub dashboard
Tags: discuss, github
Published: 2019-01-22 08:22:52

---
title: Back to 980px GitHub dashboard
published: true
description: Make GitHub Dashboard Great Again
tags: discuss, github
---

![](https://thepracticaldev.s3.amazonaws.com/i/j8gm1nn9s5eddwtr8qy9.gif)

If you do not like the new GitHub dashboard (like me), maybe this is what you need.

A small extension for Chrome.

Make GitHub Dashboard Great Again :)

https://github.com/antonreshetov/980-github-dashboard
Awesome Java Security 🕶☕🔐
Tags: showdev, java, security, githunt
Published: 2019-01-22 05:23:37

---
title: Awesome Java Security 🕶☕🔐
published: true
description: An awesome list of security-related resources for Java
tags: #showdev, #java, #security, #githunt
cover_image: https://thepracticaldev.s3.amazonaws.com/i/2puzngve9gzs90qp5n96.jpg
---

The first version of Java was released on January 23, 1996. Since then Java is said to run on over 3 billion devices. Many of these devices are web servers.

Java is one of the top 5 most popular technologies, according to the [2018 StackOverflow](https://insights.stackoverflow.com/survey/2018/#most-popular-technologies) survey.

For this reason, I've compiled a curated list of **awesome-java-security** resources to help devs code securely with Java.

{% github https://github.com/guardrailsio/awesome-java-security %}

Did I miss anything? Let me know in the comments.

And, please leave a like (or ⭐ the repo) if you find it useful.
Hastatic: A tiny static content web server for Docker
Tags: showdev, opensource, haskell
Published: 2019-01-22 05:23:18

I wrote this teeny-tiny static content web server for Docker. Just use it as the base image to add your website content and you get a Docker image of your website with a server baked in! And it's choked full of features too.

Check it out:

{% github https://github.com/abhin4v/hastatic/ %}
Design Reviews for Existing Features
Tags: discuss, design, legacycode
Published: 2019-01-22 04:58:16

---
title: Design Reviews for Existing Features
published: true
description: How can we best understand what we already have?
tags: discuss, design, legacycode
---

Recently I've taken on the project of helping organize my team's design review process. Part of what we want to do is have "design reviews" for our existing features, the outcome of which would be a desgin review meeting about that feature as well as new documentation about that feature.

Currently we're asking folks writing design reviews for exisiting features to answer the following questions:

* What is this feature?
    * What was it initially designed to do?
    * What do customers expect it to do?


* How does it work?
    * What are the components of this feature?
    * What technologies do they use?
    * How do they work together to create the feature?

How does your team maintain knowledge about your existing features? How do you go about figuring them out in the absence of updated (or any) documentation? Are there any other questions you would ask in a design review for an existing features?
Any contribution to Open Source is valuable
Tags: opensource, gatsby
Published: 2019-01-22 04:02:06

---
title: Any contribution to Open Source is valuable
published: true
tags: opensource, gatsby
cover_image: https://thepracticaldev.s3.amazonaws.com/i/2h3puantbcb0a0sfusny.jpg
canonical_url: https://www.iamdeveloper.com/posts/any-contribution-to-open-source-is-valuable-57d3/
---

We hear people say it all the time, but I would like to reiterate it. Any contribution you make to open source is a valuable contribution. Sure we all like adding features or fixing bugs in a project, but updating documentation is still worthwhile. I was reminded of this on the weekend.

My site, [iamdeveloper.com](https://www.iamdeveloper.com), is currently using [Gatsby](https://gatsbyjs.org), an awesome React based static site generator on steroids.

{%twitter 1042796116255879168 %}

For tweets on my blog posts, I had installed the [gatsby-plugin-twitter](https://www.gatsbyjs.org/packages/gatsby-plugin-twitter/) about a year ago. It was working well for me, but then I came across this tweet.

{%twitter 1086362206005006336 %}

I checked out the npm package, [@raae/gatsby-remark-oembed](https://www.npmjs.com/package/@raae/gatsby-remark-oembed) and then followed the links to the repository and demo. It looked pretty awesome and fast and it supported much more than Twitter. I installed the package, copied the code snippet to add to my gatsby-config.js and was all good to go.

I fired up my development environment and I was getting errors about the plugin not being found.

```bash
Error: Unable to find plugin "gatsby-remark-oembed". Perhaps you need to install its package?
```

I was a little perplexed, read over things several times in the documentation and then came to the realization, that since the author published the package, the name of the npm package was not the same name, it was a [scoped package](https://docs.npmjs.com/misc/scope), i.e. `@raee/gatsby-remark-oembed` instead of `gatsby-remark-oembed` (like in the code snippet in the documentation). I was glad I figured out what was up. I got the plugin running locally and then I published my site and was good to go. I was also happy to have migrated it to TypeScript, but we'll save that for another post.

{% twitter 1087096096176959488 %}

At this point, I was like, well if I spent 15-20 minutes trying to figure out what was up, I'm sure others would appreciate what I had discovered, so I put up a PR to update the documentation. It got merged and I felt just as good about adding these 6 characters, `@raae/` to the code snippet in the documentation as I do when I fix a bug or add new functionality to a project.

**Every contribution to open source is valuable.**

{%twitter 1087419926204305408 %}


Thanks for the thanks @raae!

Photo by [Slava Bowman](https://unsplash.com/photos/pkKeuRiDa2Q?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/search/photos/community?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)