teleren/devto huggingface dataset:
Access control in GraphQL using Symfony
Tags: engineeringmonday, symfony, php, graphql
Published: 2021-02-02 20:48:24

Authorization is part of almost any web application and controlling access to specific data is essential for application security. The same goes for GraphQL APIs and with help of [Overblog's GraphQL Bundle](https://github.com/overblog/GraphQLBundle), this can be done easily.

### Field access control
Every GraphQL API has at least one root type, Query. Root types are the most common place where we would want to control access by setting rules to a specific field. Some examples could be controlling access to some admin-related queries by allowing only users with `ROLE_ADMIN` role or allowing access to `user` query only if a requested user is currently authenticated user or has `ROLE_ADMIN` role. This can be done using [expression language](https://symfony.com/doc/current/components/expression_language/syntax.html) functions in the field configuration option called `resolve`.

#### Using `hasRole`
This expression language function is provided by the bundle and is self-explanatory - it checks if the currently authenticated user has the role you provide as an argument.

```yaml
Query:
  type: object
  config:
    fields:
      activityLog:
        type: "[Activity!]!"
        access: "@=hasRole('ROLE_ADMIN')"
        resolve: "@=resolver('ActivityLog')"
```

#### Using `isGranted`
This function is not documented in the [official documentation](https://github.com/overblog/GraphQLBundle/blob/master/docs/definitions/expression-language.md), but it actually exists if you look closely in the [codebase](https://github.com/overblog/GraphQLBundle/blob/master/src/ExpressionLanguage/ExpressionFunction/Security/IsGranted.php). Sometimes checking role is not sufficient and we want complex logic to determine if a user has access or not. This can be done using [voters](https://symfony.com/doc/current/security/voters.html) and `isGranted` expression language function.

```yaml
Query:
  type: object
  config:
    fields:
      user:
        type: 'User'
        access: "@=isGranted('user_access', args['id'])"
        args:
          id:
            type: 'ID!'
        resolve: "@=resolver('User', [args['id']])"
```

__________
If you have any questions, comments or experiences with using GraphQL you'd like to share, put them in the comments section below!
curl Multiple Files
Tags: cli, http, url, scrape
Published: 2021-02-02 20:58:02

---
title: curl Multiple Files
published: true
description: Downloading files from multiple URLs
tags: cli, http, url, scrape
//cover_image: https://direct_url_to_image.jpg
---

Downloading resources at multiple URLs. 
```
curl "example.com/path/{bravo, alpha, charlie}.html" -o "example/#1.html"
```
Will result in:
```
example/bravo.html
example/alpha.html
example/charlie.html
```

##Easy way to get all of the links on a particular page (ie: directory)

Hop in the dev console on the page and paste:
```
copy(document.links)
```

This will copy an array of all of the links on the page into clipboard.
Deploy Application to Firebase
Tags: firebase, deployment, ionic
Published: 2021-02-02 20:55:23

# Deploy the ionic application in firebase

## Installation

Make sure you have installed the firebase-tools. If not, please find the following command to install

```
npm install -g firebase-tools
```

## Login & Test the connection

1. Login to Firebase.

```
firebase login:ci
```
![Firebase](https://dev-to-uploads.s3.amazonaws.com/i/jj537g0ew2pg3zhy17m2.jpg)


2. Check the list of projects available. It displays the list of projects available.

```
firebase projects:list
```

![Firebase project list](https://dev-to-uploads.s3.amazonaws.com/i/i4wdjz02jzplawpse7st.jpg)

## Initialize a project

Initialize the project with the following command.

```
firebase init
```

Follow as per instructions and pick the Hosting and then select the project.
Post selection set of question will pop up

- What do you want to use as your public directory? - Mention your build folder (e.g www).

- Configure as a single-page app (rewrite all URLs to /index.html)? - No

- Set up automatic builds and deploys with GitHub? - Y

It requests you to authorize the GitHub by CLI URL.

- For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository) - Updated the user and repository (e.g amkumar072/firebase-deploy-sample)

It will set up an account FIREBASE_SERVICE_ACCOUNT for your project.

- Set up the workflow to run a build script before every deploy? (y/N) - Select depend upon your request. I have selected YES, then the next question will appear.

- What script should be run before every deploy? (npm ci && npm run build) - Provide the build script/commands or else press enter to take the default.

* Set up automatic deployment to your site's live channel when a PR is merged? (Y/n) - Select depend upon your request. I have selected NO.

Initialization is completed. By the time you would able to see the 3 files are created

- .firebaserc
- firebase.json
- firebase-hosting-pull-request.yml
![Firebase init](https://dev-to-uploads.s3.amazonaws.com/i/afz4lybxhm9w3zbci85s.jpg)

![Firebase commands](https://dev-to-uploads.s3.amazonaws.com/i/vcit7xasdf4z8a8awx0g.jpg)

## Deploy to Firebase

Now we are in the final part of the process. Deploy your project with the following commands.

note: Make sure the project is already built (npm run build)

```
firebase deploy
```

Changes will deploy into Firebase and the URL will be displayed in Console.

![Firebase deploy](https://dev-to-uploads.s3.amazonaws.com/i/nu6iywqdfo0tk5fi3ktx.jpg)

Please find the source code in [Github](https://github.com/amkumar072/firebase-deploy-sample)

Happy Deployment :)
Using gradient for styling text
Tags: android, gradient, text, androiddev
Published: 2021-02-02 20:51:40

Having an engaging and fancy user interface is essential for providing a delightful user experience. In some cases, this calls for using gradient colors. While Android’s styling system is pretty powerful, it lacks an out-of-the-box way to style a text using a gradient for coloring its text. Since at [Plum](https://withplum.com) we always try to explore new ways to achieve the best results, we had to come up with a solution!

# CharacterStyle to the rescue!

Thankfully the [android.text.style](https://developer.android.com/reference/android/text/style/package-summary) package contains enough tools for extending the already-provided styling capabilities. There’re many ways to extend it, but for this case, we’ll take a look at extending CharacterStyle to match our needs.

The key method of that abstract class is updateDrawState:

```java
public abstract void updateDrawState(TextPaint tp);
```

This method has as a parameter the `TextPaint` that will be used in our TextView. Most importantly, the TextPaint can have a [shader](https://developer.android.com/reference/android/graphics/Shader) object for drawing. And for that, we’ll be using [LinearGradient](https://developer.android.com/reference/android/graphics/LinearGradient) shader!

# The code

Without further ado, here’s what we came up with:

{% gist https://gist.github.com/cmargonis/d1822422ac3f604b97ec06757ff351cd %}

# Using it

The LinearGradientSpan can be used as any other character style:
```kotlin
val textView: TextView = findViewById(R.id.tv_hello)
val text = "Hello World!"
val purple = getColor(R.color.purple_200)
val teal = getColor(R.color.teal_200)
val spannable = text.toSpannable()
spannable[0..text.length] = LinearGradientSpan(text, text, purple, teal)
textView.text = spannable
```

It’s a relatively easy way to produce an interesting text effect.

![hello_gradient](https://dev-to-uploads.s3.amazonaws.com/i/ya88rkppndgguf4pdw9a.png)


While in a more real scenario (taken from [Plum’s](https://play.google.com/store/apps/details?id=com.withplum.app) android application) the effect can have a more subtle effect:

![plum_gradient](https://dev-to-uploads.s3.amazonaws.com/i/kel41qs1tts0eo504ib2.png)

# Closing

As I’m not an expert in Graphics (let alone Android graphics 🤣), there should be plenty of optimizations that this utility class could receive. If you also want to build amazing things (and maybe improve the LinearGradientSpan!) check out our [openings](https://apply.workable.com/withplum/)!
How to Learn Machine Learning and Deep Learning: a guide for Software Engineers
Tags: machinelearning, beginners, career
Published: 2021-02-02 20:39:40

*This article was first posted on* [renanmf.com](https://renanmf.com/machine-learning-and-deep-learning-software-engineers/)

This is a video where I share the resources I used to learn Machine Learning and Deep Learning online.

If you are looking for a path to follow, this is your guide!

I give you guidelines to learn:

* Python
* Calculus
* Linear Algebra
* Machine Learning
* Deep Learning

I hope you find it useful!

{% youtube -uxyG_VAsyo %}
Hide "No file chosen" of input elements (type="file")
Tags: html, webdev, css
Published: 2021-02-02 20:32:00

If you create file input elements, 

```html
<input type="file" />
```

you will see

![Screen Shot 2021-02-03 at 5.13.01](https://dev-to-uploads.s3.amazonaws.com/i/mityv3oskkiydssce0ar.png)
 
This "No file chosen" is sometimes bothering for design. Let's hide it.

## Needs Dom manipulation?

If you investigate how to hide this, you will find a solution using jQuery.

FYI: https://stackoverflow.com/questions/12035400/how-can-i-remove-the-no-file-chosen-tooltip-from-a-file-input-in-chrome

```css
input[type='file'] {
  opacity:0    
}
```

```html
<div>
    <input type='file'/>
    <span id='val'></span>
    <span id='button'>Select File</span>
</div>
```

```js
$('#button').click(function(){
   $("input[type='file']").trigger('click');
})

$("input[type='file']").change(function(){
   $('#val').text(this.value.replace(/C:\\fakepath\\/i, ''))
})    
```

But If you use React, Vue, and so on, How do you do it? The simple solution is just to use CSS.

```css
input[type='file'] {
  color: rgba(0, 0, 0, 0)
}
```

The point is, not to use `opacity` but use `color`. If you use opacity, the input button also disappears. 

![Screen Shot 2021-02-03 at 5.27.11](https://dev-to-uploads.s3.amazonaws.com/i/ent781qd5bip9hvytq4e.png)

Those are examples.

{% codesandbox input-file-piobe %}
วิธีการใช้ Module ของ Node.js [ตอนที่ 2]
Tags: node, modules
Published: 2021-02-02 20:17:44

จาก [ตอนที่ 1](https://dev.to/supaluckn/module-node-js-1-47p1) ซึ่งได้รู้จักกับ Module และการ Export ตัว Module กันแล้ว ที่นี้เราจะทำการ Import ตัว Module มาใช้งานกัน ซึ่งจากตอนที่ 1 นั้น เราได้ทำการสร้างไฟล์ Module ขึ้นมา 2 ไฟล์คือ index.js และ someone.js โดยเราจะทำการ run ไฟล์ index.js 

## การ Import ตัว Module ที่สร้างไว้
โดยจะใช้คำสั่ง `require('part/ชื่อ Module');` ดังเช่น เราได้สร้างไฟล์ someone.js กับ index.js ไว้ที่โฟลเดอร์เดียวกันก็ทำการ `require('./someone.js');` จากตอนที่ 1 ที่ไฟล์ someone.js เราได้มีการ export ตัวฟังชั่นอยู่ 2 ตัวคือ cherry() และ nanny() ดังนั้นเราจะ import ฟังก์ชั่นเหล่านี้จาก Module ที่ชื่อ someone มาใช้งานดังตัวอย่าง

```js
const someone = require('./someone.js');

someone.cherry();
someone.nanny();

```
จากนั้นทำการ run ไฟล์ index.js ด้วยคำสั่ง
```
node index.js
```
ผลลัพท์ที่ได้จะเป็น
```
Cherry
Nanny
```
หรืออาจจะเขียนในรูปแบบนี้ก็ได้ดังเช่น
```js
const {cherry, nanny} = require('./someone.js');

cherry();
nanny();
```
เมื่อทำการ run ก็จะได้ผลลัพท์เช่นเดียวกัน
...
เอาล่ะตอนนี้เรามีความรู้เกี่ยวกับการ Export/Import ตัว Module กันแล้วนะคะหวังว่าจะเข้าใจกัน ในตอนที่ 3 จะแสดงอีกตัวอย่างการ Export และ Import ตัว Module
Let's build for Ruby and Rails developers - Part 17
Tags: rails, ruby, video
Published: 2021-02-04 19:25:34

---
title: Let's build for Ruby and Rails developers - Part 17
published: true
date: 2021-02-02 19:31:49 UTC
tags: rails, ruby, video
canonical_url: https://web-crunch.com/posts/lets-build-for-ruby-and-rails-developers-part-17
---

{% youtube KFrzdFwhYqE%}

Welcome to Part 17 of my Let's build for Ruby and Rails developers series. In this part, I carry on adding the final functionality of the new job form by introducing several upsell options that feature varied prices when purchasing a new job listing.

The goal with these up-sells is to increase visibility for the job as well as increase profit for [railsdevs.com](http://railsdevs.com). We hook into Stripe's API to regenerate a new Payment Intent per up-sell option. From the API returns a new client\_secret which we can use to confirm a payment via credit card during the final purchase of the job.

### What's to come?

We're getting very close to having the job form complete but there are a lot of edge cases, validations, UI tweaks, and more to deal with. Coming up I plan to focus a lot on validation on both the front–end and the back-end as well as provide some more help UI during purchase so a user doesn't try to purchase twice or is left in the dark about what to do next.

Once the form is complete I plan to go through and do a big audit on the main design as well as add a dashboard for those that purchase jobs to get some insight about job listings. This would include basic details about a purchase, some basic analytics, and a link to the Stripe invoice. For each purchase we should also generate some mailers to indicate status once a job is published.

Those emails might include:

- An email when a new job is purchased. This just confirms what you purchased, when, and the details of the purchase.
- An email when the job becomes "approved". Since all new jobs will have a status of "pending" by default I'll manually approve any that come through. Once approved we'll kick off an email to the purchaser so they know their job is live.  
- An email when a job gets archived. I think I'll keep things simple and offer job listings for 30 days at the current pricing (shown in this video). Eventually once a job is archived we can allow a customer to optionally re-post the job for another fee that's maybe discounted. Making this a recurring pricing strategy might also be an option but the simpler the better right now. 

Once that phase is complete I'll push a v1 of this app live! 🚀

New here? [Check out the entire series](https://web-crunch.com/collections/lets-build-for-ruby-and-rails-developers) for an overview of what I'm building and follow my journey.
Transitioning to PM Role, The Four Horsemen and 2 Free Resources - Newsletter Issue #1
Tags: motivation, productivity, books, beginners
Published: 2021-02-02 19:17:52

Hi! Welcome to the very first issue of my newsletter, where I’ll be sharing everything I read, think, gossip, tweet, and share at the end of the week. All my learnings in a bite-sized form on content. So let’s start

### Being a Product Manager is hard
I’m currently transitioning to a lead PM role at my job (just after 6 months as lead front-end). I got offered to be the Head of Product because we needed someone to take responsibility + have an owner’s mentality + already have experience of our working style.
So I’m currently 35 days in my role, and I can say it’s hard, and a lot different than programming but I do recommend trying to fit in if you get offered because:
 - It gives you more information about the whole bigger picture
 - It’s exactly thinking like CEO mostly
 - It pays well 🤑

I’ve been sharing some tips on my Twitter for example like this:

{% twitter 1356596842017021954 %}

### What Book I'm reading right now?

##### The Four: The Hidden DNA of Amazon, Apple, Facebook, and Google

Scott Galloway equates the Big Four - Google, Facebook, Apple, and Amazon - to the Four Horseman of god, love, sex, and consumption respectively.
The author proceeds to examine and deconstruct the strategies that the Four employed in becoming the present giants of the industry
I’m kinda loving it, but I’m a little biased because of my interest in the genre.

![](https://pro2-bar-s3-cdn-cf4.myportfolio.com/655b41941737e46bf2b5f9f021940b22/fb301255-2fb9-4d2f-bfe6-e98ccae0c304_rw_1920.jpg?h=a10f2545e9ed685e832488e00ee1d13b)

What resources did I found this week?
 - [100 Daily UI Challenge Library - The first free collection of 100 Daily UI Challenge elements and screens. All files are available in Figma.](https://100dailyui.webflow.io/)
 - [Amelia Wattenberger - Amazing Visual Representation of blog to get inspired from](https://wattenberger.com/blog/react-hooks?utm_campaign=Just%20Another%20Newsletter&utm_medium=email&utm_source=Revue%20newsletter)

### Anything else?
Yeah, I’m going to buy the Grammarly pro version, to improve my overall writing ability and communication skill. So I’ll be reviewing it in my next issue #2
Also, Today’s question: Have you tried the Clubhouse app? Do you like it? What do you think about it?


Subscribe to my [newsletter](https://www.getrevue.co/profile/justaashir), :)


This post is exactly the same as [Issue #1](https://www.getrevue.co/profile/justaashir/issues/just-another-newsletter-issue-1-327310) of my newsletter "Just Another Newsletter"

Thanks for reading :)
[BookLog] グレートカンパニー
Published: 2021-02-02 18:58:17

### 概要

* ソフトエッジ
・ 信頼
・ 知性
・ チーム
・ テイスト
・ ストーリー

* ハードエッジ
・ スピード
・ コスト
・ サプライチェーン
・ 流通
・ 資本効率

* 戦略的基盤
・ 市場
・ 顧客
・ 競合他社
・ 競争優位性
・ 変革者

本書の中心的な主題はソフトエッジについて語られている。そして最も重要な軸として捉えられている。(Forbsの観察結果という根拠に基づいて)

_ソフトエッジで優位にたつと、ブランド認知が高まり、利益率が上がり、得意先が増えて、熱心な従業員が増える。コモディティ化している市場から頭ひとつ抜けるキッカケ_

_ソフトエッジが優れている会社は、戦略上大きなミスを犯しても、生き延びられる場合が少なくない、忠実さと情熱と献身が、強いソフトエッジの配当_

_ハードエッジがしっかりしていても、束の間の利益しかあげられない、ハードエッジは技術、softwareなどの知的資産が安くなるにつれて簡単に真似されてしまう。_

### memo

・新しいことを学んだり、初めてぶつかった問題を解決する能力⇨流動性知性
・学んだ結果を応用する能力⇨結晶性知性

上記の能力を「何かしらの事柄をやり抜く」という姿勢が研鑽していく為、結果的には困難な状況に対して粘り強く取り組めるかということが最重要（スマートである）とされている。

・データと人間的真実の間にある、見つけるのが難しいポイント（最適打球点）がテイスト
※必ずしも新たに作られた物である必要はない、真似でもいい
Pilot - the Free version of Resurface’s API observability solution
Tags: api, devops, datascience, sql
Published: 2021-02-02 18:28:04

Pilot is the single-container, laptop-sized, “free forever” version of Resurface’s API observability solution - a SQL database purpose-built for API data with a query-first architecture for fast and easy searching of API call data. https://resurface.io/pilot-edition
How to run NLP in the browser?
Tags: nlp, node, javascript, tutorial
Published: 2021-02-02 18:13:57

While winkNLP was initially made to run in NodeJS, it can just as easily be used in the browser. To do this, we need to use the web version of the English lite model — [wink-eng-lite-web-model](https://www.npmjs.com/package/wink-eng-lite-web-model). We'll also need a tool that can bundle all the required modules, something like [Webpack](https://webpack.js.org/) or [Browserify](http://browserify.org/). For the purpose of this tutorial we'll use Browserify. First, lets install the required packages:

>We'll be installing Broswerify globally, refer to its <a href="https://github.com/browserify/browserify#getting-started">documentation</a> for more details.

```JavaScript
npm install wink-nlp --save
npm install wink-eng-lite-web-model --save
npm install -g browserify
```
Next, we'll write our JavaScript as we normally would. Here, we'll make a new file called `token-counter.js` and require winkNLP, some helpers, and the web model:

```JavaScript
const winkNLP = require( 'wink-nlp' );
const its = require( 'wink-nlp/src/its.js' );
const as = require( 'wink-nlp/src/as.js' );
const model = require( 'wink-eng-lite-web-model' );
const nlp = winkNLP( model )

const text = `Its quarterly profits jumped 76% to $1.13 billion 
for the three months to December, from $639 million of previous 
year.`;
const doc = nlp.readDoc( text );

doc.entities().each((e) => e.markup());
document.getElementById("result").innerHTML = doc.out(its.markedUpText);
```
Now, we'll use Broswerify to bundle all the required modules into a single file:

```JavaScript
browserify token-counter.js -o bundle.js
```

This will create a new file called `bundle.js` which you can include in your HTML as you would any other:

```JavaScript
<div id="result"></div>
<script src="bundle.js" charset="utf-8"></script>
```

This will create the following output:
<blockquote>
  Its quarterly profits jumped <mark>76%</mark> to <mark>$1.13 billion</mark> for the <mark>three months</mark> to <mark>December</mark>, from <mark>$639 million</mark> of <mark>previous year</mark>.
</blockquote>


## Performance considerations
It is important to note that this is a fully-featured English language model. Make sure to use `gzip` when you serve it on the web. This will reduce its size to  under 1MB (from the uncompressed 3.5MB). Also, setting an appropriate cache header will ensure that the client doesn't have to download it multiple times.
How and Why you should clear your Microsoft Windows Temp folder
Tags: windows
Published: 2021-02-02 17:40:02

---
title: How and Why you should clear your Microsoft Windows Temp folder
published: true
description: You'll learn why you should clear your Windows Temp folder
tags: windows
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/kl2i2fz30rgoy6hqgtvy.jpg
series: All about Microsoft Windows
---

## __Introduction__

The Windows Temp folder contains files that were used, or currently being used by applications installed or running on your Windows system. When the application exits, these files still remain in this folder, over time, it'll take up a considerable amount of your disk space.

In this tutorial, you'll learn: How to find this folder; How to clean it; _and_ Why you should clean it up.

Let's start.

## __How to find the Temp folder__

The Temp folder is located in a hidden folder called `Appdata`, you can show this folder by following the steps detailed in a previous article, but I think that's unnecessary. Here is what you will do.

You'll access the folder via the Windows _Run_ dialog box with its shortcut name.

Perform the following steps:

### __Step 1__

Press the <kbd>Windows Key</kbd> and <kbd>R</kbd> simultaneously, this will bring up the _Run_ dialog box.

Then type: `%temp` as shown in the image below, then click `OK`.

![Windows Run dialog box with the word %temp%](https://dev-to-uploads.s3.amazonaws.com/i/jzmnd8elxewdib4ucli6.png)

This will display a window that will list the temporary files currently present on your system. If you've not cleared this folder before, the files could be in the _thousands_ occupying Gigabytes of space.

Mind you, some files will have the `.tmp` extension as shown in the image below:

![Windows Temp folder with file extension highlighted](https://dev-to-uploads.s3.amazonaws.com/i/7jcgemcifxc1rbky6sq3.png)

Select the files and delete them. You should know, some files might be in use by an application, if this is the case, Windows will prompt to tell you the application using the file, and it will stop the deletion unless the application exists

![Windows prevents a Temp file from being deleted](https://dev-to-uploads.s3.amazonaws.com/i/wvd969shrvphmpyautyi.png)

## __Why you should clean the Temp folder__

As stated in previous paragraphs, the Temp folder can occupy a large chunk of your hard drive depending on your system usage, in addition, __Malware can use this folder to store some of its files__ as noted in the article by ESET entitled: [More evil: A deep look at Evilnum and its toolset](https://www.welivesecurity.com/2020/07/09/more-evil-deep-look-evilnum-toolset/) published in July 2020.

> NOTE: The <kbd>Windows Key</kbd> is the key on your keyboard with the Windows logo on it.

## __Credits__

Cover photo by [Gary Chan on Unsplash](https://unsplash.com/@gary_at_unsplash).