teleren/devto huggingface dataset:
The Vim Trick Which Will Save Your Time and Nerves
Tags: vim, sudo
Published: 2018-09-11 13:31:45

---
title: The Vim Trick Which Will Save Your Time and Nerves
published: true
description: 
tags: vim, sudo
---

Whether you're beginner or advanced Vim user, I'm sure you've seen this at least once:

```
E45: 'readonly' option is set (add ! to override)
```

It usually goes like this: 

You open a file with Vim and make some changes. When you try to save the file and see the message above. 

_Then_ you realize that you didn’t run Vim with `sudo`?! Argh, so annoying isn't it?

Today, you're gonna learn how to solve this easily, and once for all.

It's very simple, all you need to do is to add this line to your `.vimrc`:

```
cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
```

When you get to the same situation again and you can't save your file, simply run `:w!!` command, and your changes will be saved!


Now, how this works:

- `cnoremap` - tells Vim that the following mappings that is used when in command-line mode
- `w!!` - the mapping (shortcut) itself.
- `execute '<command>'` - executes a command between the quotes
- `silent!` - run it silently
- `write !sudo tee % >/dev/null` - the magic trick which would take another post to explain
- `<bar> edit!` - this calls the edit command to reload the buffer and then avoid messages such as "the buffer has changed".


Hint: you need to type `:w!!` fast, so it expands into the full command. Typing these four strings slowly and hitting `Enter` won't work.

---

I share tips like this at [Mastering Vim Quickly Newsletter](https://masteringvim.com).

I also wrote a book [Mastering Vim Quickly: From WTF to OMG in no time](http://jovicailic.org/mastering-vim-quickly/)

You can also get the best Vim tips by following [@MasteringVim](https://twitter.com/MasteringVim)
Upgrading Legacy Rails App Guide
Tags: rails, video
Published: 2018-09-11 12:21:01

---
title: Upgrading Legacy Rails App Guide
published: true
description: This 3 part series show you how to upgrade your legacy rails app
tags: 
  - rails
  - video
cover_image: https://thepracticaldev.s3.amazonaws.com/i/htkoqswxutfatqxdtc9w.jpg
---
![Upgrading Legacy Rails App Part 1](https://thepracticaldev.s3.amazonaws.com/i/htkoqswxutfatqxdtc9w.jpg)
[Upgrading a Legacy Rails App Part 1](https://www.codemy.net/posts/rails-upgrading-a-legacy-rails-app-part-1) - Upgrading a legacy rails app is a chore for every rails developer. Knowing the right strategy can save you a lot of time. We'll be showing you exactly how to go about it in this episode!

![Upgrading Legacy Rails App Part 2](https://thepracticaldev.s3.amazonaws.com/i/0vru3sg62jjt8olnm2w7.jpg)
[Upgrading a Legacy Rails App Part 2](https://www.codemy.net/posts/rails-upgrading-a-legacy-rails-app-part-2) - We continue the upgrade process from the previous episode. Now that our application is running on the stable version of 4.2.10 . We can start the process of upgrading to 5.2.1 . We will use the railsdiff.org extensively to guide us through the upgrade process.

![Upgrading Legacy Rails App Part 3](https://thepracticaldev.s3.amazonaws.com/i/xgclgg3hvmmfh5g2mksa.jpg)
[Upgrading a Legacy Rails App Part 3](https://www.codemy.net/posts/rails-upgrading-a-legacy-rails-app-part-3) - We finalize the upgrade process by patching up a few files. Once all the changes are in place we should be able to run bundle update rails
Ideas for front-end project crazy think :D
Tags: ideas, help, challenge, opensource
Published: 2018-09-11 11:39:39

---
title: Ideas for front-end project crazy think :D
published: true
description: 
tags: ideas, help, challenge, opensource
---

Hello, again guys!

I have a domain called http://frontend.city , and need ideas to make a cool thing.

Dont want a normal thing, need a really crazy idea, not so much complex on that at the first stage.

Post your idea! :D

Many thanks,

Pedro Cruz ---> www.pedropcruz.pt
Python Slices vs Ruby blocks  
Tags: ruby, python, blocks, lambdas
Published: 2018-09-11 08:40:18

---
title:   Python Slices vs Ruby blocks  
published: true
description: The power and flexibility of Ruby blocks
tags: ruby, python, blocks, lambdas
---

A couple of my Python colleagues tried to impress me today with Python's named slices feature. The way it works is like that:

```python
 s = list('helloworld!')
  => ['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd', '!']
WORLD = slice(5, 10)
s[WORLD]
 => ['w', 'o', 'r', 'l', 'd']
```

So you can have your own customised slicing mechanism that you can apply to any list. Which is kind of cool. That prompted me to demonstrate how we can do the same thing with Ruby. Luckily, in Ruby world we have blocks, procs and lambdas, the ultimate play-dough that allows us to stretch and flex in every direction.

```ruby
​s = ['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd', '!']
  => ['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd', '!']
world = proc {|x | x.slice(5, 10)}
world[s]
 => ["w", "o", "r", "l", "d", "!"]
```

​so we can do things like:

```ruby
first = proc { |x| x.slice(0) }
first[s]
=> "h"
```

or even things that we can't do with Python's named slicing, since it doesn't allow us to pass the receiver as an argument to the block (x in the example below)

```ruby
last = proc {|x| x.slice x.length-1, x.length}
last[%w(dog rabbit fox cat)]
=> ["cat"]
```
or

```ruby
median = proc {|x| x.slice(x.length / 2) }
median[%w(dog rabbit cat)]
=> "rabbit"
```

and of course we're not just restricted to slicing arrays,

```ruby
domain_extractor = proc { |x| x.gsub(/.+@([^.]+).+/, '\1') }
domain_extractor["fred@mydomain.co.uk"]
=> "mydomain"
```

and since a block is just an anonymous Proc object, we can use it with any method that accepts Proc parameters
​
```ruby
email_list = ["fred@mydomain.com", "john@gmail.com", "mary@yahoo.co.uk"]
=> ["fred@mydomain.com", "john@gmail.com", "mary@yahoo.co.uk"]
email_list.map(&domain_extractor)
=> ["mydomain", "gmail", "yahoo"]
```

Blocks and Procs (a.k.a lambdas) are ideal for some quick, reusable functionality or for when defining a full-blown method would be too much, but also for more serious uses such as callbacks and deferred execution.  IMHO, they are a fundamental part of what makes Ruby such a flexible and powerful language. Learn them, use them, enjoy them :)
How you can start create your js code if you had testing side?
Tags: javascript, testing, help, discuss
Published: 2018-09-11 10:37:23

---
title: How you can start create your js code if you had testing side?
published: true
description: 
tags: javascript, testing, help, discuss
---

Hello people,

This questions it's a little bit pain in the ass for me, but i need to understand and start to understand this.

Imagine, I had HTML, CSS and some [nameOfTheFile].model.js , this file you had some tests here.

Pretty cool here.

I see the tests and i can understand some things. But it's hard for me creating my own JS according to the tests and make them checked and right.

So, how you start to see this type of projects?

If you're confuse, please, send me a email or something and i can explain you better on hangout or something :)

www.pedropcruz.pt (at the bottom of my website, you had the email)

Many thanks,

Pedro Cruz
[VUE] How to access a variable from another instance
Tags: vue, help, frontend, newbie
Published: 2018-09-11 10:34:32

---
title: [VUE] How to access a variable from another instance
published: true
description: 
tags: vue, help, front-end, newbie
---

Hi, I'm sorry if this might be a stupid question but I didn't find any answer on the web. Maybe because I am not using the correct keywords idk.
Anyway, I'm using VueJS to create an application that keeps track of your blood alcohol level.
I am using 3 vue instances and I have to access an array from a v-for witch is located in another vue instance.


Here is my code: https://jsfiddle.net/nsk0g1ou/

I've put my vue instance in a variable and tried to recall that but it's not working.

Should I use mixins? 
I hope I've been clear.
Are Google and Facebook Evil?
Tags: google, facebook, discuss, data
Published: 2018-09-11 10:07:10

---
title: Are Google and Facebook Evil?
published: true
description: Selling and collecting personal data, influencing geopolitical climates...does this qualify as evil?
tags: google, facebook, discussion, data
---

Just a question I've been pondering lately. I'm working on a side hustle called [Engauge Analytics](https://engaugeanalytics.com/), something like Google Analytics with a machine learning component. But, I tagged this "Analytics Without the Evil".

It was right around the time that the [Facebook Cambridge Analytics scandal](https://www.nytimes.com/2018/03/19/technology/facebook-cambridge-analytica-explained.html) happened, and I think I coined it on a whim. It also comes at a time when [Facebook, Twitter, and Google (well, not Google) are all sitting before the US Congress](https://www.wired.com/story/facebook-twitter-congress-testimony-dorsey-sandberg/) to discuss foreign influence in elections and other data issues.

So, I guess, my question is....

Are Google and Facebook and the like that use our personal data for their own good evil? Are their actions in these circumstances wrong?
Self-Introduction
Published: 2018-09-11 08:25:23

---
title: Self-Introduction
published: true
description: about me
tags: 
---

Hi, I'm mobile developer in Japan.

I make iPhone/iPad apps as my office work and private work.

My representative work is [ALPACA](https://itunes.apple.com/app/id934444072?mt=8), photo-related app.
ALPACA is the app that helps you delete photos in iPhone/iPad quickly.
This app group similar photos automatically. You can delete photo grouped except you picked as left.

This app is loved by people that take many pictures of babies, pets, and selfies.


I'd like to post iOS dev tips in English. (I'm studying English!)
I'll write about UIKit, Swift, Layout System(Auto Layout&UIStackView), and etc.


Please follow me if you have interested in iOS dev. Thank you!


---
*I'm studying English. If you notice English mistake, please tell me in the comments.
Android8(Oreo)の開発者オプションのOn、Off
Tags: xperiazx2, 新型iphone
Published: 2018-09-11 07:10:23

---
title: Android8(Oreo)の開発者オプションのOn、Off
published: true
description: 
tags: Xperia ZX2, 新型iPhone
---

Xperia XZ2を購入した。

## 携帯遍歴
- 2009年
    - Xperia X10(SO-01B)
        - Donut から Eclairにアップデート
- 2011年
    - Galaxy Nexus(SC-04D)
        - Ice Cream Sandwich から Jerry Beansにアップデート
- 2013年
    - iPhone 5c
        - iOS 7
- 2015年
    - iPhone 6s
        - iOS 9
- 2018年
    - Xperia XZ2(SO-04K)
        - Oreo

2年ごとに買い換えてきたが、今回だけ3年経過していた。2009年のXperiaも2011年のGalaxy Nexusも早く飛びつきすぎたと感じたため、国内需要が伸びてきたiPhoneに乗り換えたあと、5c、6sと機種変更してきたところに、iPhone7Sが発売されなかったためだ。

iPhoneは初代、3、3GSのあと、4、4S、5、5s/5c、6/6 Plus、6s/6s Plus、SEと進んだあとは、
7/7 Plus、8/8 Plus、Xと進んできた。

明後日発表される、新型iPhoneは、Xs/Xs Plus/9/SE2、もしくは、Xs Max/Xr、そして、XC/XS/SX Plusと、いろんな説が飛び出してきている。

すでにXperiaに乗り換えた私は高見の見物と行きたいものです。

# Android8(Oreo)の開発者オプションのOn、Off

ところで、Androidの「開発者オプション」を有効にする手順がわからなかったので、ググってみたところ見つかりました。

[Android 開発者向けオプションを有効にする方法、無効にする方法を紹介](https://hayamizbg.net/developer-options/)

## 手順

[設定]-[システム]-[端末情報]と進み、「ビルド番号」の箇所をタップ、タップ、、

数回タップすると、「開発者になるまであとxステップです」と表示され、タップするごとにxの部分がカウントダウンしていきます。

カウントが０になると、ロック解除の画面になりますが、これを解除すると、「これで開発者になりました！」と明るいメッセージが表示され、端末情報の並びに「開発者向けオプション」が表示されるのです。

OFFにするには、開発者向けオプションの先頭のスイッチをOFFにするだけです。

OFFからONにするには前段同様にビルド番号を叩くアクションで再度ONにすることが出来ます。

これで、Androidの実機デバッグにXperiaを使用できます。ハッピーコーディング！
Regular Expression Validation In JavaScript
Tags: javascript, regx
Published: 2018-09-11 04:12:24

---
title: Regular Expression Validation In JavaScript
published: true
description: Regular Expression Validation In JavaScript
tags: #javascript #regx #
---

Post Link : <a href="https://www.skptricks.com/2018/01/regular-expression-validation-in-javascript.html" > Regular expression validation in JavaScript
 </a>

A Regular expressions is a powerful tool in any language. In this tutorial we will be discussing how to use regular expression in JavaScript. Regular expression is the most important part in form validations and it is widely used for search, replace and web crawling systems. A regular expression is also known as RegEx.


<img src="https://4.bp.blogspot.com/-TDt5ZvjgOro/WlNkNpEqqeI/AAAAAAAABKc/mVpJJjtrn_YJavluzvkWBbEfZ-lDVLffgCLcBGAs/s320/redular.jpg" />

or succinctly,
Regular expressions use to detect patterns in strings of text. Regular expressions provides a quick and easy way of matching a string to a pattern. Validation of mobile no, username, email id, website url are possible through Regular expressions.

<a href="https://www.skptricks.com/2018/01/regular-expression-validation-in-javascript.html" > Read More...
 </a>
freecodecamp.org - html, js, css basics
Tags: html, javascript, css, example
Published: 2018-09-11 03:49:47

---
title: freecodecamp.org - html, js, css basics
published: true
description: We look at the freecodecamp.org site and how to use it, you can refresh your knowledge or start your career with just a few simple steps.
tags: html, javascript, css, example
---

{% youtube YQqVAq-v_m8 %}
Fun with your Amazon order history
Tags: amazon, sql, sqlite, csv
Published: 2018-09-11 02:11:28

---
title: Fun with your Amazon order history
published: true
description: how much have you spent on your books?
tags: amazon, sql, sqlite, csv
---

## Querying Amazon Purchase data

Create an order history report using [instructions here](https://www.amazon.com/gp/help/customer/display.html?nodeId=200131240)

Load CSV into [SQLite](https://www.sqlite.org/index.html)

```
sqlite> .mode csv
sqlite> .import ./01-Jan-2009_to_11-Sep-2018.csv orders
```


Table schema

```
sqlite> .sch
CREATE TABLE orders(
  "Order Date" TEXT,
  "Order ID" TEXT,
  "Title" TEXT,
  "Category" TEXT,
  "ASIN/ISBN" TEXT,
  "UNSPSC Code" TEXT,
  "Website" TEXT,
  "Release Date" TEXT,
  "Condition" TEXT,
  "Seller" TEXT,
  "Seller Credentials" TEXT,
  "List Price Per Unit" TEXT,
  "Purchase Price Per Unit" TEXT,
  "Quantity" TEXT,
  "Payment Instrument Type" TEXT,
  "Purchase Order Number" TEXT,
  "PO Line Number" TEXT,
  "Ordering Customer Email" TEXT,
  "Shipment Date" TEXT,
  "Shipping Address Name" TEXT,
  "Shipping Address Street 1" TEXT,
  "Shipping Address Street 2" TEXT,
  "Shipping Address City" TEXT,
  "Shipping Address State" TEXT,
  "Shipping Address Zip" TEXT,
  "Order Status" TEXT,
  "Carrier Name & Tracking Number" TEXT,
  "Item Subtotal" TEXT,
  "Item Subtotal Tax" TEXT,
  "Item Total" TEXT,
  "Tax Exemption Applied" TEXT,
  "Tax Exemption Type" TEXT,
  "Exemption Opt-Out" TEXT,
  "Buyer Name" TEXT,
  "Currency" TEXT,
  "Group Name" TEXT
);
```


Simple query for all the books (the ISBNs do not start with letter `B`):

```sql
sqlite> select "Order Date", "Title", "ASIN/ISBN", "Purchase Price Per Unit" from orders where "ASIN/ISBN" NOT LIKE "B%";
```
Total money spent on Books:

```sql
sqlite> select SUM(CAST("QUANTITY" AS DECIMAL) * CAST(SUBSTR("Purchase Price Per Unit",2) AS DECIMAL)) from orders where "ASIN/ISBN" NOT LIKE "B%";
```
New Web Framework?
Tags: ask, webdev, html, discuss
Published: 2018-09-10 22:14:48

---
title: New Web Framework?
published: true
description: What if a webframework made a backend for your webpages?
tags: ask, webdev, html, discuss
cover_image: https://thepracticaldev.s3.amazonaws.com/i/qntn1sdrhsiskcsdtgul.png
---

I've been working on a web framework, but before I go any further, I thought I should check to see if anyone else is interested in the type of framework I'm building.

Web developers build all kinds of things, but one of the most common things they build are forms.  Order forms.  Email signup forms.  Business process forms.  Forms to enter data from a fax.  All kinds of forms.

These kind of webapps usually have some html, a custom webservice, some middleware to do business/database stuff and a database.

I know I get tired of writing the webservice and the middleware boiler plate again and again.  The forms change a little, and you need to either write a fresh webservice and fresh data access objects, or make your existing webservices even smarter.

What if there was a tool that could inspect your html pages and generate a backend for you?

I think something could inspect a form, make sensible default table and column names and web services to populate them.  Done right, the tool could make something that would require very little manual tweaking.  I think a tool like this would let web developers put time into what they care about (delivery quality products and making money) as well as what the customers care about (having good looking web page that do what they want).

Would anyone else be interested in a tool like this?
The burnout, how do you deal with it?
Tags: discuss, programming, vent
Published: 2018-09-06 16:39:22

---
title: The burnout, how do you deal with it?
published: true
description: Someday, you just feel mucky 
tags: #discuss, #programming, #vent
---
## TL;DR
feeling overwhelmed today, how do you tend to deal with your days you feel burned out.

## The gist
Somedays, you wake up and you just feel it. Today is that day for me. I woke up to an email from a client, requesting some changes to her online application form. This thing is pretty large. The changes, not that big of a deal. 

I just started thinking of how annoying it's going to be to change this stuff. I mean I wrote it in symphony 3 forms, so it's done proper. It's just that now I have to change the entity model, the twig templates, migrate the database changes.... uggg!!

I love object oriented software, but sometimes I just hate it. Sometimes, I just want to go back to the old days of 1 liner changes, where it would write to flat files. As simple as a 2 minute change to add/remove features. 

Sure it was easy to break, but it was also easy to fix! 

The problem isn't OOP. The problem is, that I then started to think about how I could refactor the entire form to be React/API and make the api store json docs, so they could be modified without a huge headache. Using the json-schema on the front end for the fields. 

But how much work would that be?! And what if they never change a thing on the form again? How much time would I have wasted for no benefit. 

Would I use PHP or node for the backend? Convert the Mysql to postgres or elasticsearch (nope, that is super over kill).

Next thing I know, I'm annoyed, and I feel like I know to many things on "how it should be", but there is never enough time in the day. And anytime you're certain, you built it the best way possible, 6 months down the road, you are annoyed with yourself for not doing it X, Y, Z...

Also part of me feels like the "you have to do it this way, because everyone is in agreement" is bullshit. That is because the other part of me is "everyone over complicated things. Sometime, simple is better". An internal war. If the software end results are the exact same, and fully tested, is one really better than that other? Well how easy is it to maintain? :/

So today, I just feel the burn, and it's not fun. Luckily I know these only last a few hours or a day at max. I code literally everyday. I just have to let the annoyance pass.

So whats your story and how do you deal with it?

--DeChamp
How do you delegate work? especially to offshore developers?
Tags: discuss
Published: 2018-09-10 21:23:51

---
title: How do you delegate work? especially to offshore developers?
published: true
description: I wonder what practices do lead developers follow to delegate work to their team members?
tags: #discussion
---

I find it really hard to delegate work to my development team, especially offshore developers because of the time difference. I can't reach out to most of my team during my work hours and they can't reach out to me...


Additionally, I keep looking at user stories and thinking: "I could do that myself, faster and exactly how I want it". But there are so many hours in a day and I keep restraining myself from taking on more work on my already full plate. Also, I recognize that if I did everything for my team, they miss on learning opportunities that I've enjoyed in the past.

I wonder how other lead developers do it? Any techniques or practices that might help?
Splitting a web client into (semi) independent Node Modules.
Tags: react, angular, node, discuss
Published: 2018-09-10 21:21:21

---
title: Splitting a web client into (semi) independent Node Modules.
published: true
description: Discussion on separating a web application into several different packages.
tags: react, angular, node, discuss
---

I don't think there is anything that disrupts my workflow more than a huge test suite full of failing tests that are completely out of my domain. Working on an enterprise team means the code base I contribute to is massive and the test suite takes well over 20 minutes to run. That is obviously an issue since I constantly have to modify my test configuration to limit the amount of specs that will be run. This reduces the effectiveness of test suite in spotting issues.

I've read throughout my leisure time of teams that separate entire chunks of their application into a separate package. Basically, treat each part of your application as a `node_module` a la "micro-services". This sounds like a great idea since each test suite would be limited to a much smaller project but how do we manage shared dependencies? What about the host application that depends on all of these packages?

Have you worked on a team that took this approach? What strategies did you use and was it ultimately helpful or just another layer of complexity that added more issues than it solved? I'm especially concerned with Angular and React projects since these are the technologies we currently use in our products.
[Series] Experiencing the facts and fallacies of software engineering - Intro
Tags: softwareengineering, career, series, discuss
Published: 2018-09-10 21:02:54

---
title: [Series] Experiencing the facts and fallacies of software engineering - Intro
published: true
description: A hindsight look into the life of software engineering
tags: software engineering, career, series, discuss
---

A bit over two weeks ago I saw this [interesting looking book](https://www.amazon.com/Facts-Fallacies-Software-Engineering-Robert/dp/0321117425) over at the school bookstore. As a person who believes in professional development for software engineering I took up the book. But of course, as do in most of my attempts to pick up a book (or article), it has been added up to my backlog of to-read list.

So to up the reading game a bit I've decided to make my first few posts on DEV to be about this book and how it fairs against my experience. This way not only will I stay motivated to read the book, but I get to share and converse (hopefully) with others on the subjects presented in the book.

I have no intention to go over through the whole content of the book here, but only those that I feel I have something to say about or have experienced. Hope you will stay tuned on this series (_and my first few posts on DEV_)