teleren/devto huggingface dataset:
How to use MainController in iOS
Tags: ios, swift
Published: 2019-05-12 20:58:29

---
title: How to use MainController in iOS
published: true
description: 
tags: ios, swift
---

Usually in an app, we have these flows: onboarding, login, main. And we usually set `OnboardingController`, `LoginController` and `MainController` as the root view controller respectively depending on the state.

I find it useful to have the `MainController` as the container for main flow. It can be a tab controller, swipe menu controller or contains just 1 child view controller. The screens are provided by child view controllers, but the `MainController` does the following jobs

- Status bar style

We usually need to call `preferredStatusBarStyle` on the parent controller. See https://stackoverflow.com/questions/19022210/preferredstatusbarstyle-isnt-called

- App did become active

Usually when app is brought to foreground, we need to fetch logged in user profile to see if there's changes. We do this by listening to `app did become active` in `MainController`. 

- Mock to open

This can be anti pattern. But in UI Tests, for laziness, we can just use some [launch arguments](http://nshipster.com/launch-arguments-and-environment-variables/) and check to present some specific screens to test, because `MainController` is the root for main flow.

- Logout

Because things originate from `MainController`, things can terminate in `MainController`. We can handle `logout`, clear states, and tell `MainController` to tell `AppDelegate` to switch to another root controller

Original post https://github.com/onmyway133/blog/issues/36
How to delete local and remote tags massively from a git repo in just one line
Tags: git
Published: 2019-06-25 19:38:10

---
title: How to delete local and remote tags massively from a git repo in just one line
published: true
tags: git
canonical_url: https://nahuelhds.dev/git/2019/05/12/How-to-delete-local-and-remote-tags-massively-from-a-git-repo-in-just-one-line.html
---

![Resultado de imagen para git](https://cdn-images-1.medium.com/max/800/1*4W4fdnO680ysRhFc9ppc8w.jpeg)

### TL;DR. Give me the magic 🧙‍♂️

> **WARNING!** This is a destructive command. Use at your own risk

**Use case:** you want to delete the major version 0 and its children.

First, a dry run…

```
SEMVER=0 && git tag | awk "/^$SEMVER.\*/ { print \\$1 }"
```

This way you see what you’re about to delete.

Now, if you are certain, then bring the chaos…

```
SEMVER=0 && git tag | awk "/^$SEMVER.\*/ { print \\$1 }" | xargs -I % sh -c "git push origin :%; git tag -d %;"
```

![Thanos is so proud of you](https://nahuelhds.dev/img/0__qTUgphZYwzkwxBYl.jpg)Thanos is so proud of you

#### Notes

The **SEMVER** variable is a regular expression used inside the **awk** command. So if you would like to delete only the 0.1 version and its patches (0.1.1, 0.1.2, etc.), you could use `SEMVER=0.1` in the command.

> **Windows users:** [you can still use GitBash](https://www.atlassian.com/git/tutorials/git-bash).

### I want the details 🤓

Let’s see the entire command again for deleting major version 0 and its children.

```
SEMVER=0 && git tag | awk "/^$SEMVER.\*/ { print \\$1 }" | xargs -I % sh -c "git push origin :%; git tag -d %;"
```

This one-line-command actually does the following things:

1. `SEMVER=0`  
Declaring the **SEMVER** variable and for later use inside the **awk** command.
2. `git tag`  
Showing the available local tags in our local git repo.
3. `awk “/^$SEMVER.*/ { print \$1 }”`  
Here we use **awk** for filtering all the matching versions with the regular expression defined in the **SEMVER** variable.
4. `xargs -I % sh -c "git push origin :%; git tag -d %;"`  
Then, we use **xargs** to use the input through the percentage char (%) and combine it with the **sh** command.  
We tell to **sh** to read the execution from a string thanks to the`-c` argument.  
Finally, inside the string we execute the git commands to delete the tag remotely first, and then locally as well. Notice we’re using the **xargs** ’ input through the percentage char (%) here.

Hope it helps!
mkdir not working in windows
Published: 2019-05-12 19:05:56

---
title: mkdir not working in windows
published: true
description: 
tags: 
---

I have been having a tough time with mkdir() to get it to function in windows using CakePHP. 


<b>This doesn't work properly in windows</b>
```php
mkdir($this -> webroot . "uploads/abc");
```

<b>Use this instead</b>
```php
mkdir(getCwd() . "/uploads/abc");
```

Wasted a hell of a time on this. Hope someone else doesn't.

Back to work!
Line by Line:  Node.js Server
Tags: node, javascript, beginners
Published: 2019-05-12 18:23:43

Each line of code is explained within the context that it is being used. This is to save time and decrease exhaustion caused by information overload!

![](https://thepracticaldev.s3.amazonaws.com/i/u1rt1ff25j21vslkp4rt.png)
How to access servers running on your pentestbook
Tags: pentestbook, pixelbook, forwarding, crostini
Published: 2019-05-12 17:13:42

---
title: How to access servers running on your pentestbook
published: true
description: Allow access to services running on your pixelbook
tags: pentestbook,pixelbook,forwarding,crostini
---

![Port forwarding in crostini](https://res.cloudinary.com/peerlyst/image/upload/c_limit,dpr_auto,f_auto,fl_lossy,h_640,q_auto,w_640/v1/post-attachments/forward_y7ulrt)
What does pair programming look like for your team?
Tags: discuss, collaboration, productivity
Published: 2019-05-12 16:55:21

---
title: What does pair programming look like for your team?
published: true
description: 
tags: discuss, collaboration, productivity
---

Hey All! I’m curious to know whether your team does [pair programming](https://en.m.wikipedia.org/wiki/Pair_programming) of any form (let’s not get too academic!), and if so, what exactly it looks like. For example:

1. How frequently do you do it? Daily? Weekly? Full-time?

1. How long do pairing sessions usually last? An hour? Three hours?

1. Are sessions initiated on an ad-hoc basis (e.g. you just ping someone on Slack), or do you schedule/plan them ahead of time? (e.g. you decide to pair with someone on a task as part of sprint planning) 

1. Do you only ever do two-person pairing sessions? Or do you ever have three or more people collaborating? ([Mob programming](https://en.m.wikipedia.org/wiki/Mob_programming)/[swarming](https://softwareengineering.stackexchange.com/questions/147664/what-is-swarming))

1. Do you typically pair with the same people? Are they remote or co-located with you?

1. What is the typical scope of task you pair on? A bug? A user story? Prototyping?

1. What is the typical motivation for doing pairing sessions? Knowledge transfer/shared ownership? Mentoring? Code review?

1. Does you and your pair have specific roles during the session? (e.g. driver, navigator). Or do you keep things fairly informal? 

1. Do you use any sort of time management techniques to add structure to the session (e.g. [pomodoro](https://en.m.wikipedia.org/wiki/Pomodoro_Technique))? 

That’s obviously a bunch of questions, so feel free to share as much or as little as is convenient. Additionally, if you’ve already written a blog post about your workflow, then just share a link to that. No need to repeat yourself! 🤗

As part of building out [Visual Studio Live Share](https://aka.ms/vsls-why), I’ve had the opportunity to learn from a ton of teams regarding [how they collaborate](https://aka.ms/vsls-usecases). However, I’m increasingly inspired by the broader DEV community, and so I’d love to hear what’s actually working well for folks in-the-wild 🙌
Clone cheaply Solidity smart contracts with Proxy | ERC 1167 Tutorial
Tags: ethereum, solidity, smartcontract, erc
Published: 2019-05-12 16:02:46

---
title: Clone cheaply Solidity smart contracts with Proxy | ERC 1167 Tutorial
published: true
description: 
tags: ethereum, solidity, smart contract, erc
---


In this video I am going to show you how we can use the ERC 1167 to cheaply clone a Solidity smart contract with a proxy. This is an advanced Solidity pattern and will probably a bit difficult if you are a total Solidity beginner. So make sure you have some basic knowledge about Solidity and smart contract before watching this video. 

{% youtube zUtnYtxjOrc %}
Ruby's retry method
Tags: ruby
Published: 2019-05-12 15:26:34

Salud to Dev.to community and eager Ruby lovers! It has been a busy month [@Camaloon](https://www.camaloon.com) and I will be writing several posts from challenges and solutions in the following weeks.

Today's topic would be Ruby's `retry` method which I was not familiar until now which came in handy recently.

`retry` is used when we want to re-execute a code block. This is useful especially when we are trying to send an HTTP request to third-party API and would like several retries in case there are any failures. 

As I was not aware of this feature before, when I wanted to re-execute a code block, I would've gone with loops.

Let's look at an example with loops: 

We are sending an HTTP request and would like to have 3 retries if it fails due to connection errors.


```ruby
require 'http'

def send_request(params)
  with_connection_retry { HTTP.post("http://example.com/resource", params: 
    params) }
end

def with_connection_retry
  retries = 0

  loop do
    yield
  rescue HTTP::ConnectionError => e
    retries += 1

    raise e if retries >= 3
  end
end 
```

This code looked ugly with loop. Let's have a look with retry.

```ruby
def send_request(params)
  with_connection_retry { HTTP.post("http://example.com/resource", params: 
    params) }
end

def with_connection_retry
  retries ||= 0

  begin
    yield
  rescue HTTP::ConnectionError => e
    retries += 1
    raise e if retries >= 3
    retry
  end
end
```

So, here you are, using Ruby's native API instead of relying upon loops for re-executing code blocks.
Struggling with Gatsby Images
Tags: help, webdev, gatsby, react
Published: 2019-05-12 15:21:07

---
title: Struggling with Gatsby Images 
published: true
description: Need some help! 
tags: #help, #webdev, #gatsby, #react
---

I'm really struggling to understand how Gatsby images, in particular the fluid images work. I love the fact that they hold their positions and load in with a blur effect. But, I don't get the best way to display them or even how to at times...

I use the Img component in gatsby-image. But, sometimes I'm noticing it doesn't show anything. Especially if I try to do something like float the image or try to make it full size (100% height/width.) 

I have read the docs quite a bit, but I feel like it's one of those things where something about it isn't clicking. Where I've struggled the most on my project with Gatsby is playing with these images, trying to get them to do what I want. Everything else is pretty clear cut and makes sense to me. 

I've poured over the docs and sifted through Google a lot. There's not a whole lot other than the basics of how to use the Img component. 

If anyone has experience or expertise with these, I'd love to pick your brain. 

Thanks!
Finding the Right Purgecss Extractor
Tags: purgecss, tips, tailwindcss, vue
Published: 2019-05-12 15:02:06

---
title: Finding the Right Purgecss Extractor
published: true
description: When using Tailwind with Vue's computed styles tweaking the extractor is required 
tags: Purgecss, tips, Tailwind, Vue
canonical_url: https://www.drewtown.dev/post/finding-the-right-purgecss-extractor
---

When I was writing the tutorial on [Setting up Tailwind with Purgecss](https://www.drewtown.dev/post/setting-up-tailwind-and-purgecss-with-gridsome-without-using-any-plugins) I was running into an issue where my Vue.js computed styles were getting purged by Purgecss.  I was having a hell of a time and hat tip to [@adamwathan](https://twitter.com/adamwathan), the creator of Tailwind, for pointing me in the right direction.

{% twitter 1126644092325322753 %}

When considering the "default" extractor for Tailwind `/[A-Za-z0-9-_:/]+/` it would absolute make sense that `hidden:` would be considered a valid class name.  Unfortunately if `hidden:` is the only place that our hidden class name appears then the class name that we really want `hidden` will no longer be in our CSS file.

Playing around with the RegEx and my Vue files I was able to adjust my RegEx to use the `\b` meta character on both the beginning and end of the RegEx.

```js
/\b[A-Za-z0-9-_:/]+\b/g
```

This has worked perfectly for me as I do not use any special characters to start or end my CSS classes and I do not see any cases where Tailwind does either. So now in my computed properties the RegEx finds only `hidden` and not `hidden:`.

```js
  computed: {
    navClasses() {
      return {
        block: this.navOpen,
        hidden: !this.navOpen
      };
    }
  }
```
Cover Your Base (Element)
Tags: html, webdev, frontend
Published: 2019-05-12 13:51:25

---
title: Cover Your Base (Element)
published: true
description: The <base> tag is an HTML element that allows you to specify a URL or attribute to all <a> elements in a document.
tags: HTML, webdev, frontend
---

The `<base>` tag is a child of the `<head>` tag that can pass down a specific URL to all link elements in an HTML document.

```html
<head>
    // If the <base> tag contains a URL

    <base href="http://fakeurl.dev/">
<head>
```

You can write `<a>` tags as the following:

```html
// A simple <a> tag without a specific 
<a>Link One</a>

// An anchor
<a href="#anchor">Link Two</a>

// A path from the original index.html of the URL
<a href="/fakepath">Link Three</a>
```

The links will direct as follows:

```html
// A simple <a> tag without a specific 
<a href="http://fakeurl.dev/">Link One</a>

// An anchor
<a href="http://fakeurl.dev/#anchor">Link Two</a>

// A path from the original index.html of the URL
<a href="http://fakeurl.dev/fakepath">Link Three</a>
```

You can also pass down a specific attribute, such as a `target`.

```html
<head>
    <base target="_blank">
    // will ensure that all links will open in a separate tab.
</head>
```

**Note:** There can only be one `<base>` tag in a head. If there is more than one it will recognize only the first `href` and `target` values.

<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base">Further reading.</a>

<a href="https://codepen.io/sdras/pen/KLzyqr">CodePen Example</a> by <a href="https://twitter.com/sarah_edo">Sarah Drasner</a>
Do you read dev books?
Tags: softwaredevelopment, books, read
Published: 2019-05-12 13:41:54

---
title: Do you read dev books?
published: true
description: Staying up to date in tech
tags: software development, books, read
---

Hey, guys, I'm just wondering if you read any books about software architecture, patterns etc in your spare time? I find it very hard to focus and get the patience to sit down and just read?
GitHub Package Registry: What Does It Mean For Ruby Devs?
Tags: discuss, ruby, rails, github
Published: 2019-05-12 12:50:59

---
title: GitHub Package Registry: What Does It Mean For Ruby Devs?
published: true
description: GitHub announced a new package registry. What does it mean for Ruby developers? Let's discuss!
tags: discuss, ruby, rails, github
---

This past Friday GitHub made a major announcement that they have created a new package registry. 

{% link https://dev.to/peter/github-announces-github-package-registry-3a27 %} 

Regular Dev contributor and all-around awesome human, [Tierney Cyren](https://dev.to/bnb), live tweeted the event and you can catch up on his twitter thread:

{% twitter 1126950003832786944 %}

There seems to be a lot of reaction in the JavaScript and Node communities. My question is what does this mean for Ruby devs? Does this have any implications for our work and workflow? Does this interact at all with RubyGems? 

Would love to hear your thoughts!
Go Introduction
Tags: beginners, tutorial, learning, go
Published: 2019-05-31 10:22:17

---
title: Go Introduction
published: true
tags: beginners, tutorial, learning, go
canonical_url: https://www.codetips.co.uk/languages/go/go-introduction/
---

> Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

 ![Go Introduction](https://images.unsplash.com/photo-1489533119213-66a5cd877091?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjExNzczfQ)

Go is a relatively new language; coming into existence in 2009 at Google. It is [statically typed](https://codetips.co.uk/intermediate/translation-and-types/) and it's a [compiled language](https://codetips.co.uk/intermediate/translation-and-types/).

It is a backend language, which means it's used to write applications that sit in the background performing tasks that other services (e.g. websites) ask of it.

There are a lot of backend languages already out there, but a lot of developers are choosing to learn and use Go due to its simplicity and speed.

Another reason we've chosen to teach you Go is the learning curve. It's a much easier language to learn, due to its simplicity, than other backend languages.

<!--kg-card-begin: hr-->
* * *
<!--kg-card-end: hr-->

You can download Go by going to their [downloads](https://golang.org/dl/) page and clicking the appropriate box for your platform.

<!--kg-card-begin: image-->

![Go Introduction](https://www.codetips.co.uk/content/images/2019/05/image-2.png)<figcaption>Go download page screenshot</figcaption>

<!--kg-card-end: image-->

Once you've downloaded/installed Go you can verify your installation by running the following command:

<!--kg-card-begin: code-->
```
go version
```
<!--kg-card-end: code-->

If the command outputs a version, you'll need to install a Code Editor (we recommend [Visual Studio Code](https://code.visualstudio.com/docs/introvideos/basics)) and then you're good to move on to the next articles.

If you get stuck and need some help, drop us a comment and we'll try to help you.
How do you separate and organize your Express.JS files?
Tags: help, expressjs
Published: 2019-05-12 12:50:22

---
title: How do you separate and organize your Express.JS files?
published: true
tags: help, express.js
---

I am currently working on a project in which I have to also create a server using express.js. I am curious to know what is the best way to organize the files. Do you extract every endpoint function into a new file? How do you group them?
Why is my Docker image so large?
Tags: docker, dive
Published: 2019-05-12 12:20:45

---
title: Why is my Docker image so large?
published: true
description:  Troubleshooting issues with Docker image size
tags: docker,dive
---

Keeping Docker images as small as possible has a lot of practical benefits. But even when following best practices 
- use stripped-down base image
- utilize multi-stage builds
- don't install what you don't need
- optimize build context
- minimize number of layers

some images end up being larger than they have to be inadvertently including files that are not necessary .

# How to troubleshoot issues with image size?

Image filesystem changes are tracked in layers. Each layer is the the representation of the file system changes for each instruction in Dockerfile. Layers of a Docker image are essentially  files generated from running some command during `docker build` in ephemeral intermediate container.


In the past, I used to perform `docker history <image name>` to view all the layers that make up the image, manually extract suspicious layers and inspect their content. It worked, but it was tedious.


# Dive
[Dive](https://github.com/wagoodman/dive) is a new tool for exploring a Docker images, inspecting layer contents and discovering ways to shrink your Docker image size - all that in a nice text-based user interface.

I recently used it to diagnose an unexpected image size growth caused by change of  file ownership & permissions. One of the instructions in `jboss/wildfly` based Dockerfile was `chown -R jboss:jboss /opt/jboss/wildfly/`. It looks innocent, but these files are originally owned by _jboos:root_. Docker doesn't know what changes have happened inside a layer, only which files are affected.  As such, this will cause Docker to create a new layer, replacing all those files (same content as _/opt/jboss/wildfly/_ but with with new ownership), adding hundreds of megabytes to image size. 


# Resources
- [Dive GitHub Page](https://github.com/wagoodman/dive)
- [Best practices for writing Dockerfiles](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/)
Weeknotes - 02 Makers PreCourse
Tags: bootcamp, weeknotes
Published: 2019-05-12 12:12:46

---
title: Weeknotes - 02 Makers PreCourse
published: true
description: Looking back on my 2nd week of the Makers pre-course.
tags: bootcamp, weeknotes
series: Makers weeknotes
---

## Week Two Of Four

Pros this week: solving problems, tackling fun challenges, catching up with my cohort! But, there were some cons too: getting cross-eyed stuck, ill health, feeling behind.

I sketched diagrams to help me better plan how to tackle some of this weeks' work, which was super helpful for visualising how I needed to transform my data. 

![](https://thepracticaldev.s3.amazonaws.com/i/6ke0rovtirvuik0qhe7r.jpg)
<figcaption>in reality my desk looked like it could have been featured in Memento<sup>1</sup>.</figcaption>


### Ruby Mastery

This week was all about logic and loops and FizzBuzz<sup>2</sup>!  I was _extremely_ pleased with myself for making a neat little program that renders text graphs in the command line (so much so that I snorted).
The complexity of arrays of hashes and hashes of arrays, sub-arrays, & sub-sub-arrays was bamboozling, so I leaned into that this week and solved the challenges with a combo of perseverance and thinking-time.  To get those neural pathways fully forged I read up on arrays and hashes with blocks &, spent some time getting knee-deep in them at virtual codebar<sup>3</sup>.

### Voice Connected ...

Speaking to a few of my cohort via webex helped me feel more connected to others in the group.  Hearing about their experience and their current/prior jobs was reassuring, both for steadying my pace and, knowing I've got some good company on the course!

## Misc.

 - Shoutout to Ayelisha<sup>5</sup> who agreed to be my mentor at Makers :handshake:
 - I pushed some code before running rspec it was so embarrassing...
 - Pull requests from different branches are hugely confusing & valuable experiences
 - Radio feature, "_A Job for the Boys_"<sup>4</sup> made for interesting listening

# Weeknotes Notes

1. **Memento** (2000) | [imdb](https://www.imdb.com/title/tt0209144/)
2. **FizzBuzz** | [wiki](https://en.wikipedia.org/wiki/Fizz_buzz)
3. **codebar** | [codebar.io](https://codebar.io/)
4. **BBC Radio 4** | _A Job for the Boys_ [Listen](https://www.bbc.co.uk/programmes/m0003t9y)
5. **Ayelisha Amoah** | [blog](https://medium.com/@ayelisha.amoah)

<sub>Edit: This post was edited to include Ayelisha Amoahs blog - May 2019</sub>