teleren/devto huggingface dataset:
fish shell configuration
Tags: fish, shell, terminal, configuration
Published: 2019-06-27 01:23:42

---
title: fish shell configuration
published: true
description: fish shell provides execellent web-based UI in order to configure color theme, prompt style and so on. It is called fish_config. Just type "fish_config". Then the gate will be opened quickly :)
tags: fish, shell, terminal, configuration
---

I was in search of how to hide username in console for the sake of getting more beautiful screenshots.
I found [`fish_config`](https://fishshell.com/docs/current/commands.html#fish_config) that [`fish` shell](https://fishshell.com) officially provides.
It has execellent web-based UI for us to configure color theme, prompt style and so on.

Just type in the terminal:

```console
$ fish_config
```

Then your web browser will run and show the useful menus :)
With options, select one and click "Set \*\*\*", and it'll be done.

Besides, my current `fish` version is 3.0.2.

---

### fish_config Web UI

##### colors

![colors](https://thepracticaldev.s3.amazonaws.com/i/mtyuu9dauk4xfb0lc1h6.png)

##### prompt

![prompt](https://thepracticaldev.s3.amazonaws.com/i/q8nwdlsbcnnpcn37msbn.png)

##### functions

![functions](https://thepracticaldev.s3.amazonaws.com/i/0emoxe0yhrjg4ljfytfa.png)

##### variables

![variables](https://thepracticaldev.s3.amazonaws.com/i/s8siq5xa43od6qnfrp8t.png)

##### history

![history](https://thepracticaldev.s3.amazonaws.com/i/arr3vtphdio14x6nh0py.png)

##### bindings

![bindings](https://thepracticaldev.s3.amazonaws.com/i/1oalcktlkveaj0pdzmxc.png)

##### abbreviations

![abbreviations](https://thepracticaldev.s3.amazonaws.com/i/lm3suxily2pe99j9lyme.png)

---

After changing "prompt", great, my console shows just "$" at the top of prompt lines:

![result](https://thepracticaldev.s3.amazonaws.com/i/8vam7vysu060vxkffduv.png)

Happy coding.
I do this all the time to reduce bugs in my javascript code #1
Tags: javascript
Published: 2019-06-27 16:50:14

---
title: I do this all the time to reduce bugs in my javascript code #1
published: true
description: Tips on writing Javascript code with less errors #1
tags: javascript
cover_image: https://res.cloudinary.com/bahdcoder/image/upload/v1561653838/I_do_this_all_the_time_to_reduce_bugs_in_my_javascript_code_1_llc7hi.png
canonical_url: https://katifrantz.com/articles/i-do-this-all-the-time-to-reduce-bugs-in-my-javascript-code-1
---

Have a look at the following code sample:
```js
data.course.enrolments.forEach(enrolment => enrolment.confirm())
```

Sometimes the data we work with is not predictable, so to avoid errors or crashes we always have to take care of edge cases. The above code makes a lot of assumptions. It assumes that `data.course` exists, `data.course.enrolments` exists and is an array of objects with a `confirm` property which is a valid `Function`.

If the `data.course` or `data.course.enrolments` property is `undefined` we get the following `TypeError` error:

```js
Uncaught TypeError: Cannot read property enrolments of undefined
Uncaught TypeError: Cannot read property forEach of undefined
```

If the `confirm` property in each `enrolment` object in the `data.course.enrolments` array is not a valid `Function`, we get the following error:

```js
Uncaught TypeError: enrolment.confirm is not a function
```

Now have a look at this one:

```js
((data.course || {}).enrolments || [])
    .forEach(enrolment => enrolment.confirm && enrolment.confirm())

```

I'll explain how the above snippet works.

#### `data.course || {}`

This expression resolves to `data.course` if the `course` property exists on the `data` object, and resolved to an `{}` if it doesn't. The reason it resolves to `{}` is because of the `||` operator which checks if the left-hand side of the expression (`data.course`) is `falsy`, and if it is, resolves the expression to the right-hand side (`{}`). If it's not `falsy` then it resolved the expression to the  left-hand side. 

#### `(data.course || {}).enrolments || [])`

As explained above, the left-hand side will either be `data.course` or `{}`. Next, we try to access the `enrolments` property on the object resolved from the first expression.

#### `enrolment.confirm && enrolment.confirm()`

Unlike the `||` operator, the `&&` checks if the left-hand side of the expression (`enrolment.confirm`) is `truthy`, and if it is, resolves the expression to be the right-hand side (`enrolment.confirm()`). This means the function `enrolment.confirm` will never be executed if the `confirm` property is not found on the `enrolment` object.

#### Summary

Taking care of edge cases as you write your code can save you a lot of debugging time, and also prevent unexpected application crashes.
Use Javascript Regex to Find All IDs That Contain a String and Copy the Text to the Clipboard
Tags: javascript, regex, console, clipboard
Published: 2019-06-27 16:46:21

---
title: Use Javascript Regex to Find All IDs That Contain a String and Copy the Text to the Clipboard
published: true
description: Provides and explains a simple example browser console web scraper.
tags: Javascript, Regex, Console, Clipboard
---

Web scraping is a powerful tool. I sometimes find that spinning up a full-fledged Beautiful Soup Python script for a short task is unnecessary. Today I had an issue with a web page that would not allow me to select items in a table to copy, and, even if it did, I would have had the additional, unwanted column data in my clipboard.

## Solution: Console web scraping

### Let's break this down.

First, what I wanted was a way to capture each element. The text I desired from the table was wrapped in a `<div id="edit-tid-24-view"></div>` tag. I tried targeting them first by a "begins with" filter:

```
document.querySelectorAll('[id^="edit-tid"]');
```

This got me part of the way there, but I needed to target ID attribute values that not only started with this, but ended with `-view`. In typical Regex, you might do something like `/edit-tid.*-view/`. A bit greedy, but would have done the trick in my case. However, we don't really get to use Regex in `querySelectors`. So, I combined two filters: one for the beginning portion, the other for the ending portion.
```
document.querySelectorAll('[id^="edit-tid"][id$="-view"]');
```

After that, it was quite simple. I wanted to loop through the `NodeList` object that was returned, so I had to first convert it to an `Array`. 
```
Array.from(someObject);
```

Once there, I could have mapped the `innerText` of each `Node` from the DOM to an array of the desired strings.
```
Array.from(someObject).map(function(item) { return item.text; });
```

However, I was not satisfied with that.

I wanted my list cleanly output, and piped directly to my clipboard. Javascript allows one to select and execute a copy command on the `document` object. However I was working in the console, and found something much simpler: the `copy` function works in the console.

I simply concatenated the strings together with a carriage return, and copied the result to my clipboard.

## Conclusion

Here's my Developer Tools Console web scraper in all it's glory.

```
copyText = ''; 
Array.from(
    document.querySelectorAll('[id^="edit-tid"][id$="-view"]'))
    .forEach(function (x) { 
        copyText += x.text + '\n' 
    }
); 
copy(copyText);
```
Extract code from Android APK with 3 commands
Tags: android, java, ethicalhacking
Published: 2019-06-27 16:36:26

I mean, with 3 tools

## Disclaimer
This post is for informational and educational purposes only

## Requirements
* [Unzip](http://www.info-zip.org/)
* [dex2jar](https://github.com/pxb1988/dex2jar)
* [jd-gui](https://github.com/java-decompiler/jd-gui)

## Terminal Time

```bash
# extract classes.dex
unzip -j <apkfile.apk> classes.dex
# transform dex file to jar file
d2j-dex2jar.sh classes.dex
# read the sources
jd-gui classes-dex2jar.jar
```

## Bonus
Do you use NativeScript/Ionic/Cordova/Phonegap/"insert some webview based mobile framework"?
This is how easy someone can read your javascript code
```bash
# find the bundled JS
unzip -l <apK file> | grep '.js'
# extract the bundle
unzip -j <apk file> assets/app.js
# find endpoint, or api keys
cat app.js | grep 'api*\|http*'
# DoS the endpoints
echo "just kidding"
```

## Edit
If you want to avoid commands an just use an app with UI you have 
* [jadx](https://github.com/skylot/jadx)
* [android binary analysis tool](https://github.com/google/android-classyshark)

Hope you find it useful and educational. 

Cover Image from [https://www.eff.org/issues/coders/reverse-engineering-faq](https://www.eff.org/issues/coders/reverse-engineering-faq)
HTML Encode TagHelper in ASP.NET Core
Tags: dotnet, dotnetcore, aspnet, aspnetcore
Published: 2020-04-02 14:22:59

---
title: HTML Encode TagHelper in ASP.NET Core
published: true
date: 2019-06-27 16:31:00 UTC
tags: dotnet, dotnetcore, aspnet, aspnetcore
canonical_url: https://sebnilsson.com/blog/html-encode-taghelper-in-asp-net-core/
---

For a specific scenario recently, I wanted to display the HTML-encoded output of a [TagHelper](https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/intro) in ASP.NET Core. So I wanted to use the TagHelper, but not output its actual result, but see the **raw HTML** which would have been included in my template.

 ![HTML](https://files.sebnilsson.com/web/images/html-encode-aspnet-core/html.jpg)

So I created another TagHelper, which allows me to **wrap any HTML, inline code in ASP.NET Core and other TagHelpers**, and get all the content inside the TagHelper's tag to be HTML-encoded, like this:

```
<html-encode>
    <a href="@Url.Action("Index")">Read More</a>
    @Html.TextBox("No_Longer_Recommended-TagHelpers_Preferred")
    <my-other-tag-helper />
</html-encode>
```

From this, I will get the raw HTML of the link with an UrlHelper-result, the result of the HTML-helper and the result of my other TagHelper.

The source-code for the `html-encode`-TagHelper is as follows:

```
[HtmlTargetElement("html-encode", TagStructure = TagStructure.NormalOrSelfClosing)]
public class HtmlEncodeTagHelper : TagHelper
{
    public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
    {
        var childContent = output.Content.IsModified
            ? output.Content.GetContent()
            : (await output.GetChildContentAsync()).GetContent();

        string encodedChildContent = WebUtility.HtmlEncode(childContent ?? string.Empty);

        output.TagName = null;
        output.Content.SetHtmlContent(encodedChildContent);
    }
}
```
Deploy static site via Capistrano
Tags: ruby, capistrano, react, vue
Published: 2019-06-27 01:25:37

At work, I was working on a PTE project. The frontend was in vuejs and the backend was in rails api. As usual, we deployed the backend with capistrano. 

For frontend, my boss wanted it to be deployed just like capistrano did, with a release folder, shared folder, rollbacks, etc. He also wanted only the compile folder to go in the server and not the whole repo.

I looked into a couple of tools that deployed static site but I could not wrap my head around it.

Since I knew capistrano and have been using it for all of my projects I decided to use it to deploy the frontend. I created a gem called [Static](https://github.com/Grasruts/static) which is an SCM plugin for capistrano.

# How to use it?
Create a gemfile in your project's folder.

```
# Gemfile.rb

group :development do
 gem "capistrano", "~> 3.10", require: false
 gem 'capistrano-scm-static', '~> 0.0.2', require: false
end
```
Then run `bundle exec cap install` . It will install all the necessary files and folder in your project.


```
# Capfile

require 'capistrano/scm/static'
install_plugin Capistrano::SCM::Static

# deploy.rb
set :dist, 'path to your static template compilation folder'
```

Let's say you are working with reactjs on frontend then your compilation folder will be `build`, so just set

`set :dist, 'build' # in case for reactjs`


If you are working with vuejs

`set :dist, 'dist' # in case for vuejs`

To deploy it, run `cap production deploy` or if your have set other environments, then `cap <environemnt> deploy`
My App’s No Good! Here’s Why.
Tags: softwaredevelopment, iosappdevelopment, androidappdevelopm, programming
Published: 2019-06-29 15:57:03

---
title: My App’s No Good! Here’s Why.
published: true
tags: software-development,ios-app-development,android-app-developm,programming
canonical_url: https://medium.com/@greg.perry/my-apps-no-good-here-s-why-7699347bb235
---

[![](https://cdn-images-1.medium.com/max/1080/1*gw4Muh_lhFrQ5ne7zBp9ow.png)](https://medium.com/@greg.perry/my-apps-no-good-here-s-why-7699347bb235?source=rss-64fbd8c9e171------2)

Making a Dart package suitable for public consumption.

[Continue reading on Medium »](https://medium.com/@greg.perry/my-apps-no-good-here-s-why-7699347bb235?source=rss-64fbd8c9e171------2)
Pets of DEV
Tags: discuss, pets, animals, watercooler
Published: 2019-06-27 16:24:15

---
title: Pets of DEV
published: true
description: SHOW ME YOUR PETS
tags: discuss, pets, animals, watercooler
---

You've got pets.  You've got pictures of your pets.  You love your pets.  But most importantly, *we* love to see pictures of your pets.

SHOW ME YOUR PETS.

I'll start.  Here is Momo.  (Avatar, not creepy internet thing.)

![My cat, Momo.](https://thepracticaldev.s3.amazonaws.com/i/8z4gjdcvdxqjxayhj0zp.jpg)

Here is Willy.  (That's Willy as in "Sir William T. Pupperton III."  No other meaning/connotation intended.)

![My dog, Willy.](https://thepracticaldev.s3.amazonaws.com/i/xx7pyk8ax0qbx11nkah0.jpg)

And here is a bonus glamour shot of Willy.

![My dog, Willy, but fabulous.](https://thepracticaldev.s3.amazonaws.com/i/nfxzr19vawfizdkmp0u2.jpg)

Ready, go!
Purge or Keep old, unfinished projects in GitHub?
Tags: discuss, help, beginners
Published: 2019-06-27 16:10:24

---
title: Purge or Keep old, unfinished projects in GitHub?
published: true
description: 
tags: discuss, help, beginner
---

Context: I started learning to code off and on a few years ago and only now am I really digging in and trying to make a career switch.

With that, I have GitHub repositories over a year old with unfinished projects I started when I really didn't know what I was doing.

What should I do with these repositories? Should I delete them and pretend they never existed? Should I keep them as trophies/reminders of where I came from?

If a recruiter/interviewer saw these repositories, would they give me the stink eye?


What I am thinking:
* Update the ReadMe files to explain the project (they are empty right now D:)
* Figure out if I want to finish any of them and then get them on a schedule to make sure I finish
* Any projects I plan on not finishing, make sure I explain why in the ReadMe

Or,

I just delete them and never look back.


_Disclaimer: This is my first Dev.to post. If my tags are wrong, the format is gross, I am open to any feedback/advice posting._

tyty
Use VSCode Theme Synthwave '84 in your website syntax highlighting
Tags: css, vscode
Published: 2019-06-27 16:09:44

I have a huge reason to cheer right now. **I made my very first open source contribution** 🎉🎉🎉🥳

For a couple of months now I've been using this awesome VS Code theme called [Synthwave '84](https://marketplace.visualstudio.com/items?itemName=RobbOwen.synthwave-vscode) by [Robb Owen](https://twitter.com/robb0wen).

I liked it that much that I wanted to use it as syntax highlighting theme for my blog.

I use [PrismJS](http://prismjs.com) as syntax highlighting tool, but the theme could not be found there, so I decided to give it a try and port Robb's theme to Prism.

You can check out the theme here:
https://github.com/themarcba/prism-themes/blob/master/themes/prism-synthwave84.css


In order to use it, you just need a code.language-* within a pre.language-* element and add the prism.js file. (* stands for the language you want to highlight, e.g. javascript, css)

```html
<!DOCTYPE html>
<html lang="en">
<head>
    ...
    <link rel="stylesheet" href="./prism-synthwave84.css">
</head>
    <body>
        <pre class="language-javascript">
            <code class="language-javascript">
                // Some JavaScript code here...
                const performances = ['🎺', '🎸', '🎤']
                performances.forEach(performance => {
                    let me = entertain(you, performance)();
                });
            </code>
        </pre>
        <script src="./prism.js"></script>
    </body>
</html>
```

You can download the prism.js file from [their website](https://prismjs.com/download.html).

The result will be something like this:
![Synthwave '84 in action](https://thepracticaldev.s3.amazonaws.com/i/z4g3wt00k0013sjxjyx8.png)

Or if you already use Prism, just replace the CSS file with the [Synthwave file](https://github.com/themarcba/prism-themes/blob/master/themes/prism-synthwave84.css).
I built a site for Pride month!
Tags: pride, webdev, showdev
Published: 2019-06-27 15:59:59

_Cover Photo by [Stavrialena Gontzou](https://unsplash.com/@stavrialena?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on Unsplash_

Hey lovely **DEV** community!

I'm writing this short post to show you a small website that I built using just HTML and CSS 😁 _Yay! Old times!_ 

I always wanted to work on a project for Pride month but I could never think of something in time. Until this month I started seeing a lot of pride-themed brands using "the wrong colors" *\*gasp\** 😱

So I did some research on the subject. And by "research" I mean that I read the Wikipedia article on [Rainbow Flags](https://en.wikipedia.org/wiki/Rainbow_flag) and realised it's not really that easy.

Usually people think the LGBTQ+ Pride flag needs to have 7 colors: "the colors of the rainbow", but that's not really the case. When this happens they end up using the [Cooperativism Movement](https://en.wikipedia.org/wiki/Cooperative) flag, instead of the widely accepted (but not exclusively recognised) Pride flag.

What I found is that there's no final truth about what's the correct one, but after struggling a lot with myself thinking if it made sense to make this website or not I finally decided that it's just for fun and set out for it. And, a couple of days later, it's ready.

🥁 *drumroll* 🥁

Here it is: [Pride or Coop?](https://pride-or-coop.fyi)

_I hope you like it and can use it as a reference when in doubt!_
I did an xargs!
Tags: xargs, unix, commandline
Published: 2019-06-27 15:52:45

---
title: I did an xargs!
published: true
description: xarg
tags: xargs, unix, command-line
---

A fundamental thing you must know is that there is not a canonical set of knowledge for ... most anything, really, but here, for Linux/Unix expertise. There have been studies. We all have gaps in our knowledge. I am sure there is someone with substantial knowledge of the linked-lists underlying file system representation but is unaware that `ls -lh` put file sizes in a human-readable form. (If that's you, you're welcome.)

For me, _one_ of my long-standing knowledge gaps has been `xargs`. I've seen it for decades, all `find . | xargs <something>` and I've copied and pasted those commands, but the knowledge never stayed.

## segue

For the last month and a half, an API we use has not been working, meaning we couldn't update data into it. But that bug has been fixed, and now I have _hundreds_ of updates that have been requested of me.

I have an API tool that allows me to get a whole month's worth of data _out_ of the API and into columns, and this time I remembered `awk` is the one I wanted (`sed` and `awk` being two other gaps in my Unix knowledge, but that's another column), getting me:

```text
1sf701vdlahb
3lm63b58riej
3o4rhtaxe8lx
b5hqvs6tuqnm
eoirmijclnl1
uihc1q3yzkvm
vq2uskrrlb5h
w6ulq3sdvyir
wxk3bbdpwdx3
y2npmn6yjkcx
zepz3n2e2to7
zk08o7dysokt
...
```

(And no, that's just random strings, but bear with me.)

So, I needed to run `api_tool -status done -r` for all of those, and thought through the pain of all the other options. List of IDs into a file, and then ... bash `for` loop? add `api_tool ...` to every line and `sh id_list.txt`?

And then I remembered `xargs`, and a half-dozen tabs were opened.

`xargs` has a _lot_ of flags, so there's a LOT more to it than what I'm using here, but what I used was `api_tool -q not_done -f 2019-06-01 | awk "{print $1}" | xargs -n 1 api_tool -status done -r`.

_This_ `awk` command was right the first time (yay me!) but I ran the `xargs` against echo a few times before I got it right. `-n <number>` determines the number of entries it pulls from the list of entries at once (we just want the one) and appends it to the end of the list, so `<whatever> | xargs -n 1 <command>` becomes `<command> <first entry>` and so on.

This saved me a _whole_ _lot_ of pointless typing, and I'm so glad. 

## moral

The point is that you should _recognize_ when you have gaps, _exploit_ opportunities to learn things, and _record_ these things so that you (and others) can use them later.

And, `xargs` is cool, yo.
How can a react app be rendered in different non react webpages?
Tags: react
Published: 2019-06-27 15:51:44


I have a react app that does not include redux. The react app only has a small chatbox window that opens up in a modal. I want to render this react app in a few non-react websites some of which use normal js and some use jQuery. How can it be included?

My application is using webpack and babel. I am not using redux.

I am new to React and newer to this community. Thanks for helping!
Easier database schema management with Ridgepole
Tags: ruby, rails, activerecord, ridgepole
Published: 2019-06-27 06:54:01

---
title: Easier database schema management with Ridgepole
published: true
description: 
tags: ruby, rails, active_record, ridgepole
---

# Sharing ActiveRecord's schema migrations with teams 

It is tough when multiple teams are working on the same Rails application and deploy stuff at a fast pace.
People create migrations without knowing the migrations the other teams are creating at the same time. 
You can not ignore them because you can't have multiple sets of migrations in Rails. You can only have a set of migrations.
So you have to keep track of migrations the other teams commit to the repository while you commit your migrations.
Because of that, it is not easy to share the migrations with the other teams withouts slowing them down.


# Ridgepole

https://github.com/winebarrel/ridgepole

Ridgepole is a database schema manager.
You write Ruby DSL to "Schemafile" and apply it to your database with `ridgepole --apply` on CLI.

With Ridgepole, you don't need to create migration files every time you want to add some changes to tables in your database.

Ridgepole compares tables in Schemafile and actual tables in the database.
Then it applies the difference with `ALTER TABLE` if there is any.

It also supports "dry run". Basically you can get SQL it's going to execute without actually executing it.
If you want to do a similar thing with ActiveRecord's schema migration, you need to migrate the migration and then roll it back.
(there was a PR for ActiveRecord to support dry run, but it didn't get merged. https://github.com/rails/rails/pull/31630)


# Integration with Rails
There are some gems for it.

https://github.com/space-pirates-llc/ridgepoler-rails

https://github.com/masakazutakewaka/rafter
(This is my gem. I hope you check it out😁 PRs are welcome🙏)


Thank you for reading this to the end!!


### references
- https://techlife.cookpad.com/entry/2014/08/28/194147