teleren/devto huggingface dataset:
Implementing Flexbox with SCSS mixins 
Tags: css, scss, sass, flexbox
Published: 2019-10-03 11:51:35

---
title: Implementing Flexbox with SCSS mixins 
published: true
description: Using SCSS mixins and functions to make writing flexbox code easier
tags: css, scss, sass, flexbox
---
![CSS and HTML](https://images.pexels.com/photos/160107/pexels-photo-160107.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940)

I was scouring the internet for a good mixin for flexbox but I would always come across mixins like these,

```
@mixin flexbox() {
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}
```
with a mixin for every possible property,
```
@mixin justify-content($justify) {
  -webkit-justify-content: $justify;
     -moz-justify-content: $justify;
      -ms-justify-content: $justify;
          justify-content: $justify;
            -ms-flex-pack: $justify;
}
```
While this may work for a lot of people, I still felt that it could be made simpler, or "DRY'er". I'm pretty sure someone must have done something like this before, but I couldn't find it. So after a little bit of struggling around with SCSS mixins and functions, I came up with this,

{% gist https://gist.github.com/Blazephoenix/aca2ab809fa44937f51452ce64b922c5 %}

More functions can be created and extended into the mixin such as flex-direction, flex-wrap, flex-grow, etc. with the @content directive in a similar way. It can also be used on properties that use the same values like justify-self or align-self. I will be updating this post with a github repo for all the functions and mixins soon.

---
Would love to know if anyone finds it useful. Thanks.
Best SEO Company & Services
Tags: seoagencyusa, seoagencynearme, localseocompany, bestseoservices
Published: 2019-10-03 11:51:09

Want to avail the best SEO services to get organic traffic to your website? For this, the first thing you will probably do is to search for a good company by typing “SEO Agency near me” in any of the search engines. Once you hit the enter key, Google or any other search engine will display you a list of different companies.
Choosing the best SEO Company near me by searching this way might consume a lot of time. But you can save this by simply choosing Sarahbits for all your digital marketing needs. Sarahbits is the most popular and reputed SEO Service Company that is recognized for offering you result-driven SEO services to bring desired traffic to your e-store by boosting up its visibility in the search engines. 
Contact the Sarahbits professionals and build a path for your e-business success today!
https://sarahbits.com/blog/best-seo-company-help-you-grow-your-e-business/
What is reverse proxy? Why it is essential?
Tags: productivity
Published: 2019-10-03 11:50:04

What is forward proxy? 

A forward proxy, often called a proxy, proxy server, or web proxy, is a server that sits in front of a group of client machines. When those computers make requests to sites and services on the Internet, the proxy server intercepts those requests and then communicates with web servers on behalf of those clients, like a middleman

What is reverse proxy?

Reverse Proxy is an intermediate medium used for distribution of incoming traffic across multiple servers. i.e. balancing the load across servers. In most cases it is a common server which acts as an intermediate, or you can say a face for incoming traffic.

Why should you use it?

Scaling benefits are:

- Increased scalability and flexibility 
- Compression
- Caching 

Security benefits are:

 - Increased security 
 - SSL termination
 - Firewall Protection

For more in depth detail read below.   
https://aarvy.me/blog/2019/09/30/what-is-reverse-proxy-live-example-2019/
define_method (write once, run everywhere!)
Tags: rails
Published: 2019-10-03 11:48:16

---
title: define_method (write once, run everywhere!)
tags: rails
published: true
---

## Basic
```ruby
# The |obj| is argument, for in this example, it will represents after_save(obj).
[:after_save].each do |method|
  define_method method do |obj|
    @title, @body = obj.title, obj.body
    mail(to: @user.email, subject: 'Hello')
  end
end
```

## Variation
### 1. Status Encapsulation
```ruby
# also, you can do this.
class Mode
  [:low, :middle, :high].each do |level|
    define_method(level) do
      @state = level
    end
  attr_reader :state
  end
end

log = Mode.new
log.low
log.state    #=>low
log.middle
log.state    #=>middle
log.high
log.state    #=>high
```

### 2. only the name is different
{% link n350071/organize-the-authorizations-of-the-banken-pundit-gem-with-definemethod-2gei %}

---

## 🔗 Parent Note
{% link n350071/my-rails-note-47cj %}
Vision Signals

Published: 2019-10-03 11:38:07

Vision Signals is a service that allows individuals access to real-time market trends through the use of best Forex Signals. 

More, Vision Signals (headquartered in Cairo, Egypt) allows our members the ability to automatically execute trades on their own MetaTrader platform. We are a professional signal provider and we provide the Best Forex Signals in the Forex market. For more details at: https://www.visionsignals.com/market-information
Learning to Program 02: The What
Tags: learning, beginners
Published: 2019-10-03 11:26:47



We've looked at a basic background and prologue to this series, just to contextualise the purpose of this series. We've also looked a little at the _why_, and hopefully you have an idea of why you want to learn to program. This is not something to be taken lightly as it will help guide you on your journey. The _why_ is your ultimate goal that you are aiming for.

But let's take a break from these vague generalities and get into the _what_. _What_ exactly will this series cover?

My intention is not for this series to be a linear progression, from your first program, to intermediate topics, to advanced topics. There are many excellent resources (tutorials, video series, bootcamps, books, degrees etc.) that follow this approach. My intention is for this series to be more of a undirected journey, that slowly builds up layer upon layer, brick upon brick, until we have constructed an overview and had a discussion about the most important topics, concepts and approaches in programming.

Even though this will be a somewhat meandering journey there is still a need for some kind of golden thread or focus, and some way to follow that thread. That is the purpose of this post, to be a continually updated repository of all the other posts in the series (with some sneaky _recursion_ just for fun). I will update this post whenever I add a new post to the series so make sure you keep checking back here for updates:

# Contents
* [Learning to Program 00: Prologue](https://dev.to/pieterjoubert/learning-to-program-prologue-12d0)
* [Learning to Program 01: Hello Programmer](https://dev.to/pieterjoubert/learning-to-program-hello-programmer-46if)
* [Learning to Program 02: The What](https://dev.to/pieterjoubert/learning-to-program-02-the-what-4n2g)
* [Learning to Program 03: The How](https://dev.to/pieterjoubert/learn-to-program-03-the-how-3ad8)
* [Learning to Program 04: Anatomy of a Program](https://dev.to/pieterjoubert/learn-to-program-04-anatomy-of-a-program-2jf6)
SQL tuning in Rails
Tags: rails
Published: 2019-10-03 11:25:07

---
title: SQL tuning in Rails
tags: rails
published: true
---

## 🤔 Situation
- Something is slow.
- You dig the log files.
- Then, It's not the N+1 problem but maybe, It's specific query is slow problem.


## 👍 Solution
### 1. 🔧 Check what causes slow
We have **explain** method.

```ruby
> Model.where(attribute: 'hoge').explain

 Model Load (1364.2ms)  SELECT `models`.* FROM `models` WHERE `models`.`attribute` = 'hoge'
=> EXPLAIN for: SELECT `models`.* FROM `models` WHERE `models`.`attibute` = 'hoge'
+----+-------------+--------+------+---------------+------+---------+------+---------+-------------+
| id | select_type | table  | type | possible_keys | key  | key_len | ref  | rows    | Extra       |
+----+-------------+--------+------+---------------+------+---------+------+---------+-------------+
|  1 | SIMPLE      | models | ALL  | NULL          | NULL | NULL    | NULL | 1739502 | Using where |
+----+-------------+--------+------+---------------+------+---------+------+---------+-------------+
```

Because of No index, MySQL has to search by Full scan. This causes it slow.

### 2. Treatment
Give it an index by db migration.

```ruby
class AddIndexToModel < ActiveRecord::Migration[5.0]
  def change
    add_index :models, :attibute, name: :attibute_index_on_models
  end
end
```

### 3. Check the Result
```ruby
> Model.where(attibute: 'hoge').explain
  Model Load (0.4ms)  SELECT `models`.* FROM `models` WHERE `models`.`attibute` = 'hoge'
=> "EXPLAIN for: SELECT `models`.* FROM `models` WHERE `models`.`attibute` = 'hoge'\n" +
"+----+-------------+--------+------------+------+--------------------------+-------------------------+---------+-------+------+----------+-------+\n" +
"| id | select_type | table  | partitions | type | possible_keys            | key                     | key_len | ref   | rows | filtered | Extra |\n" +
"+----+-------------+--------+------------+------+--------------------------+-------------------------+---------+-------+------+----------+-------+\n" +
"|  1 | SIMPLE      | models | NULL       | ref  | attibute_index_on_models | attibute_index_on_models| 768     | const |    1 |    100.0 | NULL  |\n" +
"+----+-------------+--------+------------+------+--------------------------+-------------------------+---------+-------+------+----------+-------+\n" +
```

## 🦄 Compare
After
```ruby
> Model.where(attribue: 'hoge')
  Model Load (2.6ms)  SELECT  `models`.* FROM `models` WHERE `models`.`attribue` = 'hoge' ORDER BY `models`.`id` ASC LIMIT 1
```

Before
```ruby
> Model.where(attribue: 'hoge').first
  Model Load (1382.4ms)  SELECT  `models`.* FROM `models` WHERE `models`.`attribue` = 'hoge' ORDER BY `models`.`id` ASC LIMIT 1
```

It's **531.7** times faster🎉


---

## 🔗 Parent Note
{% link n350071/my-rails-note-47cj %}
How to become a Data Scientist?-An Ultimate Guide to beginner
Published: 2019-10-03 11:08:44

Data Scientist is a trending profile that demands a set of particular skills. If you are planning to establish a career as a Data Scientist, this blog can update the skills needed and how to achieve. Being a competent data scientist should not only know how to write code but also understand its needs and other essential factors. At the same time, an aspiring data scientist must have industry demanding skills and knowledge to perform their jobs the best way. Indeed, there are several online platforms that are designed to upgrade skills set and help them find better career opportunities. 

read more:- http://bit.ly/2o9qsgD
Top 10 Google Chrome Plugins For Business Productivity
Published: 2019-10-03 11:05:11

There is no doubt that Google Chrome is one of the most popular and widely-used web browsers among other web browsers like Safari, Firefox, etc. As so many Plugins are available in the Chrome web store, you can customize your browser in many ways to help you work more efficiently.

We went through the Chrome Web Store and compiled the list of top 10 google chrome plugins on the basis of four criteria :- Productivity, Web development, Time-saving and Blocking distractions.

Top 10 Google Chrome Plugins You Must Try

“In computing, a plug-in is a software component that adds a specific feature to an existing computer program. When a program supports plug-ins, it enables customization. Web browsers have historically allowed executable as plug-ins, though they are now mostly deprecated. (These are a different type of software module than browser extensions.) Two plug-in examples are the Adobe Flash Player for playing videos and a Java virtual machine for running applets.“

So if you’ve been asking yourself what are the best free WordPress plugins, here’s the list you’ve been looking for:-

If you want to see more details about this use this ref link:-https://codersera.com/blog/top-10-google-chrome-plugins-for-business-productivity/
rake task memo
Tags: rails
Published: 2019-10-03 11:04:19

---
title: rake task memo
tags: rails
published: true
---

### list the rake tasks
```sh
bundle exec rake -XT
bundle exec rake -T -A
```

### ActiveRecord::PendingMigrationError

```sh
$bundle exec rake db:migrate:status

up     20180801105656  Add index to xxx
up     20180801253463  Add index xxx to yyy
down   20180811342424  Add timestanps to something

$bundle exec db:migrate RAILS_ENV=development
```

### Routing

```sh
bundle exec rake routes | grep some_resource
```

http://localhost:3000/rails/info/routes

### Making rake task

- make a file under `/lib/tasks/`
  - example: `/lib/tasks/db:migrate:do_it.rake`
- write your task

```ruby
namespace 'eat' do
  desc "description. It's shown when you type rake -XT"
  task :sandwich => :environment do
    sandwich = Sandwich.first
    person = Person.first.eat(sandwich).save
  end
end
```

- run it
  - 'bundle exec rake eat:sandwich'

### Bookmark
{% link vinistock/customizing-rails-rake-tasks-3bg5 %}

---

## 🔗 Parent Note
{% link n350071/my-rails-note-47cj %}
The New React Native - Emily Janzer (React Native EU 2019)
Tags: reactnative
Published: 2019-10-03 11:04:09

---
title: The New React Native - Emily Janzer (React Native EU 2019)
published: true
description: Emily Janzer from the React Native team at Facebook presents The New React Native and React Native EU 2019.
tags: #reactnative
---

{% youtube 52El0EUI6D0 %}

The React Native team is excited to share the roadmap for what we've been working on in the new architecture including new native modules, a new renderer, and a new initialization path which doesn't rely on the bridge. 

We're calling all of these projects collectively The New React Native.

Give this talk a watch and let us know what you think!
What you should know about DB types, DB design, and successful software projects 
Tags: todayilearned, database
Published: 2019-10-03 11:00:04

*My TL;DR style notes from articles I read today.*

### [A one size fits all database doesn’t fit anyone](http://bit.ly/database-types)

When to consider what type of database: 
- **Relational**: when referential integrity with strong consistency is needed.

- **Key-value**: when access patterns require low-latency Gets/Puts for known key values.

- **Document**: when you want developers to use something intuitive.

- **Graph**: when working with highly connected datasets.

- **In-memory**: when you need microsecond response times and expect large spikes in traffic coming at any time.

- **Search**: when you need to index and search semi-structured logs & data. 

*[Full post here](http://bit.ly/database-types), 7 mins read*

----

### [Bad Practices in Database Design: Are You Making These Mistakes](http://bit.ly/db-design-practices)

- Ignoring the purpose of the data
- Poor normalization
- Redundancy
- Bad Referential Integrity
- Not Taking Advantage of DB Engine Features
- Poor Indexing & Naming Conventions 

*[Full post here](http://bit.ly/db-design-practices), 9 mins read*

----

### [Efficient Software Project Management at its Roots](http://bit.ly/software-project-success)

Common patterns in software projects that are more successful than others: 
- Clarity & alignment right from the start on why is the project being taken up, how will the team get it done and what role will each individual play 
- Setting milestones that verify if the team is making progress in the right direction or not 
- Regular updates with 100% transparency about where each individual and the team really is in the development cycle
- Dependency & risk management in a pragmatic way 

*[Full post here](http://bit.ly/software-project-success), 8 mins read*

---

*I share these TL;DR versions of articles on software engineering that I read every weekday through my newsletter - [in.snippets(). Sign up here](https://mailchi.mp/appsmith/insnippets?utm_source=devto&utm_medium=post08&utm_campaign=is) if you liked what you just read.*
Parsing JSON with Swift 5
Tags: swift, ios, mobile, json
Published: 2019-10-03 10:51:47

There are great libraries out there that help you parse JSON data, but it is great to see how Swift 5 implements a fully-native solution to make your data types encodable and decodable for compatibility with JSON.

There are three new protocols in the Swift standard library that define an standardized approach to data encoding and decoding. These new protocols are `Encodable`, `Decodable` and `Codable`

# Encoding and Decoding

The easiest way to encode or decode a type is to use standard properties that are already `Codable`, which can be types like `String`, `Int`, `Double`, `Data`, `Date` and `URL`.

Let’s consider a `User` structure that stores the name, the username and the phone number of a user.

{% gist https://gist.github.com/jaumevn/ebb117e169396f143e960a4d5edc3701 %}

We can make it automatically decodable and encodable by conforming to the `Codable` protocol, which is a type alias of Encodable and Decodable.

{% gist https://gist.github.com/jaumevn/67effa151cf6eb124c1c9b12ed167a43 %}

We can also use custom types that also conform to the `Codable` protocol, and use built-in types such as `Array`, `Dictionary` and `Optional` whenever they contain codable types.

Let’s add to the previous example a list of devices that the user owns. It is represented by an `Array` of `Device`. The `Device` stores the name and the manufacturer of a device.

{% gist https://gist.github.com/jaumevn/ea5d140e38ba87167ab402a9fe2f2b1b %}

We can now deserialize a JSON document into our `User` instance, and serialize that instance back into a JSON document.

{% gist https://gist.github.com/jaumevn/577e51288ee3dcdc2b468c6985863fe8 %}

# Encode or Decode Exclusively

In some cases, you may not need to decode and encode the same type. For example, you may only need to read data and decode them into an instance, or you just need to make API calls and there is no need to decode the response containing the same type.

You can achieve that by conforming `Encodable` and `Decodable` protocols. The example below shows how the `User` structure only encode data:

{% gist https://gist.github.com/jaumevn/3a6191c4734c01bee80bb7ba6bf4fac1 %}

# Custom Key Names

It is often the case that we parse JSON documents with properties that doesn’t match our property names. In that case, we need to define custom key names in order to parse these properties into our instances.

In order to define the custom list of key names we need to define an enumeration named `CodingKeys` which conforms to the `CodingKeys` protocol. The names of the enumeration cases should match the names you’ve given to the corresponding properties in your type.

Let’s update the property `phoneNumber` of our `User` structure, which is defined in the JSON document using snake-case style. The enumeration `CodingKeys` provide the `phoneNumber` alternative key specified by a `String` as the raw-value type for the `CodingKeys` enumeration.

{% gist https://gist.github.com/jaumevn/68cb8fc19aa9a2dd15d9d3acb8db283c %}

---

If you find this post helpful, please recommend it for others to read.
Form object pattern in Rails
Tags: rails
Published: 2019-10-03 10:47:42

---
title: Form object pattern in Rails
tags: rails
published: true
---

## 🤔 Motivation
In the case of ..,
- The form in the view isn't made from only one model
- You don't want to write the form specific logic in the model

You might want to introduce a form object. Because it isolates the responsibility from model/view/controller to form.

## 👍 Solution
### 1. Introduce a form class
```ruby
# forms/dog_form.rb
class DogForm
  include ActiveModel::Model

  attr_accessor  :id, :name

  validates :name, presence: true

  # This method is for getting dog collection with some 制約 
  def search
    rel = Operation
    rel = rel.where(id: id) if id.present?
    rel = rel.where("name LIKE (?)", "%#{name}%") if name.present?
    rel = rel.newer
  end

  def save
    return false if invalid?
    # do something ( save, notify, logging)
    true
  end
end
```

### 2. Use it in any controller
```ruby
# dogs_controller.rb
def index
  @serach_form = DogForm.new(params[:search])
  @dogs = @serach_form.search.page params[:page]
end
```

### 3. The erb will be like this
```erb
# dogs/index.html.erb
<%= form_for(@serach_form, as: 'search', url: manage_dogs_path, html:{method: :get}) do |f| %>
  <div>
    <div><%= f.text_field :id %></div>
    <div><%= f.text_field :name %></div>
  </div>
  <%= f.button t('words.actions.search') %>
<% end %>
```

---

## 🔗 Parent Note
{% link n350071/my-rails-note-47cj %}
The iOS Checkm8 jailbreak is hugely significant, but not for you
Tags: mobile, security, ios, discuss
Published: 2019-10-03 10:41:06

---
title: "The iOS Checkm8 jailbreak is hugely significant, but not for you"
cover_image: "https://thepracticaldev.s3.amazonaws.com/i/3016t87k4ubgycay2mik.png"
published: true
description: "A hacker has revealed an iOS exploit that's unpatchable and could impact millions of iOS devices. But, it's 2019. A jailbreak is only really useful for security researchers. Do you agree?"
tags: "mobile,security,ios,discuss"
---


This [article](https://www.wired.co.uk/article/ios-jailbreak-checkm8-iphone) refers to new iPhone jailbreak, named Checkm8, announced on Twitter by @axi0mx with [this](https://twitter.com/axi0mX/status/1177542362853040129) tweet.


# TLDR

Main points on the article:

> Back in August, Apple released an iOS 12.4 update which unpatched a jailbreak vulnerability which took advantage of the ‘SockPuppet’ flaw, and was swiftly patched by a red-faced Apple. While embarrassing, that mistake pales in comparison to the recent vulnerability of Checkm8.

> “The most significant thing about Checkm8 is that it can’t be fixed with a software patch which is the way most vulnerabilities get fixed as it is in software, which is hard-coded on the device,” says Robin Wood, an independent security consultant.

> To put it simply, Apple is completely powerless to do anything about the exploit, short of recalling millions upon millions of affected devices. It’s one of the most significant exploits in recent years, potentially shaking the Apple ecosystem to its core. But does anyone really care about jailbreaking anymore?

# Let's Discuss it

The article starts with:

> A hacker has revealed an iOS exploit that's unpatchable and could impact millions of iOS devices. But, it's 2019. A jailbreak is only really useful for security researchers. 

Do you agree?