teleren/devto huggingface dataset:
GitLab: You're Kidding Me, Right?
Tags: annoyances, cli, git, gitlab
Published: 2019-01-31 00:25:29

---
title: GitLab: You're Kidding Me, Right?
published: true
tags: annoyances,cli,git,gitlab
canonical_url: https://thjones2.blogspot.com/2019/01/gitlab-youre-kidding-me-right.html
---

Some of the organizations I do work for run their own, internal/private git servers (mostly GitLab CE or EE but the occasional GitHub EE). However, the way we try to structure our contracts, we maintain overall ownership of code we produce. As part of this, we do all of _our_ development in our corporate GitHub.Com account. When customers want the content in _their_ git servers, we set up a replication-job to take care of the requisite heavy-lifting.

  

One of the side-effects of developing externally, this way, is that the internal/private git service won't really know about the email addresses associated with the externally-sourced commits. While you _can_ add all of your external email addresses to your account within the internal/private git service, some of those external email addresses may not be verifiable (e.g., if you use GitHub's "noreply" address-hiding option).

  

GitLab makes having these non-verifiable addresses in your commit-history not particularly fun/easy to resolve. To "fix" the problem, you need to go into the GitLab server's administration CLI and fix things. So, to add _my_ GitHub "noreply" email, I needed to do:

  

1. SSH to the GitLab server
2. Change privileges (sudo) to an account that has the ability to invoke the administration CLI
3. Start the GitLab administration CLI
4. Use a query to set a modification-handle for the target account (my contributor account)
5. Add a new email address (the GitHub "noreply" address)
6. Tell GitLab "you don't need to verify this" (mandatory: this must be said in a Obi-Wan Kenobi voice)
7. Hit save and exit the administration CLI

For me, this basically looked like:
  

> ```
> gitlab-rails console production
> -------------------------------------------------------------------------------------
>  GitLab:       11.6.5 (237bddc)
>  GitLab Shell: 8.4.3
>  postgresql:   9.6.10
> -------------------------------------------------------------------------------------
> Loading production environment (Rails 5.0.7)
> irb(main):002:0> user = User.find\_by(email: 'my@ldap.email.address')
> => #<user id:532="" thjones2=""><br>irb(main):003:0&gt; user.email = 'ferricoxide@users.noreply.github.com'<br>=&gt; "ferricoxide@users.noreply.github.com"<br>irb(main):004:0&gt; user.skip_reconfirmation!<br>=&gt; true<br>irb(main):005:0&gt; user.save!<br>=&gt; true<br>irb(main):006:0&gt;<br></user>
> ```

Once this is done, when I look at my profile page, my GitHub "noreply" address appears as verified (and all commits associated with that address show up with my Avatar)
How much does apple cost in your country?
Tags: discuss, meta
Published: 2019-01-18 21:56:50

---
title: How much does apple cost in your country?
published: true
description: A comparison about apple prices outside USA
tags: discuss, meta 
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sjf6g97yif6a0tqrki7j.jpg
---

History time,
You work hard and tech is your passion, you use your computer every single day and you think you deserve a good machine for both work and play time. 👨‍💻

Apple 🍎 is the favorite brand, no questions here, it's also no surprise, apple does cost more, and if you live in US, sure you think apple is expensive...but wait a minute my friend! Let's check my country, Brazil 🇧🇷:

Let's go on [apple.com](apple.com) US and setup a pro computer, for pro user 🙂


![Custom macbook pro $3,849.00](https://thepracticaldev.s3.amazonaws.com/i/xky9yda7ybyo88heajct.png)

### Ouch!
That's a lot dollars! $3,849 or in Brazilian money: R$14.441, that is **14x the minimal wage in Brazil** 🤨

![Custom macbook pro R$14.441](https://thepracticaldev.s3.amazonaws.com/i/ovmj7d1lfghytnhzl5rx.png)

### Actually...
Actually, considering the taxes, [the same product on apple Brazil](https://www.apple.com/br/shop/buy-mac/macbook-pro/15-polegadas-cinza-espacial-seis-n%C3%BAcleos-de-2,6-ghz-512gb#) goes twice as much the USA price, or **33x the minimal wage**.

> [It is a common belief among Brazilians that it is cheaper to fly to Miami and buy iPhones and iPads there than to acquire them at home.](http://www.bnamericas.com/en/features/ict/why-is-the-iphone-so-expensive-in-brazil)

![Brazil to miami](https://thepracticaldev.s3.amazonaws.com/i/afeeehk21dmn8obo3wej.png)


# How much apple products costs in you country? Let me know bellow!
Add vim to a pipeline with vipe
Published: 2021-08-11 13:53:50

---
title: Add vim to a pipeline with vipe
published: true
date: 2019-01-18 21:39:00 UTC
tags: 
canonical_url: https://www.rakeroutes.com/add-vim-to-a-pipeline-with-vipe
---

Have you ever wanted to stop and edit text in the middle of a pipeline? With `vipe` you can!

Take the output of `brew search` as an example.

```
$ brew search proxy
==> Formulae
aws-es-proxy metaproxy proxytunnel
dnscrypt-proxy mitmproxy sproxy
haproxy oauth2_proxy tinyproxy
ios-webkit-debug-proxy ocproxy twemproxy
libproxy proxychains-ng

==> Casks
proxyman
```

What we if want to call `brew info` to get more details for those formulae?

Even if we pipe the output to something (e.g. cat) we still have the Formulae and Casks headers:

```
$ brew search proxy | cat
==> Formulae
aws-es-proxy
dnscrypt-proxy
haproxy
ios-webkit-debug-proxy
libproxy
metaproxy
mitmproxy
oauth2_proxy
ocproxy
proxychains-ng
proxytunnel
sproxy
tinyproxy
twemproxy

==> Casks
proxyman
```

We _could_ write some intermediate steps to remove the lines we don’t want. But wouldn’t it be great to have our pipeline stop, let us edit the stream, and then continue?

```
$ brew search proxy | magic | while read formula; do brew info $formula; done
```

It turns out that `vipe` can be that magic! It will stop and give you a vim session with the output of the preceeding pipe. When you write/quit the vim session that output will be sent down to the subsequent commands in the pipe. Awesome!

## Installing vipe

You can get `vipe` on OSX as part of the `moreutils` brew formula.

```
$ brew install moreutils
```

## Usage

Then drop it in wherever you want to quickly edit text in the middle of the pipeline. It’s also great as a nice way to view intermediate output of a pipeline.

```
$ brew search proxy | vipe | while read formula; do
  brew info "$formula";
done
```

When we run that command the `brew search proxy` output goes straight into a vim buffer.

```
 1 ==> Formulae
 2 aws-es-proxy
 3 dnscrypt-proxy
 4 haproxy
 5 ios-webkit-debug-proxy
 6 libproxy
 7 metaproxy
 8 mitmproxy
 9 oauth2_proxy
10 ocproxy
11 proxychains-ng
12 proxytunnel
13 sproxy
14 tinyproxy
15 twemproxy
16
17 ==> Casks
18 proxyman
```

vim editing goodness We can manipulate that buffer to be whatever we want.

```
1 mitmproxy
```

How about we trim down to one interesting formula? When we save and quit the pipeline continues into the `while read` loop that sends all the input to `brew info`.

```
"/private/var/folders/n6/gxxgmjhs1599x195xzdbnp_40000gn/T/mL0nDL6bCD" 1L, 10C written

mitmproxy: stable 4.0.4 (bottled), HEAD
Intercept, modify, replay, save HTTP/S traffic
https://mitmproxy.org
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mitmproxy.rb
==> Dependencies
Required: openssl@1.1 ✔, protobuf ✘, python ✘
==> Options
--HEAD
    Install HEAD version
==> Analytics
install: 6,017 (30 days), 15,281 (90 days), 46,094 (365 days)
install_on_request: 5,777 (30 days), 14,445 (90 days), 44,138 (365 days)
build_error: 0 (30 days)
```

Nice!
A lighter dev.to theme
Tags: meta, discuss
Published: 2019-01-18 21:30:55

---
title: A lighter dev.to theme
published: true
description: Adding a bit of simple CSS to make articles a bit easier to read
tags: meta, discuss
---

I recently saw this issue brought up on the dev.to repo review:

{% github https://github.com/thepracticaldev/dev.to/issues/1470 %}

I thought I'd take a swing at simplifying the article theme a bit, using the [Stylus](https://github.com/openstyles/stylus) extension. Here's where I ended up:

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

If you like this and want to install it, you can [find it here](https://userstyles.org/styles/167958/dev-to-simple-style)!

What do you think? What would you change?
Why You Should Learn TypeScript
Tags: typescript, javascript
Published: 2019-01-22 13:12:05

---
title: Why You Should Learn TypeScript
published: true
tags: typescript, javascript 
canonical_url: https://www.telerik.com/blogs/why-you-should-learn-typescript
---

This time on the Eat Sleep Code podcast, we learn why it's important for developers to learn TypeScript.

On this episode, David Pine (Microsoft MVP) shares his experience with TypeScript. David talks about why TypeScript is a valuable tool for improving your experience with applications that normally are written using JavaScript. We discuss how to compile TypeScript, what are its strengths and how to get started.

You can listen to the [entire show](https://soundcloud.com/esc-podcast/why-you-should-learn-typescript) and catch [past episodes](https://soundcloud.com/esc-podcast) on SoundCloud. 

<iframe width="100%" height="166" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/546287049&amp;color=%23ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;show_teaser=true"></iframe>
## David Pine

David Pine is a Technical Evangelist, [Microsoft MVP](https://mvp.microsoft.com/en-us/publicprofile/5002736) and Google Developer Expert working at [Centare](https://www.centare.com/) in Wisconsin. David loves knowledge sharing with the technical community and [speaks internationally](http://davidpine.net/speaking/) at meetups, user groups, and technical conferences. David is passionate about sharing his thoughts through writing as well and actively maintains a blog at [davidpine.net](http://davidpine.net/). David's posts have been featured on [ASP.NET](https://www.asp.net/), [MSDN Web-Dev](https://blogs.msdn.microsoft.com/webdev/), [MSDN .NET](https://blogs.msdn.microsoft.com/dotnet/) and [Dot Net Curry](http://www.dotnetcurry.com/). David loves contributing to [open-source projects](https://github.com/IEvangelist) and [stackoverflow.com](http://stackoverflow.com/users/2410379/david-pine) as another means of giving back to the community. David sat on the technical board and served as one of the primary organizers of Cream City Code for going on four years. When David isn’t interacting with a keyboard, you can find him spending time with his wife and their three sons, Lyric, Londyn and Lennyx. Follow David on Twitter at [@davidpine7](https://twitter.com/davidpine7).

## Show Notes
<iframe width="560" height="315" src="https://www.youtube.com/embed/L7IY9vKO2Bw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"></iframe>
- [David's slides for TypeScript Making JavaScript Tolerable](https://gitpitch.com/IEvangelist/TypeScriptMakingJsTolerable#/)
- [TypeScript](https://www.typescriptlang.org/)

### Related Resources

- [Kendo UI for Angular - Professional Grade Angular UI Components](https://www.telerik.com/kendo-angular-ui)
- [Build better NativeScript apps with TypeScript](https://www.nativescript.org/using-typescript-with-nativescript-when-developing-mobile-apps)

### Transcript

Coming soon!
Sh*tpost: can we stop saying "syntactic sugar"?
Tags: discuss, beginners, javascript, unpopularopinion
Published: 2019-01-18 19:56:52

---
title: Sh*tpost: can we stop saying "syntactic sugar"?
published: true
description: What does it actually mean? you're not helping!
tags: discuss, beginner, javascript, unpopularopinion
cover_image: https://ak3.picdn.net/shutterstock/videos/3107113/thumb/2.jpg 
---

"Syntactic sugar": After self-studying what seems like a narrow and ever-changing field for four years this term keeps rearing its head. I'm not usually one to squabble over the semantic aspects of any language... but this noun has sent me into a confusing tailspin before. 

The first time I heard of the term "syntactic sugar" was in relationship to React.  I heard about it in terms of `JSX` in a Wes Bos [React](https://reactjs.org/docs/jsx-in-depth.html) video. Then it was described as such in terms of [`async` and `await`](https://ponyfoo.com/articles/understanding-javascript-async-await). Hell, there are even talks on this!

![syntactic sugar toy story meme](http://memecrunch.com/meme/1E92X/syntactic-sugar/image.png)

(Without Googling) What I interpret it to mean between seasoned developers, is that syntactic sugar is an aspect of a language or framework that allows devs to write code in an abbreviated, clear and/or easier way. 

For example, writing JSX helps with integrating javascript into HTML in a view while writing partials. `Async`/`await` makes Javascript *look* as if it's synchronous while reminding us it's going to run asynchronously, pause the execution of a function and wait til a promise resolves or information returns.

Couldn't it be argued that anything that abbreviates or makes writing code simpler and cleaner "syntactic sugar"? Wouldn't template literals, destructuring or even `++` and `+=` then be syntactic sugar?

Despite the analogy, the term "syntactic sugar" did not/is not helping me, or learners understand what the very sweet, refined characteristic of a language or framework does! 

Every time I hear it, I'm just going to omit and continue reading the examples. 

`rant.end()`

Ok. I'm open to hearing how this term is canonical and useful. It's likely I'm just "young" on my second career and disgruntled.

***

So I did have to google if anyone on the internet shared my opinion, and [this post](https://medium.freecodecamp.org/js-diabetes-and-understanding-syntax-sugar-5de249ee9ebc) seems to place my sentiments more eloquently. 

I needed a definition anyway, so here are some resources I found helpful:
[Sweet API – Syntactic Sugar And You](https://nordicapis.com/syntactic-sugar-apis/)
[Quora | What is Syntactic Sugar?](https://www.quora.com/What-is-syntactic-sugar-in-programming-languages)
An alternate way to calculate Fibonacci series
Tags: python, math
Published: 2019-01-18 18:59:48

---
title: An alternate way to calculate Fibonacci series
published: true
description: 
tags: python, math
---

###### (The alternate way is at the end!)

Fibonacci series is a collection of numbers which two numbers that precede it.


Which will produce a series like this:

`0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377`


## Calculating it

There are two popular ways to do this

* Using the normal method (`1 + 1 = 2`, `1 + 2 = 3`, `3 + 2 = 5`, `...`)
* Using the recursive method (`Fn = F(n - 1) + F(n - 2)` where `F1` and `F2` is equal to `1`)

Implementations in Python will be something like this (Finding first 100 Fibonacci numbers)

- Normal method
```python
a, b = 0, 1
for _ in range(100)
  print(a, end=' ')
  a, b = b, a + b

#=> 0 1 1 2 3 5 8 13...
```

- Recursive method
```python
def fib(n):
  if n < 3:
    return 1
  return fib(n - 1) + fib(n - 2)

for n in range(100):
  print(fib(n), end = ' ')

#=> 0 1 1 2 3 5 8 13...
```
###### (Not recommended to do it in Python due Tail Call Optimization)

---

So until now, I haven't seen any other ways. Why not find another way?


There is an interesting fact in Fibonacci numbers. What is the fact?

-> Dividing `F(n + 1)` with `Fn` (`F(n + 1) / Fn`) will approximate the golden ratio! (`1.61803399...`)

Let us test it!

`1, 1, 2, 3, 5, 8, 13, 21, 34...`

```
1 / 1 = 1  
2 / 1 = 2  
3 / 2 = 1.5  
8 / 5 = 1.6  
13 / 8 = 1.62  
21 / 13 = 1.615  
34 / 21 = 1.619  
...  
```

And so on! While numbers getting numbers bigger, the ratio will be more similar to the golden ratio. Then, what we can do with it?

If `F(n + 1) / Fn ≈ φ`, `Fn * φ` will be (approximately) equal to `F(n + 1)` which founds the next fibonacci number!

So, let's implement it in Python!

```python
fib = 1
for _ in range(100):
  print(fib, end=' ')
  fib = round(fib * 1.618)

#=> 1, 1, 2, 3, 5, 8, 13, 21, 34...`
```

So I multiplied `fib` with `1.618` which is approximate golden ratio. As I said it will be found next fibonacci number approximately. Then I rounded it because I want an integer, not a decimal. If we need to visualize it:

``` 
fib = 1  
fib = round(fib * 1.61) -> fib = round(1.61) -> fib = 2      
fib = round(fib * 1.61) -> fib = round(3.22) -> fib = 3      
fib = round(fib * 1.61) -> fib = round(4.83) -> fib = 5      
fib = round(fib * 1.61) -> fib = round(8.05) -> fib = 8      
...  
```


And so on! It's an interesting method (found by me :p), but it can be wrong for really big numbers. For big numbers, you will need a better approximation of the golden ratio to use it. Because the decimal numbers multiplying with big numbers will create bigger numbers. For example:

```
1.2345 * 10 = 12.345  
1.2345 * 100 = 123.45  
1.2345 * 1000 = 1234.5  
1.2345 * 10000 = 12345  
1.2345 * 100000 = 123450  
```


So basically I don't recommend this method for big numbers.

Thanks for reading this post!
Binary Search Algorithm - C Programming Example
Tags: binarysearch, cprogramming, c, algorithm
Published: 2019-01-18 18:13:24

---
title: Binary Search Algorithm - C Programming Example
published: true
description: Binary Search Algorithm and Example With C Programming Language
tags: binary search, c programming, c, algorithm
cover_image: https://thepracticaldev.s3.amazonaws.com/i/nqg8p8qyriiz87jewc19.jpg
---


A binary search algorithm is a search algorithm that finds the position of searched value within the array. In the binary search algorithm, the element in the middle of the array is checked each time for the searched element to be found. If the middle element is not equal to the searched element, the search is repeated in the other half of the searched element. In this way, the search space is halved at each step.

The binary search algorithm works on sorted arrays. For non-sorted arrays, the array must first be sorted by any sorting algorithm in order to make a binary search.

The steps of binary search algorithm:


1- Select the element in the middle of the array.

2- Compare the selected element to the searched element, if it is equal to the searched element, terminate.

3- If the searched element is larger than the selected element, repeat the search operation in the major part of the selected element.
 
4- If the searched element is smaller than the selected element, repeat the search in the smaller part of the selected element.

5- Repeat the steps until the smallest index in the search space is less than or equal to the largest index.

For example; 2,3,4,5,6,7,8,9,22,33,45. 

The following steps will be followed to find the number 4 with binary search in a sequential array of these numbers.

The middle element of the array is selected as 7 and compared with the searched element 4. The searched element (4) is not equal to the middle element (7), the part at the center of the array which is less than 7.

Our new search array: 2,3,4,5,6.

The middle element of our new search array is 4 and the search is completed.

With binary search algorithm, it is possible to find the searched value to log2N comparisons in an N-element array.

A sample C code will be as follows if we try to implement the binary search algorithm in a sequential array as in the example.

C Example:

```c

#include <stdio.h>
int main()
{
	int array[11] = {2,3,4,5,6,7,8,9,22,33,45};
	int low       = 0;
	int high      = 10;
	int flag      = 0;
	int s         = 4;
	
	while(low <= high){
		int index = low+(high-low)/2;
		if(array[index] == s){
			flag = 1;
			printf("Founded: %d \n",index);
			break;
		}
		else if(array[index] < s){
			low   = index+1;
		}
		else{
			high = index-1;
		}
	}
	if(flag == 0){
		printf("Not Found!\n");
	}

	return 0;
}

```
#10YearChallenge
Tags: kotlin, c, joke
Published: 2019-01-18 16:35:30

---
title: #10YearChallenge
published: true
description: how things have changed for the "complexer"
tags: kotlin, c++, joke
---
**2009** | wow I can code!

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


**2019** | writing modular, maintainable code. using fancy language features, writing blog posts.

![two](https://thepracticaldev.s3.amazonaws.com/i/k5lj9x7mi33us3mfmxkv.png)
Using arrow function to define a method
Tags: react, arrowfunction, method
Published: 2019-01-18 16:24:30

---
title: Using arrow function to define a method
published: true
description: 
tags: React, arrow function, method
---

Hi,

I started learning React and right now I'm a bit confused about where to use Arrow-function to define a method and where not to use it.


# First let's check object literals

This code works:
```
const person = {
  points: 23,
  score() {
    return this.points++;
  }
};

person.score(); // Works
```
But the bellow code doesn't work, because we defined the score() method as an arrow-function:
```
const person = {
  points: 23,
  score: () => {     // Arrow function
    return this.points++;
  }
};

person.score(); // Doesn't work
```
**Take away: Never define methods in an object literal via arrow-function.**
**Is the above statement correct?**




# What about JavaScript classes?

This code works:

```
class Dog {
    constructor(name, bread) {
        this.name = name;
        this.bread = bread;
    }

    bark() {
        return `Bark Bark! My name is ${this.name}`;
    }
}
const mini = new Dog('Mini', 'Spitz');
mini.bark();

```
And the bellow code, which uses arrow-function syntax to define the bark() method works too:

```
class Dog {
  constructor(name, bread) {
    this.name = name;
    this.bread = bread;
    this.bark = () => {     // Arrow function
      return `Bark Bark! My name is ${this.name}`;
    }
  }
}
const mini = new Dog('Mini', 'Spitz');
mini.bark();
```
**Take away: It's fine to define methods in a Class via arrow-function.**

**Is the above statement correct?**


# What about React classes (class components)?

**It is even recommended to use arrow-functions for defining methods inside React classes as a way to create "auto-binding" methods, e.g. methods that could be used by event handlers but that stayed bound to the class.**

**Is the above statement correct?**