teleren/devto huggingface dataset:
Picasso, 직접 이미지를 설정할 땐 비동기 작업 처리 취소를 잊지말자
Tags: picasso, android
Published: 2020-05-25 04:36:08

---
title: Picasso, 직접 이미지를 설정할 땐 비동기 작업 처리 취소를 잊지말자
published: true
description: 
tags: picasso, android
---

앱에서 이미지로더로 [picasso](https://square.github.io/picasso/) 를 사용하고 있다. 얼마 전 새로운 요구사항이 추가되었다. 모델에서 이미지의 source를 로컬 리소스를 사용할 건지, 웹 url을 사용할 건지 분기를 하여 처리해야 한다. 이 부분은 간단히 만들 수 있다. 대강 이렇게 구현하면 된다.

```kotlin
sealed class ImageSource {
  class RemoteImage(val url:String) : ImageSource()
  class LocalResourceImage(@DrawableRes val resId: Int) : ImageSource()
}

when( source) {
    is RemoteImage -> picasso.load(source.url)
    is LocalResourceImage -> picasso.load(source.resId)
}
.into( imageView)
```

다 된 줄 알았는데 VectorDrawble이 제대로 보이지 않는다는 제보가 들어왔다. 하지만 Jake Wharton 형님은 안해주신다고 하였다.

{% github https://github.com/square/picasso/issues/1109#issuecomment-130365630 %}



궁금해서 왜 vector drawable일 경우 실패하나 찾아보니 `ResourceRequestHandler` 에서 `BitmapFactory.decodeResource` 를 통해 bitmap 을 가져오는데, vector drawable일 경우 여기서 null이 떨어져버린다.

https://github.com/square/picasso/blob/2.71828/picasso/src/main/java/com/squareup/picasso/ResourceRequestHandler.java#L48

```java
  private static Bitmap decodeResource(Resources resources, int id, Request data) {
    final BitmapFactory.Options options = createBitmapOptions(data);
    if (requiresInSampleSize(options)) {
      BitmapFactory.decodeResource(resources, id, options);
      calculateInSampleSize(data.targetWidth, data.targetHeight, options, data);
    }
    return BitmapFactory.decodeResource(resources, id, options);
  }
```

여기까지 확인해서 picasso 의 `load()` 로는 vector drawable을 읽어들일 수 없다고 결론을 내렸다.

이 경우 취할 수 있는 판단은 아래 2가지 일 것이다.
1. 어떻게든 picasso 맥락 안에서 해결한다.
2. picasso 에서 해결할 수 없는 건 picasso 맥락을 벗어나 해결한다.

이 경우 1번으로 할 여지가 거의 없어 보인다. 막 억지로 transform 이나 callback을 집어넣으면 유지보수 측면에선 오히려 더 해롭다. 그래서 picasso 맥락 안에서 해결하는 건 포기하고 아래와 같이 수정했다. 내 경우 local resource일 경우 transform 등의 후처리가 전혀 필요하지 않았기 때문에 간단했다.

```kotlin
when( source) {
    is RemoteImage -> {  //원격 이미지는 picasso로 처리
      picasso.load(source.url)
        .into( imageView)
    }
    is LocalResourceImage -> { //로컬 이미지는 그냥 setImageDrawble로 처리
      imageView.setDrawable( context.resource.getDrawble( source.resId) )
    }
}

```

잘 동작하는 것 같다. 하지만 `RecyclerView` 와 같이 뷰를 재사용하는 경우 문제가 된다. 왜 문제가 되는지 3초 동안 생각해보시오.

... 

`RecyclerView` 를 빠르게 스크롤 한 경우, 원격 이미지를 picasso 가 비동기로 불러오는 와중에 로컬 리소스가 `setDrawble()` 된 경우가 발생할 수 있다. 이러면 로컬 리소스 이미지가 보여야 할 자리에 뜬금없는 원격 이미지가 뜰 수 있다. picasso 맥락 안에서 해결했으면 이런 일이 없었을 것이다. 이 경우 다행히 picasso 는 `cancelRequest()` 라는 메서드를 제공하기 때문에, `ImageView` 를 대상으로 동작중인 비동기 작업을 취소하면 된다. 

```kotlin
when( source) {
    is RemoteImage -> {  //원격 이미지는 picasso로 처리
      picasso.load(source.url)
        .into( imageView)
    }
    is LocalResourceImage -> { //로컬 이미지는 그냥 setImageDrawble로 처리
      picasso.cancelRequest(imageView)
      imageView.setDrawable( context.resource.getDrawble( source.resId) )
    }
}
```

이런 이슈는 비단 picasso 뿐 아니라 다른 프레임워크를 사용할 때도 쉽게 접할 수 있는 문제이다. 따라서 프레임워크 맥락에서 해결할 수 있는 문제는 어지간하면 프레임워크 안에서 해결하는게 대게는 좋은 선택지라고 생각한다.
The start.
Tags: codenewbie, javascript, career, webdev
Published: 2020-05-25 04:09:00

Today I have decided to begin documenting my software engineer career. I guess you could call this a blog. Software engineering isn't something I grew up doing. I'm not some genius coder that has been writing fullstack web applications since I was 14. As of now I am in a full time software engineering program learning fullstack web development. Follow me on my journey there is more to come.

Thank you
Examples of Sass/ SCSS Mixins
Tags: sass, css, tutorial, webdev
Published: 2020-05-25 04:04:20

when I first started learning Sass, I had a hard time conceptualizing what a mixin was and what their uses were in the css I was writing. 

Now that I've been using mixins for a while, I thought I'd write a post showing some examples of really nice use cases for mixins. 

The first time it really hit me was when I realized I could use a mixin to minimize my code for working with *flexbox*...

###Example 1: Flexbox

I found myself writing this multiple time throughout all of my projects:
```css
.element{
    display:flex;
    flex-direction:row;
    justify-content:center;
    align-items:center;
}
```
This made my code very WET and very hard to manage. This is where the advantage of mixins became clear! By declaring this mixin...
```scss
@mixin flex ($direction, $justify, $align){
    display:flex;
    flex-direction:$direction;
    justify-content:$justify;
    align-items:$align;
}
```
calling the four most common rules in flexbox becomes this...
```scss
.element{
    @include flex(row, center, center);
}
```

###Example 2: Fade

Another habit I found myself developing was importing all of jQuery only to find myself using just fadeIn and fadeOut in my projects. This mixin allows a modular way to fade in and out elements using only CSS...
```scss
@mixin fade($fade, $timing, $length, $count, $fill){ 
        animation: $fade $timing $length;
        animation-iteration-count: $count; 
        animation-fill-mode: $fill; 
    } 
    @keyframes fadeIn { 
        0% { opacity: 0; } 
        100% { opacity: 1; } 
    } 
    @keyframes fadeOut { 
        0% { opacity: 1; } 
        100% { opacity: 0; } 
    }
```
This approach relies heavily on the ability to pass params to mixins, making them super flexible and modular for code you repeat often! 

Now animating an element with fade in simply looks like this...
```scss
.element{
    @include fade(fadeIn, ease, 5s, 1, forward);
}
```

###Example 3: Fonts
I've found it useful to use the following mixin when I'm using a font in different areas across a project, but at a range of sizes, weights, and spacings. 
```scss
@mixin font($style, $weight, $height, $spacing){
        font-family: 'Jost', sans-serif;
        font-style: $style;
        font-weight: $weight;
        line-height: $height;
        letter-spacing: $spacing;
    }
```
So calling a font with all of these specifications looks like this...
```scss
.element{
    @include font(italic, 400, 1, 5px);
}
```
This can even be expanded a little more if you're using multiple fonts...

```scss
@mixin font($family, $category, $style, $weight, $height, $spacing){
        font-family: $family, $category;
        font-style: $style;
        font-weight: $weight;
        line-height: $height;
        letter-spacing: $spacing;
    }
```


###remember, 
*I'll be updating this article often as I write new and even better mixins!*
HTML Snippets for Korean Developers
Tags: snippets
Published: 2020-05-25 03:57:00

## Mostly inspired by some of the free snippets available at [freeformatter.com](https://www.freeformatter.com)

#### 20 Largest Cities, South Korea
```html
<select>
		<option value="Seoul">Seoul</option>
		<option value="Busan">Busan</option>
		<option value="Incheon">Incheon</option>
		<option value="Daegu">Daegu</option>
		<option value="Daejon">Daejon</option>
		<option value="Gwangju">Gwangju</option>
		<option value="Suwon">Suwon</option>
		<option value="Ulsan">Ulsan</option>
		<option value="Changwon">Changwon</option>
		<option value="Goyang">Goyang</option>
		<option value="Yongin">Yongin</option>
		<option value="Seongnam">Seongnam</option>
		<option value="Bucheon">Bucheon</option>
		<option value="Cheongju">Cheongju</option>
		<option value="Ansan">Ansan</option>
		<option value="Jeonju">Jeonju</option>
		<option value="Cheonan">Cheonan</option>
		<option value="Namyangju">Namyangju</option>
		<option value="Hwaseong">Hwaseong</option>
		<option value="Anyang">Anyang</option>
</select>
```

#### List of South Korea's Provinces
```html
<select>
		<option value="Chungcheongbuk-do">Chungcheongbuk-do</option>
		<option value="Chungcheongnam-do">Chungcheongnam-do</option>
		<option value="Gangwon-do">Gangwon-do</option>
		<option value="Gyeonggi-do">Gyeonggi-do</option>
		<option value="Gyeongsangbuk-do">Gyeongsangbuk-do</option>
		<option value="Gyeongsangnam-do">Gyeongsangnam-do</option>
		<option value="Jeollabuk-do">Jeollabuk-do</option>
		<option value="Jeollanam-do">Jeollanam-do</option>
		<option value="Jeju Special Self-governing Province">Jeju Special Self-governing Province</option>
</select>
```

#### List of Seoul's Districts (ranked by population)
```html	
<select>
		<option value="Songpa-gu">Songpa-gu</option>
		<option value="Gangseo-gu">Gangseo-gu</option>
		<option value="Nowon-gu">Nowon-gu</option>
		<option value="Gangnam-gu">Gangnam-gu</option>
		<option value="Gwanak-gu">Gwanak-gu</option>
		<option value="Eunpyeong-gu">Eunpyeong-gu</option>
		<option value="Yangcheon-gu">Yangcheon-gu</option>
		<option value="Gangdong-gu">Gangdong-gu</option>
		<option value="Seongbuk-gu">Seongbuk-gu</option>
		<option value="Guro-gu">Guro-gu</option>
		<option value="Seocho-gu">Seocho-gu</option>
		<option value="Jungnang-gu">Jungnang-gu</option>
		<option value="Yeongdeungpo-gu">Yeongdeungpo-gu</option>
		<option value="Dongjak-gu">Dongjak-gu</option>
		<option value="Mapo-gu">Mapo-gu</option>
		<option value="Gwangjin-gu">Gwangjin-gu</option>
		<option value="Dongdaemun-gu">Dongdaemun-gu</option>
		<option value="Dobong-gu">Dobong-gu</option>
		<option value="Gangbuk-gu">Gangbuk-gu</option>
		<option value="Seodaemun-gu">Seodaemun-gu</option>
		<option value="Seongdong-gu">Seongdong-gu</option>
		<option value="Geumcheon-gu">Geumcheon-gu</option>
		<option value="Yongsan-gu">Yongsan-gu</option>
		<option value="Jongno-gu">Jongno-gu</option>
		<option value="Jung-gu">Jung-gu</option>
</select>
```

source: Wikipedia.org
Literature Synthesis 
Tags: devgrad2020, octograd2020
Published: 2020-05-25 03:51:39

[Comment]: # (All of this is placeholder text. Use this format or any other format of your choosing to best describe your project and experience.)

[Note]: # (If you used the GitHub Student Developer Pack on your project, add the "#githubsdp" tag above. We’d also love to know which services you used and how you used it!)

## Introduction 
 This project stemmed from the idea of Generative Adversarial Networks and their philosophical implications on the sale of the GAN generated [artwork sold for a few hundred thousand dollars on Christies's](https://www.christies.com/features/A-collaboration-between-two-artists-one-human-one-a-machine-9332-1.aspx). The premise behind this idea that art itself is not a uniquely human endeavor, that whatever we as humans accomplish, machines may beat us at it. Keeping that in mind I drove to find the last nail in the coffin in human extraordinaire, literature. 

## Utility
   Literature is one the only things that has transcended time and rightful consumption of it is essential to evolution of human society. The advent of infinite (presumably) original literature with the world's largest encyclopedia embedded in its roots and some of the greatest cultural works as a guiding star could produce some high quality literature. 

### Demo Link
 It is currently a Work in Progress. Will probably have a working demo by the end of May. \**fingers crossed\**


## How I built it 

I had initially started building it using the **Transformer** Language Model, but due to its heavy memory consumption for storing attention to other words, its context was severely limited. 
   However, the introduction of the [**Reformer**](https://openreview.net/forum?id=rkgNKkHtvB) Architecture by Google was a godsend. Reformer improves on the long-distance context retention, quintessential to quality literature, by using *LSH*(Locality Sensitive Hashing) and reversible residual layers reducing its storage footprint from {% katex inline %} O(N^2) {% endkatex %}(for Transformer) to {% katex inline %} O(N log N) {% endkatex %}. 
    Having built the model using this architecture as a base on the **Trax Library**{% github https://github.com/google/trax no-readme %}   I intend to lease the TPUs from Google Collab for extensive training, trained on the **enwiki** data set, (or someone comes up with pre-trained weights on top of Reformer before that) and to use transfer learning on the [**Project Gutenberg**](https://www.gutenberg.org/) Open Dataset.  
#  
### Additional Thoughts / Feelings / Stories
   A GPT-2-esque model with highly efficient context retention could spell the next-generation of natural language literature proliferation  throughout the internet-connected world
[Final Note]: # (CONGRATULATIONS!!! You are amazing!)
Cookie vs. Session
Tags: misc
Published: 2020-09-24 04:12:22

---
title: Cookie vs. Session
published: true
date: 2020-04-22 15:37:00 UTC
tags: Misc,misc
canonical_url: https://coderscat.com/cookie-vs-session
---

![2020_04_22_cookie-vs-session.org_20200506_231846.png](https://coderscat.com/wp-content/uploads/2020_04_22_cookie-vs-session.org_20200506_231846.png)

Cookie and Session are two concepts will be met many times in Web development.

Can you give more details about them?

## Cookie

In daily life, a cookie is a dessert or a piece of cake.

In the field of the software world, a Cookie is an information saved by your web browser.

As we all know, HTTP is stateless. So how do you identify a specific customer?

Cookies do that.

Each time an HTTP request is made, the client sends the appropriate Cookie information to the server. It can be set to expire at any time, and if you don’t take the initiative to clear it, you can keep it for a long time, even if you shut down your computer. Another limitation is: Cookie has a size of limit of 4K.

Since it is stored on the client-side, the attackers can tamper with the locally stored information to trick the server. What should we do?

Session will be the solution.

## Session

Session is another mechanism used to identify specific users.

Normally, Session is stored on the server-side, they are stored in a file, database or memory in servers. Session ID could be stored in cookies.

When a user logout from a website, the session will be deleted by server. The stored session ID will be invalid.

In fact, both Cookie and Session are a way to record a state of users. They are typically used in scenarios such as “shopping carts”, where the server does not know exactly what the specific user is doing when you click on the order button. In order to identify and track users and understand that there are several items in the shopping cart. The server gets this information by creating a Cookie/Session for that user.

## More …

Session is not always stored on server-side. The ultimate difference between Session and Cookie is Session is safer and it ends when users close their browsers. Session will be adopted when we do authorization.

You should not put confidential information in Cookies.

Some Web frameworks support the mechanism of CookieBased session. The session will be encoded, encrypted and stored in Cookies. `Rails` use this as the default session solution. Actually there are 6 methods to store session in Rails:

```
:cookie_store
:active_record_store
:drb_store
:mem_cache_store
:memory_store
:file_store
```

The post [Cookie vs. Session](https://coderscat.com/cookie-vs-session) appeared first on [Coder's Cat](https://coderscat.com).
Unicornの管理対象アイテムをパッケージ化する
Tags: sitecore
Published: 2020-05-25 03:49:16

[Unicorn](https://github.com/SitecoreUnicorn/Unicorn)というSitecoreモジュールをご存知でしょうか？アイテムの変更をgitなどのバージョン管理システムで管理することができるモジュールで、私自身よくプロジェクトで使用しています。  

このツールを使用すると開発者間でアイテムを同期することが簡単にできるようになるのですが、そのアイテムをAppServiceなどの本番環境へ直接同期させる方法がないようです。 
しかし、調べてみるとUnicornで管理しているアイテムをパッケージ化する方法がありました。
これを使えばパッケージ化して本番環境へインストールすることができるので、今回はその方法を紹介したいと思います。

## パッケージ化の方法
① まずは[Sitecore PowerShell Extensions](https://doc.sitecorepowershell.com/)というモジュールをSitecoreへインストールします。  
これはPowerShellスクリプトでSitecoreを拡張したり作業の自動化をしたりすることができるモジュールで、大変便利なので今回に限らずインストールをおすすめします。

② 次にLaunch PadからPowerShell ISEを開き、以下のスクリプトを入力します。`$unicornConfigName`と`$packageName`は環境に合わせて変えてください。

```powershell
# Unciornのconfigの名前
# <configuration name="ここの値">
$unicornConfigName = "TestUnicornItems"
# 作成するパッケージ名
$packageName = "Exported Package Name"

$pkg = New-Package -Name $packageName
Get-UnicornConfiguration $unicornConfigName | New-UnicornItemSource -Project $pkg

$now = Get-Date -Format yyyyMMddHHmmss
$filepath = "$SitecorePackageFolder\$packageName.$now.zip"
Export-Package -Project $pkg -Path $filepath -Zip
Download-File $filepath
```

③ リボンのExecuteボタンを押下すると以下のようなダイアログが表示されるので、Downloadボタンを押すとダウンロードできます。

![unicornpackage](https://user-images.githubusercontent.com/52471764/82776159-f2869780-9e84-11ea-926d-921f702b59e5.png)  

### ダウンロードできない場合
Sitecore 9.xでかつIdentity Serverを有効化していると、ボタンを押してもダウンロードされないことがあります。その場合は、以下のconfigを有効化するとダウンロードできるようになるはずです。

- `/App_Config/Include/Cognifide.PowerShell.IdentityServer.config.disabled`

## 参考
- [Community - Sitecore PowerShell Extensions](https://doc.sitecorepowershell.com/community)
Feeling stagnated at this point in my career.
Tags: career, webdev, engineering
Published: 2020-05-25 03:42:56

---
cover_image: https://www.meme-arsenal.com/memes/4294ad7ac6c2c89d71221840c2be5ce5.jpg
title: Feeling stagnated at this point in my career.
published: true
description: When did you start to feel unchallenged at your job?
tags: career, webdev, engineering
---
### When did you start to feel unchallenged at your current job?

First let me give you some background about me:

I'm a software engineer that's been in this industry for 6 years now, with experience in the good and bad stuff that comes with the profession and I've had the luck of meeting really smart, talented people whose brilliance as human beings always gave me the courage to try harder and keep searching for challenges all the time.

![spongebob](http://images4.fanpop.com/image/photos/19600000/SpongeBob-Photo-happy-square-sponge-19621591-640-360.jpg)

I've been working as a software engineer for a year and a half at "Big Company X". I started doing fullstack software development (JS mostly) and infrastructure engineering (Linux, AWS and containers), then moved to a SW Integrator position inside the company due to my project being canceled by external factors. It sounded good at first glance since the responsibilities were almost identical to a devops engineer position but slowly degraded into just calling people to coordinate efforts during each release and now there is no technical challenge and the position feels dull and without room for growth.

![dull-boy](https://i.imgur.com/ytL0ico.gif)

I did find some solace with some junior colleagues that by their own volition asked me to mentor them which I'm deeply grateful for. You never realize you know something until you start teaching someone about it. There they are, all eager to learn from you, with hopes and expectations about the world you'll unravel before their eyes. It's a heavy but gratifying experience.

I know I'm just ranting at this point so I just wanted to hear if you ever felt this way too. Did you change jobs? How did your situation improve?

Thanks for reading :)
Which hosting do you use? 
Tags: webdev, aws, javascript, discuss
Published: 2020-05-25 03:35:06

Hey Pal! Just wanted to know which hostings do you use? 

- [AWS Amazon Web Services](https://aws.amazon.com/)
- [Linode](https://www.linode.com/)
- [Bluehost](https://bit.ly/2XxlKY2)
- Google Cloud Engine
- Firebase
- Azure
- Digital Ocean
- Heroku

Which one do you prefer?
Tech your computer to play chrome dino game
Tags: tensorflow, chromedinogame
Published: 2020-05-25 02:47:22

---
title: Tech your computer to play chrome dino game
published: true
description: A simple neural net to play chrome offline dino game.
tags: TensorFlow, chrome dino game, 
cover_image: https://github.com/FabianBG/dinoplayer-neuralnet/blob/master/docs/dino1.png?raw=true
---

# Intro
As an AI fanatic I decide to do a simple neural net to learn more about TensorFlow so I do a neural net which plays the offline chrome dino game, It a very simple approach than it is not the best and perfect but as a starter, point to learn AI, it is a funny way to do it.

# The project
For the common AI learning agents actually exist a lot of playgrounds (like GYM [https://gym.openai.com/]) which simplify the way you interact with the game, the playgrounds can be paused and played frame by frame which is very helpful, it has a lot of useful data of each frame of the game such as rewards and game status. But For this I want to make it from a very scratch. So I choose to do it with the famous dino game.

The project is coded in Python3, to get the actual state of the game it takes screenshots of the chrome window and has a controller for the keyboard to trigger the keypress. It is not a deep reinforcement learning approach, it is more like a supervised approach because first of all I played the game to generate the data then this data is fed to the neural net and finally is used to play.

For the inpatients, the source code is on GitHub [https://github.com/FabianBG/dinoplayer-neuralnet]

# Usage

First of all download the code and open google chrome on [crome://dino].

Then in the folder of the code execute the next command:

`python3 main.py preview` 

It shows the preview of the area in which the code takes the screenshoots so move the navigator with the game to fit the preview.

![preview](https://github.com/FabianBG/dinoplayer-neuralnet/blob/master/docs/dino1.png?raw=true)


When the screenshot area is set, use this command to generate the train data:

`python3 main.py gen-data`

To start recording data *press the key i*, and to stop *key e*, finally to save the data on the preview window press the *key q*.

It will generate a *data-train.pkl* file on the source. This contains the train data for your model.

Next step is to train the model, so just exec:
`python3 main.py train`

![train](https://github.com/FabianBG/dinoplayer-neuralnet/blob/master/docs/dino2.png?raw=true)

When all the train is done it saves a *model.tf* file which has the trained model.

Finally, to see how it does, execute
`python main.py predict`

And to start predicting press *press the key i* start the game and let the computer tries to do its best.

![sample](https://github.com/FabianBG/dinoplayer-neuralnet/blob/master/docs/dino3.gif?raw=true)

The net can be improved just modify the file *model.py* it has the net definition.
Building Intergenerational Games
Tags: blockchain, architecture, ai, ar
Published: 2020-05-25 02:28:51

Salvete Gamers, AIers, and DLTers!

The communication and interest gulfs between 3 year olds, 30 year olds, and 60 year olds is well attested across cultures and time. The perspective and need differences of each age fully highlights the nearly impossible task of building intergenerational games. As we age, grow, and learn from our experiences, our tastes change. Likewise, some tastes never change, rather they solidify into our preferences. 

## The Questions
1. What if we had a gaming system that took changing interests and lifelong preferences into account, aged with the player, used AI to track and maintain game progress, and blockchain to reward player efforts with skill certificates and cryptocurrency? 

2. Would you play the game? 

3. How do we design an intergenerational, cradle-to-grave software experience, when Moore's Law laughs in the face of last year's obsolete techs?


### How do we do it? 
_Let AI tailor the gaming experiences to each age, preference, and skill level._ 

We must understand the motivations of each age group; and then, create the game to level as they age. Natural age transitions should be based on individual progress as well as on age averages. Player performance tracked by an AI can control transitions. The longevity of the AI's stack can't be guaranteed, as such, it seems a modular system would be preferable. 

Player interests are proven through player actions. As players focus their in-game attention on doing quest actions, they'll receive blockchain rewards upon completing the quest. As they pass the levels, they receive XP, HP, and Geld. And, as they pass the quests they receive bonus multipliers and random loot boxes. 

### More Questions
1. Will the different age groups require different reward types?  

2. Since the levels are determined by doctors and completed by their potential patients, do the rewards even matter when we're talking about access to healthcare? 

I'll leave you with that last question to ponder. 
Vale, 
Monique