teleren/devto huggingface dataset:
Open source meetups - specifically
Tags: opensource, gnu
Published: 2019-10-08 11:31:45

---
title: Open source meetups - specifically
published: true
description: There are lots of technology meetups, and many are about open source projects and languages. But what about meetups about open source itself? Quid Free Software?
tags: freesoftware, opensource, gnu
---

A few months ago in June I attended the [UK Open Source Awards in Edinburgh](https://opensourceawards.org/), and got to chatting with a number of people there, including Ashley from SalesAgility SuiteCRM who was delivering a talk on why we need more Open Source in schools, and what groups are working to make that happen. I asked her if there were any meetup groups that were specifically geared towards discussing Open Source matters, and neither of us could come up with any for Glasgow, Stirling or Edinburgh, aside from perhaps each one's local Linux User Groups, and even then, these don't solely or necessarily focus on the topic of Open Source themselves.

So I went about setting up a meetup just about that - talk about Open Source and Free Software, the principle itself, and the topics around them. It's all well and good that Linux is Open Source, that AOSP is Open Source, that Mozilla is Open Source, etc, etc. But what about talking about its licenses, its adoption, its relevance... its difficulties, its funding models? What about all these nearly "meta" topics around openness and user freedom preservation? We called it the "Scotland Open Source Users Meetup" with the aim in part to get members across the Scottish tech scenes including Edinburgh and Glasgow, as well as Stirling, Dundee and Aberdeen, so as to provide a central location for all Open Source enthusiasts to discover eachothers' events.

In August we hosted our first meetup - amidst the existing chaos that are the Edinburgh summer festivals - around how to fund Open Source projects (the notes for which are [on the website](https://scot-osum.gitlab.io)). It had a modest turnout, around 10 people, and the large CodeBase meeting room did feel a little overkill, but it was productive and we got through quite a number of questions for the Guided Conversation format.

It's taken some time to get around to it - partially because of a suddenly busy life schedule, and partly because I have been doing too many meetups recently (I also run two other [technical][edlug] [meetups][workshops], and am proactively involved in a couple of language based ones) - but I've managed to put together the next Scotland Open Source Users Meetup : a discussion of Free/Open Source licenses and about the adoption of software using libraries and software with such licenses.

<https://www.meetup.com/Scotland-Open-Source-Users-Meetup/events/265478344>

After this I'll have to aim for January for a new session. The search for topics and speakers continues...

[edlug]: https://edlug.gitlab.io
[workshops]: https://www.meetup.com/Edinburgh-Free-Software-workshops-and-exploration/
shared_examples in RSpec
Tags: rails
Published: 2019-10-08 11:16:07

---
title: shared_examples in RSpec
tags: rails
published: true
---

## Pattern1: No arguments for `it_should_behave_like`

```ruby
shared_examples_for "happy" do
  it{expect(dog.feel_good?).to be true}
end

context 'good status' do
  it_should_behave_like("happy"){ let(:dog){ Factorybot.create :dog, status: :eating }}
  it_should_behave_like("happy"){ let(:dog){ Factorybot.create :dog, status: :excited }}
  it_should_behave_like("happy"){ let(:dog){ Factorybot.create :dog, status: :running }}
end
```

## Pattern2: with an argument for `it_should_behave_like`

```ruby
shared_examples_for "0-23 hour" do |expectation|
  it{expect(hour.save).to be expectation}
end

describe 'hours' do
  it_should_behave_like("0-23 hour", false){ let(:hour){ Factorybot.create :hour, hour: -1 }}
  it_should_behave_like("0-23 hour", true) { let(:hour){ Factorybot.create :hour, hour: 0 }}
  it_should_behave_like("0-23 hour", true) { let(:hour){ Factorybot.create :hour, hour: 1 }}
  it_should_behave_like("0-23 hour", true) { let(:hour){ Factorybot.create :hour, hour: 22 }}
  it_should_behave_like("0-23 hour", true) { let(:hour){ Factorybot.create :hour, hour: 23 }}
  it_should_behave_like("0-23 hour", false){ let(:hour){ Factorybot.create :hour, hour: 24 }}
  it_should_behave_like("0-23 hour", false){ let(:hour){ Factorybot.create :hour, hour: 25 }}
end
```

---

## 🔗 Parent Note
{% link n350071/my-rspec-note-17ec %}
Making an array of test data by Factorybot
Tags: rails
Published: 2019-10-08 11:06:31

---
title: Making an array of test data by Factorybot
tags: rails
published: true
---

## 🤔 ok but not great
Because you can't understand it without reading through the procedure.

```ruby
let(:author1) { create(:author) }
let(:author2) { create(:author) }
let(:book1) { create(:book, author: author1) }
let(:book2) { create(:book, author: author2) }
let(:books) { [book1, book2] }
```
## 👍 Great
The intention is clear. The test needs the books array, and each book has different author.

```ruby
let(:authors){ create_list(:author, 2) }
let(:books){
    [
      create(:book, author: authors[0]),
      create(:book, author: authors[1])
    ]
  }
```

### do-end is ok instead of the `{}`

```ruby
let(:companies) do  [
    create(:company, name: 'Hoge Company'),
    create(:company, name: 'Fuga Company'),
    create(:company, name: 'Piyo Company')
] end
```

---

## 🔗 Parent Note
{% link n350071/my-rspec-note-17ec %}
What surprises new devs; spec-first API development; & scaling data pipelines
Tags: todayilearned, api, programming
Published: 2019-10-08 11:00:12

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


### [Top 5 Surprises When Starting Out as a Software Developer](http://bit.ly/sd-beginner)

- Programming isn’t a solitary activity. It needs a lot of interactions with people 
- Writing well (clear & unambiguous) matters, be it your code, documentation, bug descriptions or be it your emails 
- Software is never done. Anything new you create has to fit into something that’s existing already. A large of creating new software functionalities is understanding the existing code. 
- Real-world favors simplicity. All the clever algorithms you learned may never come to use. 
- Scale creates complexity. Complexity arises from the aggregation of many simple parts, not from complex parts.

*[Full post here](http://bit.ly/sd-beginner), 4 mins read*

---

### [Using spec-first API Development for Speed and Sanity](http://bit.ly/spec-first-api)

Reasons to consider spec-first API development:
- Tight feedback loops 
- Effective feedback about API design 
- Minimal wasted effort 
- Contract testing for safety 

*[Full post here](http://bit.ly/spec-first-api), 9 mins read*

---

### [Scaling a Mature Data Pipeline — Managing Overhead](http://bit.ly/scale-data-pipeline)

- Over time, you end up encoding application structure in the data pipeline. Application logic gets coupled with orchestration logic. 
- Orchestration complexity causes overhead. This complexity scales with the depth of the data pipeline.
- When you decouple orchestration logic from application logic, you get tools to fight the overhead, without compromising the quality of the application.
- When trying to reduce the run time of a data pipeline, analyze the whole pipeline’s execution time, not just the obvious factors like map-reduce computation time.
- Focus on fault tolerance considerations. 

*[Full post here](http://bit.ly/scale-data-pipeline), 11 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.*
my RSpec note
Tags: rails
Published: 2019-10-08 10:58:08

---
title: my RSpec note
tags: rails
series: note
published: true
cover_image:
canonical_url:
---

## 🏭 Preparing data(let, before)
### Factorybot
{% link n350071/making-an-array-of-test-data-by-factorybot-4k8n %}
{% link n350071/rspec-factorybot-trait-making-a-complex-association-data-3f47 %}
{% link n350071/rspec-factorybot-transient-trait-with-argument-2djd %}
{% link n350071/search-how-to-use-the-factorybot-form-the-project-files-12ne %}

## 🧪 Testing
### expect
block needed matcher

```ruby
it{ expect{something.save}.to change{ SomethingRelation.count }.by(3) }
it{ expect{something.save!}.to raise_error(StandardError) }
```


### Model Spec

### Controller/Request Spec
{% link n350071/rspec-controller-request-1oc3 %}
{% link n350071/rspec-layout-false-how-to-test-it-3j68 %} 
{% link n350071/rspec-what-does-assigns-mean-in-rspec-3bma %}
{% link n350071/rspec-for-applicationcontroller-5c6o %}

### Feature Spec
{% link n350071/my-capybara-note-2gp3 %}

## 🧪 Advanced Testing
### shared example/context
{% link n350071/sharedexamples-in-rspec-nbm %}
{% link n350071/capybara-like-sharedexamples-18be %}
{% link n350071/rspec-sharedcontext-4ch2 %}

### Stub / Dowble
```ruby
before{ allow_any_instance_of(ClassName).to receive(:a_method).and_return('great!') }
before{ allow_any_instance_of(ClassName).to receive(:a_method).and_raise(StandardError.new("error"))  }
before{ ClassName.any_instance.stub(:a_method).and_return('cool!') }
before{ ClassName.any_instance.stub(:a_method).and_raise('error!') }
```

## 😎 Run RSpec
```sh
bundle exec rspec
bundel exec rspec spec/models/xxxx_spec.rb           ## specify specific file
bundel exec rspec spec/models/xxxx_spec.rb -e status ## specify a test in specific file
```

### Troubleshooting
Sometimes, the test DB is not migrated(updated). If it occurs after you run `rake db:rollback`, then try this.

```sh
rake db:rollback RAILS_ENV=test
rake db:migrate RAILS_ENV=test
```
Future-Proof your Mutations
Tags: vuex, vue
Published: 2019-10-08 10:09:02

Recently I began expunging mutations from the Vue application I work on as the way we were using them served no purpose and simply cluttered the application with pointless boilerplate, and tests for that boilerplate.

After doing this and planning on writing an opinionated post about how mutations are pointless and hinted as obsolete by Vue's creator Evan You, I did a bit of research. I quickly discovered that they can be useful as an abstraction layer but are most likely not leveraged as such in most applications and probably shouldn't be anyway.

## What are Mutations?

Mutations are designed mainly as a way of tracking atomic changes to the state for debugging. They are necessary due to language limitations in ES5. However, this is no longer an issue with the eventual adoption of ES6 Proxies by most modern browsers.

## How can they be useful?

Mutations can be leveraged as a useful abstraction of your state layer. For example, 

```javascript
commit('startLoadingBlogs');
const blogs = await getBlogs();
commit('completeLoadingBlogs', blogs);
```

which can be useful for debugging as this gives a more immediate overview of what is happening in your application. You're most likely to find the following in your application though,

```javascript
commit('setLoading', true);
const blogs = await getBlogs();
commit('setLoading', false);
commit('setBlogs', blogs);
```

which reduces this potential abstraction layer to useless boilerplate.

Mutations can also be used as a logical point to validate data before committing it to state. Preventing state corruption is very important in avoiding hard to track bugs and can easily happen when directly committing API responses or user input.

## Is that valuable enough to keep writing Mutations?

I've personally never had an issue debugging changes to application state using breakpoints and following the logical flow of the application. Also, the Vue debugger is useful in inspecting the state tree with each change but a quick overview of each change hasn't been a significant factor in resolving any issues I've encountered.

Bulletproofing your application with validation is the only good reason I can find for useful mutations. However, (arguably) this should be happening before your action ever gets to your commit. That is if your API returns an unexpected response your service layer should handle that as an error instead.

With this in mind, I'll continue designing for a future without commits by removing individual modules mutations and replacing it with a generic state mutator. And save me the trouble of, 
- No longer needing to write benign tests that simply assert that state has been changed.
- No longer needing to have both actions and commits open to understanding the data flow of my application.
DBus is fabulous
Tags: linux
Published: 2019-10-08 10:01:06

---
title: DBus is fabulous
published: true
date: 2019-10-08 09:38:02 UTC
tags: Linux,Python
canonical_url: https://daniele.tech/2019/10/dbus-is-fabulous/
---

Why DBus is cool, how much is easy to use for your scripts and improve your Linux experience. With a real story.

The post [DBus is fabulous](https://daniele.tech/2019/10/dbus-is-fabulous/) appeared first on [Daniele Mte90 Scasciafratte](https://daniele.tech/eng).
Generating Thumbnail From Uploaded Video in Laravel
Tags: php
Published: 2019-10-08 09:33:54

Good day guys, Please can any one help me with a working and reliable code for generating a thumbnail from video.I am using laravel  spatie library and was able to generate thumbnail from image in a fly but having difficulty to get thumbnail from video. I am developing api for a business android app. Using laravel as back-end api development. My interest is getting thumbnail from uploaded video. 

Thanks in advance
Prevent the need to zoom into inputs with CSS
Tags: css, microtips, toolbox
Published: 2019-10-08 09:27:28

Adrian Roselli describes [a quick, effective way](https://adrianroselli.com/2019/09/under-engineered-text-boxen.html) to make HTML inputs inherit the styles of the page they're on, rather than deriving their appearance from operating system conventions. The following (simplified) declaration makes the font match the input's surroundings; in particular, it makes its `font-size` equivalent to `1em`:

```css
textarea,
input {
  font: inherit;
}
```

If you use mobile Safari, you've probably noticed that it sometimes zooms into inputs as you focus them, to make them easier to read and type into. It happens whenever an input has its text smaller than `16px`, and it's a sensible thing to do. However, in some cases, it's purely accidental: you get this _barely zooming into an input_ because it happens to have a computed font size of `15px`, or `14px`, as inherited from its parent.

To proactively fix this, and spare the user a useless interaction, I got into the habit of throwing in an extra declaration:

```css
button,
select,
textarea,
input {
  font-size: max(16px, 1em);
} 
```

In browsers supporting [the `max()` function](https://developer.mozilla.org/en-US/docs/Web/CSS/max) — including, thankfully, Safari — it prevents the inherited font size of inputs from going below `16px`, and avoids the zoom behavior.

Nice and easy!

---

Some notes:

* This technique only applies to 100% zoom; starting from version 13, mobile Safari has zoom controls, and zooming out of the page understandably brings back the `zoom into input` thing.
* One thing that's still prevalent is using `maximum-scale=1.0`, or `user-scalable=no` in the `viewport` meta tag. Despite Safari ignoring them since iOS 10 to allow users to pinch-zoom regardless, they're [still bad for accesibility](https://a11yproject.com/posts/never-use-maximum-scale/).
V Programming Language
Tags: v, news, discuss
Published: 2019-10-08 09:22:41

There's a new language called V which could be found [here](https://vlang.io) and was open sourced in July and it has got almost 12k stars on Github. It promises a lot of new things and it is said to have a stable release by the end of the year.

It derives its syntax from Go and has memory management like Rust. It could be learned in minutes because of its easy syntax. There are some projects that already use V. Some people say that it won't be able to keep up with promises and it's a meme. So what you guys think about it and will you guys would use V when it comes out? 

In my opinion V does have a lot of potential and has rapid development which can keep up with its promises and rock when it comes out.
Turn Your Website into a PWA
Tags: pwa, javascript, webdev
Published: 2019-10-08 08:56:59

According to [this article](https://www.cnbc.com/2019/01/24/smartphones-72percent-of-people-will-use-only-mobile-for-internet-by-2025.html) by CNBC, Nearly three-quarters of the world will use just their smartphones to access the internet by 2025.

Considering these stats, if you are thinking of building a new website or redesign one, you should consider developing your website as PWA with no doubts.

_Starting from a PWA could be the perfect start for your projects, you don’t need too much effort and you can build one application that works for all platforms!_

**What is a PWA?**
A Progressive Web App (PWA) is a hybrid of a regular web page and a mobile application.
A PWA combines features offered by most modern browsers with the benefits of the mobile experience. They are built using standard web technologies, including HTML, CSS, and JavaScript.

The functionalities include working offline, push notifications, and device hardware access and enabling creating user experiences similar to native applications.
You can add them to the home of your phone exactly like a mobile app.

**Why should you build a PWA?**
A few weeks ago, I was looking for more information about PWA, and I found a very cool website pwastats.com, it shows the stats of all the most famous companies which are using PWA.
It was impressive to find out how the companies improved the performance of their website, mostly more than 100%.

A Progressive Web App can cut load times, allow users to navigate offline, increase the time spent on the website, increase revenue, can be much smaller than a mobile app, and much more.

**Who is already using PWA?**
It’s interesting to see the companies which already have a PWA, some of the world’s biggest company such as **Twitter, Instagram, Uber, Pinterest, Forbes, Alibaba** and much more.

To know how to turn your website in a PWA in 5 minutes read the article on medium https://medium.com/notonlycss/turn-your-website-into-a-pwa-6aaecb95f8b9
Scarily similar names in javaScript
Tags: javascript
Published: 2019-10-08 08:22:39

---
title: Scarily similar names in javaScript
published: true
description: similar names lead us to bug sometime.
tags: #js
---

#1 substr and substring

`String.prototype.substr(…)` the method extracts a specified number of characters in a string, `from` a start index (`avoided when possible`).

```js
   let str = 'commonSourceOfTruth';
   // str.length : 19 
```

`substr` [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) takes parameters as `(from, ?length).`

```js
str.substr(1, 10);  // 'ommonSourc'
```

`substring` [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) takes parameters as `(start, ?end(exclusive)).`


```js
str.substring(1, 10);  // 'ommonSour'
```

:angry: if we start from 0 both behave the same. 

```js
str.substr(0, 10);  // 'commonSour'
str.substring(0, 10);  // 'commonSour'
```
Example : Remove first and last character from a given string :question:

```js
str.substr(1, str.length-2) // ommonSourceOfTrut
str.substring(1, str.length-1) // ommonSourceOfTrut as substring takes indices
```

:collision: Your turn now. Comment your output below.

```js
str.substring(0, 2) // ?
str.substring(2, 0) // ?
```

#2 `array.splice()` and `arr.slice()`

I found an amazing article on these similar methods, and the article covered all the required parts that one should know.So there is no need to write it again :joy:

{% link https://dev.to/laurieontech/splice-slice-shoot-i-meant-shift-424p %}

My favorite from the above article is:
Example: Remove/add a string and replace/add with the new string :question:

```js
let content = ['post', 'tweet', 'video', 'talk']
content.splice(1, 0, 'dev', 'ten mile')
// content is ['post', 'dev', 'ten mile', 'tweet', 'video', 'talk']

let content = ['post', 'tweet', 'video', 'talk']
content.splice(1, 1, 'dev', 'ten mile')
// content is ["post", "dev", "ten mile", "video", "talk"]
```

and

```js

let social = ['twitter', 'instagram', 'facebook', 'myspace']
let sliced = social.slice(1,3);
// content is ["instagram", "facebook"]

let social = ['twitter', 'instagram', 'facebook', 'myspace']
let spliced = social.splice(1,3);
// content is  ["instagram", "facebook", "myspace"]

```


#3 `.textContent` and `.innerHTML`

```js
// textContent
<div id="targetNode">This is <span>some </span> text</div>

let targetNodeEl = document.querySelector('#targetNode');
let targetNodeElText = targetNodeEl.textContent;

console.log(targetNodeElText) // This is some  text
```

- textContent is not parsed as HTML.
- as it's not parsed [XSS](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#Differences_from_innerText) can be prevented

```js
// innerHTML
let targetNodeElHtml = targetNodeEl.innerHTML;
console.log(targetNodeElHtml) // This is <span>some </span> text
```

- innerHTML is parsed.
- it won't return `hidden` elements.
Sued for Being Inaccessible
Tags: a11y, news, beginners, webdev
Published: 2019-10-08 07:46:00

Haven't thought about accessibility lately? You should. Yesterday, [the U.S. Supreme Court turned down an appeal](https://www.latimes.com/politics/story/2019-10-07/blind-person-dominos-ada-supreme-court-disabled) of a lower court ruling by Dominos Pizza, which ruled their website inaccessible.

The U.S. 9th Circuit court rules that

> _"...the Americans With Disabilities Act protects access not just to restaurants and stores but also to the websites and apps of those businesses."_

If you're building a site for an organisation that has to abide by the Americans With Disabilities Act, be careful! Do your research and make the site accessible -- not just to be inclusive and because it's the morally right thing to do -- but because you might get sued.