teleren/devto huggingface dataset:
Curl Proxy vs X-Forward-For
Tags: curl, forward, php, proxy
Published: 2020-03-28 14:13:12

When working with cUrl and proxies in PHP and a lot of request, first of all it can of course help to run multiple process at the same time, but besides that how you use the proxy itself can be a huge performance boost if done like below:

````php
		$curlResource = curl_init($this->sourceUrl);
+		if (isset($this->getProxy())) {
+			$headerData[] = 'X-Forwarded-For: ' . $this->getProxy();
+		}
+		curl_setopt($curlResource, CURLOPT_SSL_VERIFYHOST, false);
+		curl_setopt($curlResource, CURLOPT_SSL_VERIFYPEER, false);
 		curl_setopt($curlResource, CURLOPT_URL, $this->sourceUrl);
 		curl_setopt($curlResource, CURLOPT_HEADER, 1);
 		curl_setopt($curlResource, CURLOPT_FOLLOWLOCATION, 1);
 		curl_setopt($curlResource, CURLOPT_RETURNTRANSFER, 1);
 		curl_setopt($curlResource, CURLOPT_HTTPHEADER, $headerData);
-		// Set proxy if applicable
-		if (NULL !== $proxyIp && FALSE !== $proxyIp) {
-			curl_setopt($curlResource, CURLOPT_PROXY, $proxyIp);
-			curl_setopt($curlResource, CURLOPT_HTTPPROXYTUNNEL, 1);
-		}
````

This is a small diff from an example. The most important part is that instead of using the `CURLOPT_PROXY` and `CURLOPT_HTTPPROXYTUNNEL` then  use the `X-Forward-For` header do the trick for you.

The win here is due to they will be no network latency what so ever, as the proxy is only simulated and not actually used.

I'm using this test for GEO IP redirects etc. and when testing e.g. 300 redirects, then it does matter that you gain a four times faster job than you had before. With this said this of course depends on the proxy speed, but i'm close to guarantee that this will speed up you job, if you do this change.
ENS+IPFSでページ作ってみた
Tags: ens, ipfs
Published: 2020-03-28 14:12:54

---
title: ENS+IPFSでページ作ってみた
published: true
description: 
tags: ens, ipfs
---

https://app.ens.domains/ こちらで開いてるname spaceを探します。
6文字以上なら0.039ETHぐらいで取れます。
Request To RegisterでMetaMaskが起動され確認プロセスに入ります。正しく確認されたら登録可能になります。

登録終わったらIPFSでstaticページを作ってIPFS上にaddします。
https://github.com/dongri/IPFS

さきほど登録した ens.domains の設定でrecordを追加します。
contentを選択して、 `ipfs://QmZJxRbN7dujTURuBJUu2LPd5x6eWfHLf11uWHZUXtLbko` のように登録します。Ethereum blockchain上に登録するので数円のgas代かかります。

しばらく待つと反映されます。しかし `.eth` ドメインはブラウザは認識くれず表示されません。MetaMaskなど対応してるwalletアプリがextensionで入ってたらipfsページリダイレクトしてくれます。普通のブラウザが認識できるようにするには `**.eth.link` が用意されてます。 https://eth.link/

```
$ host -t TXT dongri.eth.link
dongri.eth.link descriptive text "a=0x1D09Dbd214E08583597Be1195394DCf965F50D22"
dongri.eth.link descriptive text "contenthash=0xe30101701220a3016ce12c2d1130bb6ca4f2a4f38bff1f441ed4a5405d25ed08cf742bb6275c"
dongri.eth.link descriptive text "dnslink=/ipfs/QmZJxRbN7dujTURuBJUu2LPd5x6eWfHLf11uWHZUXtLbko"
```

以上で、500円ぐらいでホームページを公開できました。
ちなみに `.eth` はイーサアドレス代わりにできるので、対応してるwalletアプリで `dongri.eth` で送金できます。
Getting started with web scraping in Python
Tags: python, webdev, beginners, tutorial
Published: 2020-03-28 14:03:04

## Web scraping

If you do a simple Google search about Web Scraping, it'll lead you to the wiki page of Web Scraping, which notes that web scraping started way back in 1993. Even though back then, and even now, these scrapers were used to collect data from the sites, our aim would be a bit different. We don't want to collect all kinds of data but only the data that would benefit us.

For the sake of this article, we'll take the example of building a simple API for billboard that returns chart data based on the passed chart name.

## The Process

The process can be broken down into 3 steps

1. Research
2. Implementing
3. Checking all cases

Read the rest of the article in my personal page [here](https://deepjyoti30.github.io/blog/getting-started-with-web-scraping-in-python)
Function-Based Views Vs Class-Based Views - Django 
Tags: django, views, python, webdev
Published: 2020-03-28 13:48:49


A view is a place where you put the logic of the application. The Views are used to perform activities like fetching objects from the database, modifying those objects if needed, rendering forms and so on.

The Django official documentation describes views as:
"A view function, or view for short, is a Python function that takes a Web request and returns a Web response. This response can be the HTML contents of a Web page, or a redirect, or a 404 error, or an XML document, or an image . . . or anything, really. The view itself contains whatever arbitrary logic is necessary to return that response. "

In the earlier days of Django there was only the function based views. They were easy to implement and very useful, but while working on a large project, the views were often crowded with similar functions. This was one of the reasons for the creation of class based views.

# Function Based Views

 Function based views are the views in Django that are defined by functions. These python functions take a web request and returns a web response.
 Function based views are most of the time based on 'What you see is what you get approach'. This is because all the logic of the view must be included.

 The biggest disadvantage of this approach is the length and repetition of codes. Writing a same block of code over and over is never a good practice.

```python
 def example_fbv(request):
 	items = Item.objects.all()
 	context = {
 		'items' : item
 	}

 	return render(request, 'app/index.html', context)
 ```

This example of FBVs is easy to implement and understand, but if it was a part of a larger Django project we would see a lot of similar functions. This causes code repetition and views become long and hard to read.  

# Class Based Views

Class based views are Django views based on Python classes. As mentioned in the Django official documentation, 'class based views do not replace function-based views, but have certain differences and advantages when compared to function-based views'. CBVs are very easy to use in simple cases, but extending them with increasing project complexity becomes more and more difficult. 

Class based views may be easy to begin with but you need to understand Python classes along with Django views to master them.  

```python
class example_cbv(View):
	model = Item
	template_name = 'app/index.html'
```
This class based view does the exact same thing as the function based view above. It makes code relatively shorter and reduce code duplication, but it makes code harder to understand due to implicit code flow.


# Conclusion

As stated earlier class based views do not replace function-based views and there is no right or wrong. Function based views can be a better choice in some cases, whereas class based views in another. It all depends on context and need of the project.
What is webmention?
Tags: webmention, webdev, social, indieweb
Published: 2020-03-28 13:48:44


Webmention is a way to notify any website URL from your site. Receivers can use webmention to request notifications when other sites mention it. This web standart is created and maintained by IndieWeb. As of January 12, 2017 it is a W3C recommendation.

By using this protocol, you can list any mentions to your posts and push content to other sites automatically. It is like having a conversation between websites. It is also easy to accept webmentions right away.

That's not all, you can also list twitter likes, replies and retweets when your link shared on twitter.

### Accepting webmentions

Change the URL and add this code to your `head` tag.

```html
<link rel="webmention" href="https://webmention.io/pikseladam.com/webmention" />
<link rel="pingback" href="https://webmention.io/pikseladam.com/xmlrpc" />
```

Now you can enter the [webmention.io](https://webmention.io) website and see any mention linked to your site.

Here is good example websites that supports webmentions.

- [aaronparecki.com](https://aaronparecki.com)
Aaron is also the co-founder of indiewebcamp. His websites is perfect example of webmention usage. In his site, you can see the reposts, replies, mentions and twitter likes for his posts.  

[![One the posts of aaron](https://pikseladam.com/static/99ed42d7c17c3ac2cd470a46ba59e396/935bc/aaron.jpg "One the posts of aaron")](/static/99ed42d7c17c3ac2cd470a46ba59e396/0d6a8/aaron.jpg)

- [kickscondor.com](https://kickscondor.com)
Kicks is one of the best collectors in internet. He is always searching for good links, sharing them on its site. Also, he has a good web browser extension called [Fraidycat](https://fraidyc.at/) which basically gathers and displays all feed information that you want to follow. His website has pretty old-school kind of different style. He supports webmentions. You can see his twitter replies and mentions under his posts. _Kicks doesn't want anyone to share his page. Sorry kicks._

### API to list mentions

[webmention.io](https://webmention.io) has also have an API to list webmentions to your pages.Just change the target url and list any mention to it.

```
https://webmention.io/api/links.jf2?target=https://webmention.io
```
   
### Help out

If you would like to help, you can start [on github](https://github.com/aaronpk/webmention.io).

_This just a simple introduction article to webmentions. If i missed anything please let me know._
What to do if I want to work so much but have nothing to work on?
Tags: discuss, javascript, webdev
Published: 2020-03-28 13:47:02

---
title: What to do if I want to work so much but have nothing to work on?
published: true
description: What to do if I want to work so much but have nothing to work on even though I'm trying so hard to find?
tags: discuss, javascript, webdev, productivity
---

Hi guys! I'm a frontend developer with almost 4 years of experience. I started with websites on HTML, CSS, and JavaScript and a little bit more than 2 years ago I started working with React. Unfortunately, 99,9% of this time I worked either on freelance (all websites — no web apps or anything like this, even though I had some websites on Gatsby) or on my own projects. I had almost all my freelance projects from one customer so unfortunately, I didn't master the science of searching for new customers and new projects.

So, why am I telling you all this stuff? Right now I'm in such place when I want to work, I want to work hard and a lot because I love working on frontend, I love JavaScript, I love React, I want to grow as a developer, I tried working with TypeScript and I want to work with it more, I want to write tests, I want to work in a team with teammates who want to grow as developers too, and the most important thing — I need to work to keep myself busy because otherwise, I regret that I'm just wasting my time.

But the problem is that I can't find a job or a new freelance project on React. And I have no idea what to do. It's not the first week or first month, it's going like this for half a year. I tried to find a job or new projects on React. I had an idea to work open-source on some projects like Gatsby or some other projects I know and I like but it's all in vain. I would love to work on my own projects but I don't even have any ideas. It's just sad that so much energy and passion is wasted. And I thought maybe you could help me with that? Any ideas, recommendations or anything else is welcome. If somebody has an open-source project or a project that is dedicated to helping people or anything else and you think I'll be useful — please, I'm open to anything.

Thank you!
Are your workers working?
Published: 2020-03-28 13:45:15

Link: https://blog.joshsoftware.com/2016/01/18/are-your-workers-working/

Most of the Rails developers choose Sidekiq for background processing in their Rails applications and setup the Sidekiq workers to do the long running work in background.

But as a Rails developer have you ever wondered whether your workers are doing their job? Now question may pop up in your mind, How to know whether my background workers doing their job? No worries now you can do that easily with sidekiq-status gem, How? Lets see how …
Solution working Hammer.js after upgrading to angular 9
Tags: webdev, angular, hammerjs, typescript
Published: 2020-03-28 13:35:24


### :small_orange_diamond: Why did Hammerjs stop working after upgrading to angular 9?

In Angular 9 it was decided that the implementation of ``Hammerjs`` was optional, so now we have to import the ``HammerModule`` from ``@angular/platform-browser``.

### :small_orange_diamond: Solution

Add the ``HammerModule`` import from ``@angular/platform-browser`` and add it to our ``@NgModule`` imports in the ``app.module.ts``

```ts
import { HammerModule} from '@angular/platform-browser';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    HammerModule,
    .
    .
    .
  ]

```

### :small_orange_diamond: Solution with HammerGestureConfig

```ts
import { BrowserModule, HammerGestureConfig, HammerModule, HAMMER_GESTURE_CONFIG} from '@angular/platform-browser';

// custom configuration Hammerjs
@Injectable()
export class HammerConfig extends HammerGestureConfig {
  overrides = <any> {
      // I will only use the swap gesture so 
      // I will deactivate the others to avoid overlaps
      'pinch': { enable: false },
      'rotate': { enable: false }
  }
}

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    HammerModule,
    .
    .
    .
  ],
  providers: [{provide: LocationStrategy, useClass: PathLocationStrategy},{
    provide: HAMMER_GESTURE_CONFIG,
    useClass: HammerConfig
  }],

```

Thanks for reading me. 😊
Daily Developer Jokes - Saturday, Mar 28, 2020
Tags: jokes, dailydeveloperjokes
Published: 2020-03-28 13:00:26

---
title: "Daily Developer Jokes - Saturday, Mar 28, 2020"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Saturday%2C%20Mar%2028%2C%202020"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258c00f974.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ What does a baby computer call his father?

___A:___ Data!
 -->
React coding challenges - what & why 
Tags: react, challenge, github, javascript
Published: 2020-03-28 12:56:37

Not interested in the background and want to jump into some code? Link here: https://github.com/alexgurr/react-coding-challenges

--- 

Our interview process used to look like this:

1) Initial 15 minute phone call, 'the basics'. Did the candidate research the business? Are they aligned with what we're looking for? Some basic information about their experience.

2) One hour technical interview. Questions about various bits of our tech stack, JavaScript, React, GraphQL, testing, clean code. General technical assessment.

3) Tech test/challenge. Takes anywhere from 2 - 8 hours depending on the candidate. Full stack JS - front/backend test.

4) Final interview to talk through the test/candidates code and next steps.

A month or so ago a colleague of mine suggested adding a new step in our interview process. His suggestion was to add a pair coding exercise in the early stages that was relatively short, but would help us identify if a candidate had the following qualities:

- Ability to think on the spot
- Communication skills and ability to talk through their code with others
- Logical thought processes

I introduced a coding challenge designed to be completed in 15 - 30 minutes. The scaffold of the app would be provided for you. You'd have a set of requirements and off you'd go. It was coupled with the initial 15 minute phone call.

The technical challenge? It had to be remote. We didn't want to waste anyone's time if they were the wrong fit. We ended up using VSCode and a live collaboration plugin alongside ngrok which allowed me to share my local development server to candidates over the internet.

It worked surprisingly well. The feedback I've had has been excellent and the challenge I was told, was fun. The lesson to be learned is that you can provide small, fun challenges that give some serious benefit.

I've published the challenge to GitHub. I've also added a new one to the same repo. The plan is to build more and more over time. I'm super open to feedback/suggestions/ideas! Reach out! Each one has a difficulty level, time to complete and a set of requirements.

Repo here: https://github.com/alexgurr/react-coding-challenges

If you're interested in the solutions, get access at [solutions.alexgurr.com](solutions.alexgurr.com).

Like my article and want more? Come and follow me on [medium](https://medium.com/@alexgurr).
UI Component Source Files (.sketch)
Tags: uidesign, resources, sketch, frontend
Published: 2020-03-28 12:49:16

Last week most of my daily practices were spent on creating components for Flow UI.

Flow UI is a design system that we're building together with the amazing guys from Themesberg for the tailwind CSS framework.

I created a notification settings modal, a list, some tooltips, a sign up pop-up and a couple other components.

You can check out the designs and click on them to download the `.sketch` source files below.

I hope you like them, and you'll find them useful.


![Notification Settings](https://uidesigndaily.com/uploads/1056/day_1056.png)

[Download Source from here](https://uidesigndaily.com/posts/sketch-notification-settings-notifications-modal-day-1056)


![App List](https://uidesigndaily.com/uploads/1057/day_1057.png)

[Download Source from here](https://uidesigndaily.com/posts/sketch-apps-list-app-modal-day-1057)


![Tooltips](https://uidesigndaily.com/uploads/1058/day_1058.png)

[Download Source from here](https://uidesigndaily.com/posts/sketch-tooltips-tooltip-onboarding-day-1058)


![Sign Up](https://uidesigndaily.com/uploads/1059/day_1059.png)

[Download Source from here](https://uidesigndaily.com/posts/sketch-sign-up-card-day-1059)


![Components](https://uidesigndaily.com/uploads/1060/day_1060.png)

[Download Source from here](https://uidesigndaily.com/posts/sketch-components-share-card-day-1060)
Fight Covid-19 - Online Hackathon
Tags: hackathon, opensource, opendata, machinelearning
Published: 2020-03-28 12:44:43

Hi Developers and Hackers.

We have an important challenge for you 😷 

Fight COVID-19 Open Challenge is an open collaboration effort in which volunteers, designers, students, researchers, computer scientists, health workers, startups, software developers, business developers and others will cooperate and produce creative solutions which can help fight against the current health crisis introduced by COVID-19.

This global hackathon is an opportunity for developers to build software solutions that drive social impact. 

## GOAL
* Create technological solutions to help health professionals to deal with the huge amount of patients that are clogging our health services.
* Create concise informational (infographics, videos, written) materials to raise awareness about the virus transmission and spreading factors, epidemic geographic focal points and the right measures to circumvent the transmission.
* To call on more people to participate and create works including product prototypes, coding, user experience design, and business or social impact models to combat the COVID-19 epidemic.
* To encourage social innovation so that we can help the fight against the epidemic with open collaboration and hence create shared value among volunteers, institutions, businesses enterprises, and platforms.

## THEMES
* **Health Services**
* **Epidemic Analytics**
* **Covid-19 Information Materials** 

## DELIVERABLES:
All project resources (source code, designs, presentation, documentation, sketches, etc.) must be submitted as a TAIKAI Project. All submissions must be in English and must be the original work of the submitter team.

**Project Description with**:

* A description that includes a brief explanation of what the solution is and what problem is it tackling;
* Screenshots or pictures from the Application;
* Open Source Code link;
* Technology stack or services used;

Register your application at [TAIKAI](https://taikai.network/taikai/challenges/covid-19)

Join this global battle 💪 

"Let's find solutions faster than the virus spreads! ✨
Unity Accelerator + Prometheus + GrafanaをDockerでサービス化する
Tags: unity3d, docker
Published: 2020-03-28 12:38:00

---
title: Unity Accelerator + Prometheus + GrafanaをDockerでサービス化する
published: true
tags: Unity, Docker
date: 20200328T12:38Z
canonical_url: https://qiita.com/shiena/items/ca8b998eb085f12fa163
---
# はじめに

Unity2019.3からAsset Pipeline v2が追加されてUnity Acceleratorを組み合わせるとインポートしたアセットをキャッシュおよび共有することができます。

- [Unity Accelerator でチームの作業をスピードアップ](https://blogs.unity3d.com/jp/2019/09/11/speed-up-your-team-with-the-unity-accelerator/)

それまでのUnityにもAsset Pipeline v1とキャッシュサーバーでキャッシュできていましたが、Unity Acceleratorには以下の違いがあります。

- キャッシュサーバーと同居できる
- Collaborateのキャッシュに対応
- 不要なキャッシュを定期的にクリーンアップ
- 転送されたバイト数や接続されたエディターなどの情報をPrometheusから利用できるメトリクスで公開

フォーラムの以下のスレッドによるとDockerHubでイメージが公開されています。

- [Consider making a Docker Container for Accelerator?](https://forum.unity.com/threads/consider-making-a-docker-container-for-accelerator.809115/)
- https://hub.docker.com/r/unitytechnologies/accelerator

Unity Acceleratorは[Prometheus](https://prometheus.io/)とダッシュボードの[Grafana](https://grafana.com/)を組み合わせるとメトリクスを可視化できるのでdocker-composeでサービス化しました。


# Dockerでサービス化

https://github.com/shiena/docker-unity-accelerator

## 設定ファイル

```accelerator.env
COLLAB_REGISTRATION_TOKEN=ft0bJvbRD
DISABLE_USAGE_STATS=yes
```

- [Unity Collaborate](https://unity3d.com/unity/features/collaborate)と連携する場合は`COLLAB_REGISTRATION_TOKEN`にトークンを設定します。
- 統計情報の送信を抑制する場合は`DISABLE_USAGE_STATS`に任意の値を設定します。

## サービスを実行

```
docker-compose up -d
```

サービスを起動するとそれぞれ以下からアクセスできます。

- Unity Acceleratorおよびキャッシュサーバー: 起動したPCのIPアドレス
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000
    - 初期アカウントとパスワードは`admin`と`admin`

Grafanaでは[Unity - Manual:  Unity Accelerator](https://docs.unity3d.com/Manual/UnityAccelerator.html)の一覧にあるメトリクスを扱えます。


## Local Administraotr Dashboard

v1.0.272+gb7c26b9からLocal Administrator Dashboardが追加されて http://localhost:10080 からアクセスできるようになりました。

ConfigurationとLogsは以下のコマンドでパスワード設定が必要です。

```
docker-compose exec accelerator /agent/unity-accelerator tool adminpw mysupersecretpassword ​
```

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

# 公式イメージ公開前にDocker化で工夫したこと

- ~~Unity AcceleratorをダウンロードするURLからバージョンが分からないのでバージョンを確認する方法を用意しています。~~
- v1.0.196+ge1f9988で修正されました。~~キャッシュサーバー追加でインストーラーを非対話モードで実行するとnpmのパスが展開されないバグがあるので対話モードprintfで強引にインストールしています。(バグ報告済み)~~
- v1.0.242+gf11031dで修正されました。~~v1.0.196+ge1f9988で初回起動時などpidファイルがなかったり空の時に起動できないバグがあるのでパッチを当てています。~~
- 公式イメージが公開されたので独自Dockerfileから切り替えました。
From Idea to Launch Ep. 3
Tags: react, javascript, showdev
Published: 2020-03-28 12:26:30

---
title: From Idea to Launch Ep. 3
published: true
description: In this latest video I show you how to use react components and state with useReducer in NextJS
tags: react, JavaScript, showdev
---

Here is the latest video in the series where I create https://wachstum.space using react, nextjs and now. In this episode I show you how to use React components with Nextjs and how to manage state with useReducer.

Hope you enjoy! Leave some comments so I can improve 😃🙌

{% youtube 5fD_ETnXApE %}