teleren/devto huggingface dataset:
Widget testing when your app needs access to directories.
Tags: widgettesting, flutter, unittesting
Published: 2020-07-28 05:27:20

---
title: Widget testing when your app needs access to directories.
published: true
date: 2020-07-27 07:16:01 UTC
tags: widgettesting,flutter,unittesting
canonical_url: https://medium.com/wyzetalk-tech/widget-testing-when-your-app-needs-access-to-directories-2c9c7aa73b8a
---

![](https://cdn-images-1.medium.com/max/1024/1*bnm8sRPmozmm0_tgnN97WQ.png)

Many times in an application you would have a need to store files, temporarily or even permanently. For this, you are probably going to be using [path\_provider](https://pub.dev/packages/path_provider), however, those methods are not going to simply work when running a widget test.

Thankfully it is quite simply to be able to mock that and provide your own path for use during testing.

There is quite a simple way to do this and it is done with MethodChannel

```dart
const TEST\_MOCK\_STORAGE = './test/fixtures/core';

const channel = MethodChannel(
  'plugins.flutter.io/path\_provider',
);
channel.setMockMethodCallHandler((MethodCall methodCall) async {
  return TEST\_MOCK\_STORAGE;
});
```

You simply need to provide the channel you wish to mock, in this case, it is pluggins.flutter.io/path\_provider and use the setMockMethodCallHandler where you can either provide specific calls and values to return or in this case provide a catch-all response, in this case, what will happen is any request to path provider will return the provided path.

So whether you are getApplicationDocumentssDirectory or getExternalStorageDirectory the result is going to be ./test/fixtures/core.

An important thing to note is that this MethodChannel call needs to be run in each test that will be accessing the path, if it’s only a single test then it is fine to provide that directly inside the main().

In our case, however, there is quite a bit of the application that relies on accessing the Documents Directory. For that reason, we have added that method into a setUpTest function that we pass into the setUp((){ }) part of the widget test.

```dart
void main() {
  setUp(() async {
    await setupTest();
  });

  testWidgets(
    'Should render [SampleWidget]',
    (WidgetTester tester) async {
      await tester.pumpWidget(SampleWidget());

      await tester.pumpAndSettle();
    },
  );
}
```

If you are needing access to files, ensure they exist in the path you have provided as the mock result path, after that you should have no problems testing any Widgetsthat need access to those files.

* * *
Let's Learn - Week 1 - REST vs SOAP
Tags: restful, soap, webservices, microservices
Published: 2020-07-27 07:06:15

The final post for this week 1 , we are going to wrap up with the difference between REST vs SOAP.

Although this is not an Apple-Apple comparison because SOAP is format of XML whereas REST is actually an architectural style , I would like to highlight just the differences that gives a recap of what we have seen so far

![rest-vs-soap](https://github.com/csdinakar/SketchNotes/blob/master/rest%20vs%20soap.png?raw=true)

Now we have quite some idea about the basic terminologies and key concepts , next week will meet you all with 

![spring-boot](https://github.com/csdinakar/SketchNotes/blob/master/spring%20boot%20icon.png?raw=true)
Let's Learn - Week 1 - REST
Tags: rest, webservices, microservices, learning
Published: 2020-07-27 07:06:06

## Table Of Contents
        * [Introduction](#Introduction)
        * [Resource](#Resource)
        * [Data Exchange](#data-exchange)
        * [Service Definition](#service-definition)

### Introduction <a name="Introduction"></a>


> REST stands for REpresentational State Transfer coined by Roy Thomas Fielding who is credited for developing HTTP.

REST makes best use of HTTP (Hyper Text Transfer Protocol).
Thus, RESTful webservices try to define services using the different concepts that are already present in HTTP.

HTTP methods are used to indicate what action we are using.

### Example:

 * GET -> to get details of a resource
 * POST -> during creation of a resource
 * PUT -> update resource
 * DELETE -> delete resource

### What is a resource <a name="Resource"></a>

The most important abstraction in REST is called resource.
* A resource is anything that you would want to expose to the outside world through your application
* A resource can have different representations
    - XML
    - HTML
    - JSON
* A resource has an URI (Uniform Resource Identifier)
    ```
Create employee -> POST /Employee
Delete an employee -> DELETE/Employee/1
Get all employees -> GET /Employees
Get Particular employee -> GET /Employee/2
```
* The important thing about REST is the fact that 
   - We have to think in terms of resources
   - Make proper use of HTTP methods 

### How does data exchange between applications take place <a name="data-exchange"></a>

* In REST we don’t have any restriction on Data exchange format.However,JSON is very popular and widely used.

Also note that , transport protocol is always HTTP.
REST is built on top of HTTP.
### What is the service definition <a name="service-definition"/>
There is no standard service definition attached with REST.
However the service details can be provided by WADL (Web application definition language) / Swagger

To Summarise the above

![RestSketch](https://github.com/csdinakar/SketchNotes/blob/master/Rest.png?raw=true)

Next,we will wrap up the basics by seeing the difference between REST and SOAP
Let's Learn - Week 1 - SOAP
Tags: restful, soap, learning, springboot
Published: 2020-07-27 07:05:44

# Introduction to SOAP Web Services

SOAP is an acronym for Simple Object Access Protocol.
SOAP defines specific way of building web services.
We use XML as request and response exchange format. 

Any request that contains XML as request and response is not SOAP.
SOAP defines specific XML request and response structure.

![SOAP](https://github.com/csdinakar/SketchNotes/blob/master/soap.png?raw=true)


We need to create SOAP envelope that contains header and body.
The header contains meta information like authentication , authorization etc.
SOAP body is where we put real content of request and response.

The service definition is managed by WSDL – Web Service Description Language

### Examples of SOAP Request , Response & WSDL

#### SOAP Request
```
<?xml version="1.0"?>

<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Header/>
<soap:Body xmlns:m="http://www.example.org/stock">
  <m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>
</soap:Body>
</soap:Envelope>
```

#### SOAP Response
```
<?xml version="1.0"?>

<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">

<soap:Body xmlns:m="http://www.example.org/stock">
  <m:GetStockPriceResponse>
    <m:Price>34.5</m:Price>
  </m:GetStockPriceResponse>
</soap:Body>

</soap:Envelope>

```

#### WSDL
```
<message name="getTermRequest">
  <part name="term" type="xs:string"/>
</message>

<message name="getTermResponse">
  <part name="value" type="xs:string"/>
</message>

<portType name="glossaryTerms">
  <operation name="getTerm">
    <input message="getTermRequest"/>
    <output message="getTermResponse"/>
  </operation>
</portType>

```

Now that we have an idea about SOAP based web services , let's move to Restful Web Services
Liman MYS 1.2 Sürüm Duyurusu
Tags: liman, management, linux, debian
Published: 2020-07-27 06:56:04

HAVELSAN tarafından geliştirilmekte olan Liman MYS 1.2 sürümü 27 Temmuz 2020 tarihinde Mert ÇELEN tarafından duyuruldu.

# Değişim Günlüğü

Liman'ın mevcut sistem yetkileri alınarak Go dilinde yazılmış bir mikro servise aktarıldı.
Eklentilerin paralel işlenebilmesi ve sistemin yük dağılımı yapabilmesi için gerekli altyapılar hazırlandı.
Session altyapısı Redis'e aktarıldı.

## Hata Düzeltmeleri

Eklentilerin arkaplanda çalışamama sorunu çözüldü.
Kullanıcı girişi sırasında yaşanabilen 419 sorunları çözüldü.
Arayüzde javascript tarafından oluşabilen sorunlar çözüldü.
Reuse Serverless Deployment S3 buckets
Tags: serverless, aws, s3
Published: 2020-07-27 06:50:58

---
title: Reuse Serverless Deployment S3 buckets
published: true
description: Quick tip on reusing the serverless deployment s3 bucket
tags: serverless, aws, s3
//cover_image: https://direct_url_to_image.jpg
---

[Serverless framework](https://www.serverless.com/) does a lot of magic (not in a bad way) to make your life easy while deploying serverless projects. Serverless or `sls` in short, packages your application and uses s3 bucket to deploy your application. It doesn't ask you what the name should be, but infers it based on your service name and some random strings to come up with the S3 bucket name. Just give name which exists in your s3.

```yml
service: cool-service

provider:
  name: aws
  runtime: nodejs12.x
  region: ap-southeast-2
...
```
If your `serverless.yml` looks like above, you might get a bucket name like `cool-service-prod-serverlessdeploymentbucket-<random string>`. No problem with that. All good! If you have 1000 serverless projects in one account, you will need 1000 s3 buckets for sls deployment and you cannot have more than 1000 s3 buckets in an AWS account. That's when you would think of reusing the s3 buckets. And here is how to do it by using a key in the `serverless.yml` file.

```yml
service: cool-service

provider:
  name: aws
  runtime: nodejs12.x

  deploymentBucket:
    name: all-service-deployments # Deployment bucket name. Default is generated by the framework
    maxPreviousDeploymentArtifacts: 10 # On every deployment the framework prunes the bucket to remove artifacts older than this limit. The default is 5
    blockPublicAccess: true # Prevents public access via ACLs or bucket policies. Default is false
    serverSideEncryption: AES256 # server-side encryption method
    sseKMSKeyId: arn:aws:kms:us-east-1:xxxxxxxxxxxx:key/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa # when using server-side encryption
    sseCustomerAlgorithim: AES256 # when using server-side encryption and custom keys
    sseCustomerKey: string # when using server-side encryption and custom keys
    sseCustomerKeyMD5: md5sum # when using server-side encryption and custom keys
    tags: # Tags that will be added to each of the deployment resources
      key1: value1
      key2: value2

```

It will store all your deployment packages in subfolders in the s3 bucket.
Vanilla JavaScript Chicken or Egg?
Tags: javascript
Published: 2020-07-27 06:36:51

I saw this a couple of days ago and thought it was finally a solution to this ancient problem!

Who was there first the chicken or the egg?

## JavaScript Chicken or Egg Sort

```js
var array = ['🥚', '🐔'];
console.log(array.sort());
// (2) ["🐔", "🥚"]
```

There you go the answer is `Chicken`!

But let's dive a bit deeper and see how this then worked out for the egg?

```js
var array2 = ['🐔', '🐣', '🐤', '🥚'];
console.log(array2.sort());
// (4) ["🐔", "🐣", "🐤", "🥚"]
```

Hmm weird? Yes this definitely complicates things right?

What are your opinions on this Chicken vs. Egg complication?

View the code on Codepen.

<p class="codepen" data-height="265" data-theme-id="dark" data-default-tab="js,result" data-user="rebelchris" data-slug-hash="vYLMVym" style="height: 265px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="Vanilla JavaScript Chicken or Egg?">
  <span>See the Pen <a href="https://codepen.io/rebelchris/pen/vYLMVym">
  Vanilla JavaScript Chicken or Egg?</a> by Chris Bongers (<a href="https://codepen.io/rebelchris">@rebelchris</a>)
  on <a href="https://codepen.io">CodePen</a>.</span>
</p>
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/47gm3qhqehfxqikkhe89.png)

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
CaseStudy – Contactless Food Delivery: Mobile Companion App for Food Dispenser
Tags: casestudy, aws, deliveryapp, fooddelivery
Published: 2020-07-27 06:25:19

With the whole world swinging in full throttle, balancing between work and life, we wanted to give something that money can’t buy, which is “Time”. Whether we realize it or not, we are constantly faced with the decision to either spend hours cooking our own meals for the week, or to surrender and pick up a random sandwich from the cafeteria. To ease the process, we have designed a system that will allow our customers to pick up their food, fresh & flavorful, without human interaction.

To achieve that, we have developed a user friendly mobile application, which allows a user to place a food order on a nearby Vending machine / Kiosk and then pick it up. Also, a profile for the vendor can be created to manage their products and kiosk details

Tech Stack:

We have used the following technology stack to achieve the same.
Hosting – AWS: Amazon Web Services (AWS) plays a very vital role in offering reliable, scalable, and inexpensive cloud computing services.

JAVA: With Java as backend, we were able to effectively communicate between the application, Kiosk and the Database, so that we will can keep an update on the product availability & order status.

React Native : Using React Native as mobile platform that offers Single framework and works in multiple platforms, we are able to achieve the proposed solution more strategically with less effort & time.

BrainTree for PayPal: PayPal / Braintree provides us global use of payments with multiple payment options with credit card, wallet that makes our payment easy without having any security concerns for our customers.

Key Features

Our team at Optisol has developed a simple, yet extensive application with features that assist in dispensing the products from Kiosk.

1.	Search and Locate the nearby Kiosk and the also ones in specific locations.
2.	View the products available at the specific kiosks.
3.	Buy products based on their availability.
4.	Make payment is made seamless through PayPal gateway.
5.	Generate barcode on each successful order.
6.	Track the order until it gets delivered or expired.
7.	Track the order expiry time taken for the users to pick up products.
8.	Scan the barcode in the Kiosk machine and dispense the products.
9.	Refund the amount on partial dispense or if the order time expires.
10.	Allow user to mark their favourite products, so that user can keep their favourite food on their tips to re-order.

Conclusion:

The implementation of food delivery using Kiosks has the potential of eliminating human interaction of picking up and delivery from restaurants.

With administrative portal in place, the vendors will be able to understand the customer of their locality by the data points they get from the mobile application. With that the vendors will be able to form a strategic plan for different regions to attract their customers, making it as Customer Centric.
The dangers of choosing the wrong identifier for your users when federating logins
Tags: security, identity
Published: 2020-07-27 06:09:43

**Preface:** I was going to title this something along the lines of "Twitter's username clean up is dangerous", but I felt that made it sound too much like what twitter was doing was the dangerous part, and not that other applications failing to follow good practice puts their user data at risk, regardless of what twitter is doing. I also started writing this and then promptly forgot about it for 8 months.

If you haven't seen what twitter did, they [removed inactive accounts to free up the usernames](https://www.theverge.com/2019/11/26/20984328/twitter-removing-inactive-accounts-usernames-available-date). On top of the the issues that others raised with this, freeing up twitter handles made it possible for someone to potentially get access to data that is not theirs.

There's a lot of maybes there. I don't think this has happened, but it is theoretically possible. It is not because of a mistake that twitter has made. It is possible because people changing usernames could uncover issues where a third party application is not linking accounts from twitter as an identity provider correctly.

##Example
If you use twitter as an Identity Provider for your application, you have to use a piece of information twitter gives you to link between a twitter account and your application. If you use their twitter username (or email) as this key between your user will experience issues if they change it. If someone else starts using a previously used twitter handle they also gain access to the old users information in your application.

Instead of using a username or email address between you application and an identity provider, which could change, you should look at a field that can't change. If you are using OIDC, you should use the **subject** claim (and other claims that don't change).

If you think that users information doesn't change, between starting this blog post 8 months ago and finishing it, I lost access to data in one application because I changed the email address I use for Facebook.
Do CSS Grid replace Flexbox?
Tags: grid, flexbox
Published: 2020-07-27 06:01:51

**Grid** is better than **flexbox** for a number of valid points. _There are things grid do better than flexbox and vice versa_.On March 2017 with less browser support than flexbox grid was released unprefixed and ready-to-go, in Chrome, Opera, Firefox, and Safari.
Grid is better for whole page layouts than flexbox because using flexbox for layout can cause content shift during loading due to js modifying the DOM which can be used for [tools not rules.](https://jakearchibald.com/2014/dont-use-flexbox-for-page-layout/)

  Grid can add columns or rows on fly with `grid-template-rows` or `grid-template-columns` and use `grid-gap` property to make home made style page. The flexbox on other hand use its content to layout the page using `flex-wrap` and `flex-basis` which can essentially implement flex-grow or `flex-shrink` the boxes.

 Furthermore, Grid uses the auto layout, minmax(), repeat(), and auto-fill which can provide responsive media query alternative.
_Flexbox is essentially for laying out items in a single dimension – in a row OR a column. Grid is for layout of items in two dimensions – rows AND columns._
{% codepen https://codepen.io/sandrina-p/pen/mZXWYN %}
40+ Free Resources for Web Development
Tags: webdev, javascript, html, css
Published: 2020-07-27 05:55:53

As a programmer we always look for high quality free resources for our projects, so here is my list of **50+** free resource.

Here we go:

# Illustrations & Ui Stuff

#### [Humaaans](https://www.humaaans.com/)
#### [Undraw](https://undraw.co/)
#### [Illlustrations](https://illlustrations.co/)
#### [UIspace](https://uispace.net/)
#### [Error 404](https://error404.fun/)
#### [Avataaars](https://avataaars.com/)
#### [Open Peeps](https://www.openpeeps.com/)
#### [Open Doodles](https://www.opendoodles.com/)
#### [Black illustrations](https://www.blackillustrations.com/)

# Icons

#### [Bootstrap icons](https://icons.getbootstrap.com/)
#### [Ionicons](https://ionicons.com/)
#### [Material Icons](https://material.io/resources/icons)
#### [Icons8](https://icons8.com/)
#### [Flaticons](https://www.flaticon.com/)
#### [Feather icons](https://feathericons.com/)
#### [Hero icons](https://heroicons.dev/)
#### [Browser Logos](https://github.com/alrra/browser-logos/)
#### [Icon Bros](https://www.iconbros.com/)
#### [Cryptocurrency Icons](http://cryptoicons.co/)
#### [Simple Icons](https://simpleicons.org/)

# Templates

#### [Tailwind Toolbox](https://www.tailwindtoolbox.com/)
#### [Bulma Themes](https://bulmathemes.com/)
#### [Creative Tim](https://www.creative-tim.com/)
#### [Start Bootstrap](https://startbootstrap.com/)
#### [Hacker Themes](https://hackerthemes.com/)
#### [Colorlib](https://colorlib.com/wp/templates/)
#### [Templated](https://templated.co/)
#### [Bootswatch](https://bootswatch.com/)

# Themes for Static Site Generators

#### [JAMstack themes](https://jamstackthemes.dev/)

# Color & Other Tools

#### [Brumm.af - Box shadows](https://brumm.af/shadows)
#### [Google Material Color Tool](https://material.io/resources/color)
#### [Coolors](https://coolors.co/)
#### [Material Ui Colors](https://www.materialui.co/colors)
#### [Material Color Pallet](https://www.materialpalette.com/colors)
#### [Paletton](https://paletton.com/)
#### [Scheme Color - PredBuilt Schemes](https://www.schemecolor.com/)
#### [Color Combos](https://www.colorcombos.com/)

# Frameworks & Libs

#### [Web Components](https://www.webcomponents.org/)
#### [Material UI](https://material-ui.com/)
#### [Ant Design](https://ant.design/)
#### [Ionic Web Components](https://ionicframework.com/)

---

Enjoy 😎
CopyPasta vs adding smaller dependencies
Tags: discuss, node
Published: 2020-07-27 05:37:23

This also including copy-paste from **Gist** or GitHub blobs, vs installing from / cloning the repos.

Copy-paste seems to have benefits, although it probably cannot be versioned directly.

- Not only [size-aware](https://bundlephobia.com/), but also content-aware.
- Removing necessary codes and streamlining to your projects are easier.
- Bug fixing is yours, and can be easier. Not fixing bugs is a vulnerability.
  - Dependencies' code is still code, and I believe that usually, the less code, the safer.
- Not really sure how to deal with LICENSE, though.

As NPM might be full of a few lines' packages; but not sure about how other repositories (e.g. PyPI) do, what do you think?

So, should I publish a Gist, a GitHub Repo, or a Package?
Automating debug removal for Ansible YAML code with Bugspray
Tags: ansible, python, linux, yaml
Published: 2020-07-27 05:03:39

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/5z3vponga5zsv89e104r.png)
**Backstory**: I wanted to learn more about the philosophy behind debug in production and development. I am not a programmer by nature, so understanding the implementation of debug was a foreign concept to me. I researched and researched on best practices for implementing debug into production. The answer I got - "it depends". There is no one way to properly implement debug. It comes down to what your enterprise requirements are. Some programmers leave in non-intrusive and non-sensitive debug in production code. Some programmers believe all debug should be removed from production.

I designed a small application to fulfill the needs of having to mass remove or selectively locate useful debugs.

The program I came up with is called ***Bugspray***.

https://github.com/schnipdip/Bugspray

Bugspray allows you to automate the mass removal of debug code from YAML files or you can selectively keep debug within your code. This reduces the amount of time needed to refactor your code when moving from dev to ops. It fits nicely within the devops pipeline.

So whatever your enterprise requirements, Bugspray can help!