teleren/devto huggingface dataset:
Why I Default to The Old Ways
Tags: habits, regex, backwardscompatibility
Published: 2019-07-19 23:00:00

---
title: Why I Default to The Old Ways
published: true
tags: habits,regex,backwards compatibility
canonical_url: https://thjones2.blogspot.com/2019/07/why-i-default-to-old-ways.html
---

I work with a growing team of automation engineers. Most are purely dev types. Those that have lived in the Operations world, at all, skew heavily towards Windows or only had to very lightly deal with UNIX or Linux.  
  
I, on the other hand, have been using UNIX flavors since 1989. My first Linux system was the result of downloading a distribution from the MIT mirrors in 1992. Result, I have a lot of _old_ habits (seriously: some of my habits are older than some of my teammates). And, because I've had to get deep into the weeds with all of those operating systems many, many, _many_ times, over the years, those habits are pretty entrenched ("learned with blood" and all that rot).  
  
A year or so ago, I'd submitted a PR that included some regex-heavy shell scripts. The person that reviewed the PR had asked "why are you using `[<SPACE><TAB>]*` in your regexes rather than just `\s`?". At the time, I think my response was a semi-glib, "A) old habits die hard; and, B) I know that the former method always works".  
  
That said, I _am_ a lazy-typist. Typing "`\s`" is a lot fewer keystrokes than is "`[<SPACE><TAB>]*`". Similarly, "`\s`" takes up a lot less in the way of column-width than does "`[<SPACE><TAB>]*`" (and I/we generally like to code to fairly standard page-widths). So, for both laziness reasons and column-conservation reasons, I started to move more towards using "`\s`" and away from using "`[<SPACE><TAB>]*`".  I think in the last 12 months, I've moved almost exclusively to  "`\s`".  
  
Today, that move bit me in the ass. Well, yesterday, actually, because that's when I started receiving reports that the tool I'd authored on EL7 wasn't working when installed/used on EL6. Ultimately, I traced the problem to an `awk` invocation. Specifically, I had a chunk of code (filtering DNS output) that looked like:

```
awk '/\sIN SRV\s/{ printf("%s;%s\n",$7,$8)}'
```

  
Which worked a treat on EL7 but on EL6, "not so much." When I altered it to the older-style invocation:  
  

```
awk '/[]\*IN[]\*SRV[]\*/{ printf("%s;%s\n",$7,$8)}'
```

  
It worked fine on both EL7 _and_ EL6. Turns out the ancient version of `awk` (3.1.7) on EL6 didn't know how to properly interpret the "`\s`" token. Oddly (my recollection from writing other tooling) is that EL6's version of `grep` understands the "`\s`" token just fine.  
  
When I Slacked the person I'd had the original conversation with a link to the PR with a "see: _this_ is why" note, he replied, "oh: I never really used <tt>awk</tt>, so never ran into it".
Api security 
Tags: discuss
Published: 2019-07-19 21:25:40

Hi, I built a product that offer a public api endpoint to collect data from my users' applications, each of those needs to provide their specific API key.

Sometimes I receive a lot of fake http calls (3/4.000 requests per minute) that tend to fill my server's resources. They are fakr, just to keep my server busy. 

Actually my solution is identify these anomalies because my server slow down and add a "deny [fake-ip]" entry in my .htaccess file.

Instantly the server come to breathe. 

Can I adopt a more scalable strategy to recognize and filter out bad traffic?
What's the deal with RSS feeds?
Tags: discuss, rss, webdev
Published: 2019-07-19 21:22:58

---
title: What's the deal with RSS feeds?
published: true
description: What is the deal with rss feeds. Are they still used?
tags: discuss,rss,webdev
---

My blog generates an RSS feed but I haven't really done anything with it and was wondering if I am missing out on opportunities to help promote my blog?  

The only time I have used it is to connect it to dev.to to automatically add articles. 

RSS feeds seems to have been around for a long time, but do people still use them and what benefits have you found from them?
React Hooks - useContext with multiple context
Tags: react
Published: 2019-07-19 20:59:40

Here is my question/confusion. 

I am following some code examples to create GlobalState and then use the react Hooks useContext to access the state. 

here is the example code
https://github.com/academind/react-redux-vs-context/blob/context-hooks/src/context/GlobalState.js

and Example video
https://www.youtube.com/watch?v=R_7XRX7nLsw


My question is, if I have multiple components, each trying to access the global state, do I create a global context or do I create multiple context. And then how do I use the provider and consumer if I have multiple context.
Materialize Modal closing instantly when attempting to load data from a URL
Tags: webdev, help, javascript, html
Published: 2019-07-19 20:48:06

This is my first time using Materialize... Always used bootstrap. Anyways, I am attempting to load data dynamically into a Materialize Modal.

My issue is that it only appears for about a second then closes. Any help would be appreciated. Not sure if this is something I'm doing wrong, and if a better way exists to do this.

Javascript:
```javascript
    $(document).ready(function () {
    	$('.modal').modal();
    	$('.openEditor').on('click',function(){
    		var dataURL = $(this).attr('data-href');
    		$('#editorModal').load(dataURL);
    		$('#editorModal').modal('open');
    	});
    });
```
.. I have also tried the following ..
```javascript
    $('.openEditor').on('click',function(){
        var dataURL = $(this).attr('data-href');
        $('#editorModal').load(dataURL,function(){
            $('#editorModal').modal('open'); 
        });
    });
```
both with the same result, the modal almost instantly closing.

Initialize Button (HTML)
```html
    <a href='javascript:void(0);' data-target='editorModal' data-href='/ajax/editorModal.php' class='btn btn-small waves-effect waves-light orange modal-trigger openEditor'>Edit</a>
```
and the actual Modal
```
    <div id="editorModal" class="modal"></div>
```
editorModal.php
```php
    <!DOCTYPE html>
    <html lang="en" dir="ltr">
      <head>
        <meta charset="utf-8">
        <title></title>
      </head>
      <body>
        Body...
      </body>
    </html>
```
Do you A/B test improvements?
Tags: discuss, webdev, ux
Published: 2019-07-19 20:23:01

---
title: Do you A/B test improvements?
published: true
description: A discussion about A/B testing and what developers do to ensure improvements are good for UX.
tags: discuss, webdev, ux
cover_image: https://thepracticaldev.s3.amazonaws.com/i/iirmpsjujz3geldzqba4.jpg
---

I'd love to hear from the community what you all do to ensure that changes you make will actually improve the user experience.

I'm especially curious about:

- if you don't do A/B testing, why not?
- is your development a data-driven process?
- do you use a server or client-side A/B testing tool?
- what are the metrics you look at to decide whether the experiment was a success?
- how does A/B testing help you understand the cause and effect of changes to your website?

I plan to write another post about web performance and how A/B testing helps tie improvements to the UX metrics back to specific optimizations. Your responses would be helpful context for me!
I published App I been working on and this happened...
Tags: productivity, angular, electron
Published: 2019-07-19 20:11:57

---
title: I published App I been working on and this happened...
published: true
description: Yesterday I published cross-platform App and I got unexpected results.
tags: productivity, angular, electron
cover_image: https://thepracticaldev.s3.amazonaws.com/i/7kigwjy2we4ac6fa4y2c.png
---


First of all, I wanna thank @danielw and @darksmile92 for helpful feedback on my website. I will apply it to my next website update.


#### Yesterday, I finally completed and published the app on [Product Hunt] & [Website]. Now, I wanna share results with you.


I expected less than 10 upvotes on [Product Hunt] and less than 5 registered users. My biggest fear was that no one will even visit a website and that I will have zero registered people.

But somehow I got a small response and I was so happy about it. More than 20 registered accounts, and almost 60 Upvotes (58 while I'm writing this) on Product Hunt.


Oh yeah, of course, I unexpected bug occurred :O "Quota has been exceeded for this project..." and visitors couldn’t download installation files. I was so lucky that T.E. was kind enough to point that out and I did quick transition to AWS where I already had uploaded files for download. 

> I'm still counting every registered user, and I plan to send each of them an email. 


This is the app for personal projects, and customizable so it can be more personal itself. The whole point is to have something personal, and I want to get know with each person who uses the app.



Thanks for the support and feedback. Read [post] if you wanna know more, or check [Product Hunt] and/or [Website].


![The Track - Time Tracking App for Personal projects](https://thepracticaldev.s3.amazonaws.com/i/95zlo27lr6r66pnrhl9y.gif)
Video Created by [Remote Tools]



[Product Hunt]:https://www.producthunt.com/posts/the-track
[Website]:https://thetrack.app/
[post]:https://dev.to/jovansavic/i-designed-and-coded-a-cross-platform-app-by-myself-1m35
[Remote Tools]:https://www.remote.tools/
Running tor using docker
Tags: devops, docker, tor, privacy
Published: 2019-07-19 19:58:21

---
title: Running tor using docker
published: true
description: Quick tip to run tor in docker
tags: devops, docker, tor, privacy
---
If you want to connect to [tor](https://www.torproject.org/) network without using tor browser, docker is the solution!

Just copy this code into a Dockerfile:
```
FROM alpine:edge

RUN apk update
RUN apk add tor

RUN echo "Log notice stdout" >> /etc/torrc
RUN echo "SocksPort 0.0.0.0:9150" >> /etc/torrc

EXPOSE 9150

CMD tor -f /etc/torrc
```

Build it with `docker build -t tor -f Dockerfile .` and run it with:

```
docker run -d --rm --name tor -p 9150:9150 tor
```

But, if you don't want to do the build just run:

```
docker run -d --rm --name tor -p 9150:9150 boris/tor:alpine
```

After that, you'll have a tor proxy running in your `127.0.0.1:9150` so go ahead and configure your browser of choice to use a SOCKS proxy on `127.0.0.1:9150` and you'll go from this:


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

To this:

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

Enjoy your privacy :)

PS: Code for my Dockerfile is [here](https://github.com/boris/docker/blob/master/tor/Dockerfile-alpine) and the image in Docker hub is [here](https://hub.docker.com/r/boris/tor)
Heads down, Spirits up
Tags: devlog, interactivefiction, gamedev
Published: 2019-07-19 23:15:54

---
title: Heads down, Spirits up
published: true
tags: devlog , interactivefiction, gamedev
canonical_url: https://triptych.writeas.com/heads-down-spirits-up?pk_campaign=rss-feed
---

I'm working steadily on [STIM](https://repl.it/@triptych/Super-Tiny-IF-Maker-STIM) and having a great time coding it up. It's been a long time since I've had “fun” building something on the web. And it's been because I have stopped feeling guilty about knowing some framework or doing it the “best way”. I'm using a collection of open source projects to build it and not reinvent the wheel.

Other than that, I'm looking forward to playing a game called [Dragon Quest Builders 2](https://www.nintendo.com/games/detail/dragon-quest-builders-2-switch/) which is this really fun RPG/sandbox game.

The theme for the rest of this year is “output” and I aim to follow that.

Look for more posts soon on my progress on STIM
Rule on insert
Tags: help, postgres
Published: 2019-07-19 19:36:38

Hello!

There is a bug in one of the database modules I use and sometimes it inserts 'undefined' into the database. I want to create a rule that will replace one of the values in the row with another. I've tried this:

```sql
CREATE RULE replace_undefined AS ON INSERT TO telegraf_session
    WHERE NEW.session = 'undefined'
    DO INSTEAD INSERT INTO telegraf_session VALUES(NEW.id, REPLACE(NEW.session, 'undefined', '{}');
```

But on inserting with this rule I get `ERROR: infinite recursion detected in rules for relation "telegraf_session"`

What am I doing wrong? I thing the condition isn't respected, but I'm not sure why.

Thanks!
Fediverse || Mastodon instances ??
Tags: explainlikeimfive
Published: 2019-07-19 19:19:06

---
title: Fediverse || Mastodon instances ??
published: true
description: Explainers please ??
tags: explainlikeimfive
---

I've spent the last I don't know how long trying to understand what exactly is a fediverse and what are mastodon instances but I still have no idea... Anyone out there who can help ??
Book Review: Refactoring UI (2018)
Tags: bookreview, design, ux, ui
Published: 2019-07-19 19:18:31

I love this book, because it doesn't mess around: there's a title page, the table of contents, and then you're immediately presented with some great design advice:

> _"Start with a feature, not a layout"_

That's the title of the first section of the first chapter of this book. The authors explain that _design_ is different from _aesthetics_. When you're developing a product like an app or a website, the most important thing is that it's _functional_. Decide what UI elements you need to satisfy that functionality first, then build your product around it. Google's home page contains little more than a single search box, but it's one of the most popular websites on the Internet.

I feel like I can't accurately summarise this book in a review because every sentence is brimming with great design tips. The book is only about 200 pages long and -- because there are a lot of graphics -- you can easily read it in a few hours in a single afternoon. It feels like sitting down for a chat with an experienced web developer and listening to them explain every bit of design advice they've accrued over their career.

This book has helped me put into words what I think is the most important piece of design advice anyone could give, and that is: "be consistent". Not "consistent" in the sense that everything has to always be the same, but in the sense that you should pick a few different fonts, a few different colours, and so on, and use them the same way in the same contexts.

The authors call this a "visual hierarchy" and recommend that you develop it ahead of time so you you're not constantly fretting over minute design details as you develop your website or app. Pick 2-3 shades of a colour for emphasised, normal, and de-emphasised text. Use a heavier font weight to emphasise important information. Pick a colour scheme and stick with it. Use whitespace judiciously. Steer clear of relative sizing.

In my humble opinion, the two biggest "tells" of someone who's not design-minded are:

1. inconsistent or inappropriate spacing
2. inconsistent layout

I can't tell you how important it is for your company logo to be in the same place on every page of your website, or every slide of your Powerpoint presentation (excepting maybe the home page / title slide). It looks unprofessional (dare I say "sloppy"?). This book emphasises these points and more.

As I said, it's difficult to summarise this book in a few sentences. If you're interested in visual design, especially web design, I promise that you will not be able to put this book down. I would recommend it to anyone working in UI/UX, frontend development, or web or mobile design. Actually, I would recommend it to anyone who has ever had to lay out a report, make a slide deck, or design a brochure. There are certain rules of design that transcend media and this book provides a great foundation for designing professional-looking products. 100% Recommended.
Follow Friday!
Tags: showdev, discuss, career
Published: 2019-07-19 19:01:13

Happy Friday everyone! Post your social media links, blog links, etc so people can follow you!

Mine are below:

Twitter: [@iam_timsmith](https://www.twitter.com/iam_timsmith)
Github: https://www.github.com/iamtimsmith
LinkedIn: https://www.linkedin.com/in/tim-smith-1a651aa0/
False positives and ML
Tags: python, machinelearning
Published: 2019-07-19 18:56:31

---
title: False positives and ML
published: true
description: python
tags: python, machine learning
---
Computers sometimes come to the wrong conclusions. That's because of different reasons. The model (<a href="https://pythonprogramminglanguage.com/python-machine-learning/">Machine Learning</a> algorithm) may be incorrect, it may be not enough data and so on.

Lets take the simple flower data set and find the number of false positives. The Python program below calculates:

    #!/usr/bin/python3
    from sklearn import datasets
    from sklearn.naive_bayes import GaussianNB

    iris = datasets.load_iris()
    gnb = GaussianNB()
    y_pred = gnb.fit(iris.data, iris.target).predict(iris.data)
    print("Number of false positives out of a total %d points : %d"  % (iris.data.shape[0],(iris.target != y_pred).sum()))

That's 6 errors out of 150. You could say it's not much, but it depends on what kind of data you are dealing with and what kind of fault tolerance is allowed.

<img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Ftse1.mm.bing.net%2Fth%3Fid%3DOIP.-dkSwZaXTpgcsAf93d0ZHgHaEB%26pid%3DApi&f=1">

Predictive algorithms sometimes come to the wrong conclusion. There are 4 possible outcomes:

<img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fi.stack.imgur.com%2F65Rsd.jpg&f=1">

In an ideal situation, it would score 100% and there would be only true positives and true negatives. In practice algorithms often are less accurate.

For a toy program that's not such a big of a deal, but what if the algorithm is driving your car or flying the plane you sit in?

Indeed, an error in your self driving airplane could be a disaster:

<img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FArYyMzY10qNnq%2Fgiphy.gif&f=1">

You want to optimize your algorithm as much as possible, with lots of training and test data. 

Related links:
* <a href="https://scikit-learn.org/stable/index.html">The sklearn module</a>
* <a href="https://gumroad.com/l/MnRYU">Machine Learning course and examples</a>
* <a href="https://pythonprogramminglanguage.com/python-machine-learning/">Machine Learning blog</a>
* <a href="https://pythonbasics.org/why-python-for-machine-learning/">Why Python for Machine Learning</a>
Filtering Many Options on the Frontend
Tags: javascript, frontend, filtering, designpatterns
Published: 2019-07-19 18:21:04

---
title: Filtering Many Options on the Frontend
published: true
description: A friend of mine asked about filtering a large list of items on the frontend. I recorded a simple solution and offered it here for those who might be interested
tags: javascript, frontend, filtering, design patterns
cover_image: https://thepracticaldev.s3.amazonaws.com/i/cq9c5nkam9x020w8twy0.png
---

A friend of mine recently emailed me asking how he might filter a large list of items in Javascript. He started out with just a couple filters, but as more got added, it became increasingly complex to filter out matches.

I ran across a similar problem recently when building a new [filtering feature for CFP Land](https://www.cfpland.com/conferences/). I wanted users to be able to limit conferences with open CFPs to those that matched their criteria, and since the list isn't that big (usually fewer than 100), I decided to implement it on the frontend.

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

While this solution isn't optimized, it does limit the complexity of any one filter. In cases where performance differences are negligible it's better to favor solutions that make code more readable to those that are optimal.

First, I created a master filter function:

```
function filter(allResults, options) {
	return allResults.filter(result => passesFilter(result, options))
}
```

Where `allResults` is the array of all items in the list (conferences in my case).

Next, I created a `passesFilter` function that will ultimately return a boolean (`true` or `false`) depending on whether an individual item passes all the filter options given:

```
function passesFilter(result, options) {
	const results = [];

	if (option.firstOption) {
		results.push(resultPassesFirstOption(result, options.firstOption));
	}

	// TODO: Repeat for as many options as you want.
	// You'll end up with an array of true/false statements

	return results.every(result => result);
}
```

The last line uses `every` to return `true` if all elements in the `results` array are `true`.

Finally, I implemented my `resultPassesFirstOption` function where the real business logic lies:

```
function resultPassesFirstOption(result, option) {
	// TODO: Return true or false depending on the result and option
}
```

Now, you just need to create functions and `if` statements to process each option that you want to support.

What do you think? Do you know a more efficient way to filter items using complex options in Javascript? Let me hear your solutions to the problem in the comments 👇.
How to implement Auth using Laravel & Nuxt.js (framework for Vue.js)
Tags: help, vue, nuxt
Published: 2019-07-19 18:04:28

I am trying to implement Authentication for a Nuxtjs + Laravel app. 
I would like my app to allow register + login with email and social (google, facebook, linkedin and twitter).

What is the best way to approach this? Should the auth happen in the back-end (Laravel) via Nuxt making API calls to the back-end? Are there other approaches? Pros and cons? Pointers to github repos are appreciated! I love to copy-and-paste :D

PS. Also I've heard about JWT but don't understand how it's any better than regular auth.
Using Video Games to Improve Machine Learning (2023)
Tags: ai, machinelearning, games
Published: 2019-07-19 17:49:09

---
title: Using Video Games to Improve Machine Learning (2023)
published: true
description: How video games can be used to simulate real-world situations to improve general-purpose AI.
tags: AI, ml, games
cover_image: https://thepracticaldev.s3.amazonaws.com/i/cxbjuh3l8igy305jdqca.png
---

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

One application for machine learning that I've been excited about is in gaming. Not only useful for game developers, but also many other applications as well! One area of interest to me is the possibility to use video games to simulate real-world challenges and create solutions that can then be implemented outside of the video game. Here I will walk you through how I built a custom object detection model trained for Fortnite.

## What are we building a model for?
In machine learning its best to start with deciding on what question you want to answer. In my case, I decided to build a model that could track the unique vehicle in Fornite called The Baller. The goal will be to identify and track when a baller is in a player's field of view, including when a player is using the vehicle.

## What's the point?
The primary thesis of this exercise is to demonstrate how we can use simulated environments to solve real-world, general-purpose, AI problems. Rather than have to gather real-world data, we can capture video game data as a testbed to build, test, and refine AI systems. In the case of Fortnite, and specifically, the model demonstrated here, imagine being able to create the framework for object-avoidance, decision-optimizations, or planning the best route to travel. The possibilities are endless!

Hopefully, this post spurs your imagination of what's possible using video games. In the next post, I'll share a guide on how to replicate the model above to detect and track ballers.