teleren/devto huggingface dataset:
Cambiar color de la barra de estado en vim
Tags: vim
Published: 2020-03-26 05:53:09

---
title: Cambiar color de la barra de estado en vim
published: true
description: Modificar el color de la barra 
tags: vim
---

Cuando dividimos la ventana en `vim` se puede cambiar el color de _la barra de estado_.
![gvim split color original](https://dev-to-uploads.s3.amazonaws.com/i/4szp5kxbxhyi1vkis3yv.png) ![vim split color original](https://dev-to-uploads.s3.amazonaws.com/i/snx2h9sjy122e3plr1ng.png)

Con eso se usa, respectivamente en `gvim` y `vim` 
```vim
<esc>:highlight StatusLine guibg=red guifg=yellow
<esc>:highlight StatusLine ctermbg=red ctermfg=yellow
```
![gvim split color nuevo](https://dev-to-uploads.s3.amazonaws.com/i/3ppmmnrmwjo3rz8vjgsy.png) ![vim split color nuevo](https://dev-to-uploads.s3.amazonaws.com/i/7qnujsovjdpjj2hhpvn2.png)

Ahora, para cambiar la barra de la sección que no esta en uso.
```vim
<esc>:highlight StatusLineNC guibg=magenta guifg=cyan
<esc>:highlight StatusLineNC ctermbg=magenta ctermfg=cyan
```
![gvim split color nuevo NC](https://dev-to-uploads.s3.amazonaws.com/i/k7dqqd2ehivs1v4jb31g.png) ![vim split color nuevo NC](https://dev-to-uploads.s3.amazonaws.com/i/sunzhwc6tj9k09txlndx.png)
UnityのWindowsアプリでアプリケーションの再起動処理
Tags: unity3d
Published: 2020-03-26 05:26:07

## 経緯
需要はそんなに多くはないと思うけどメモ
イベント用アプリ等だとオペレータに操作を任せるので何かあったら再起動...の手順があると望ましい。
ただオペレータに再起動のやり方を教えても普段PCを利用していない人の場合だとヒューマンエラーの原因となりかねない( あと見られたくないフォルダがあるとか... )のでゲーム内のUIに再起動ボタンを作成してそれを押下してもらう方法などがよいと思います。

---

## スクリプト

```csharp
using UnityEngine;

namespace sample
{
    public class Sample : MonoBehaviour
    {

        void Start()
        {
        }
        
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Return))
            {
#if UNITY_STANDALONE_WIN
                System.Diagnostics.Process.Start(Application.dataPath.Replace("_Data", ".exe"));
                Application.Quit();
#endif
            }
        }
        
    }
}

```

---

## 解説
このサンプルスクリプトではEnterキーを押下した時にアプリケーションを再起動する。

Application.dataPathは  **[アプリ名]_Data** フォルダまでのパスであるが [アプリ名] の部分は実際の実行ファイルの名前と同一でないとアプリが起動しない( 実行ファイルの名前のみ変更や_Dataフォルダのアプリ名部分の変更を行うとエラーが出て起動しない )為、このパスから自身のアプリケーション名を取得することが可能、ほかにもAssembly.GetEntryAssembly().Location等があるがこちらはUnityではnullが返されたり動作が安定しないので安牌として Application.dataPath から実行ファイル名を取得する方法で実装するのが一番お手軽だろう。
7 Web Application Security Best Practices You Need to Know
Tags: security, webdev, devops, design
Published: 2020-03-26 05:19:54

Web app security is not something that you can bolt on after developing your app, it should be a core part of the app development process. Web applications are by design, available to others and are very much exposed to many potential threats. As such, you need to ingrain security features within each component of your app and make security a part of each phase of the software development lifecycle to ensure that it is safe from threats.

There are several web application security best practices that you can follow to achieve this. These web application security best practices ensure that there are multiple layers of security incorporated in your app and development and testing processes.

In this post, we will list seven of the most important web application security best practices that you should follow to protect your apps from threats. So, let’s take a look at these app security best practices and why they are important.
[Webinar] Demystifying Serverless
Tags: serverless, devops, webinar
Published: 2020-03-26 05:16:57

Hello friends [Cloud Pune](https://www.meetup.com/Cloud-Pune-Meetup) meet up group is organizing webinar on `Demystifying Serverless` on Saturday, March 28, 2020. 

Following will be covered in the webinar:

#### Introduction to Serverless
- Evolution of serverless computing
- Mysteries around Servers
- What is serverless
- Advantage

#### IBM Cloud Serverless Foundation
- functions
- Api Gateway
- Cloudant

#### Serverless Deep Dive :
- Demo

Anyone can join this webinar without any prior knowledge on `Serverless`. 

Please register yourself [here](https://www.meetup.com/Cloud-Pune-Meetup/events/269000217/).
Cleaner Imports in SPFx Projects
Tags: sharepoint, typescript, webpack, spfx
Published: 2020-03-26 05:10:22

SharePoint Framework (SPFx) projects usually consist of multiple web parts, and a variety of shared components, services and utils. This leads to some gnarly imports.

*Welcome to Dot City...*
```typescript
import ThemeColorPicker from "../../../ui-toolkit/components/ThemeColorPicker";
import { cachify } from "../../../utils/cache"
```
I find it very frustrating and disruptive to count folders every time I need a new import! Wouldn't it it be nice if you could just reference files relative to your `/src` folder?

*With 5 minutes of setup, you can get clean imports like this*
```typescript
import ThemeColorPicker from "ui-toolkit/components/ColorPicker/ThemeColorPicker";
import { cachify } from "utils/cache"
```

---

SPFx projects are compiled in 2 steps. 

1. TypeScript turns the `/src/*.ts` files into `/lib/*.js`
2. Webpack bundles `/lib/*.ts` into `/dist/yourproject-bundle.js`

With minor config changes to each tool, we can achieve the `/src` relative imports we desire.

---

## TypeScript Setup

First, update the `tsconfig.json` file at the root of your SharePoint Framework project. Under `compilerOptions`, set `"baseUrl":"src"`.

``` json
{
  ...
  "compilerOptions": {
    "baseUrl": "src",
    ...
   }
}
```

This is a quick change and immediately we can update our imports and see VS Code help us out with path completion.

![VS Code Autocompletion](https://res.cloudinary.com/droopytersen/image/upload/v1585196151/blog/src-rel-import.png)

> Immediately after setting the `baseUrl`, sometimes VS Code will complain about the `src` relative imports. Restarting VS Code usually does the trick.

## Webpack Setup (Gulp)

Because the imports don't start with a `./` anymore, Webpack will think they are `node_modules`. We need to update the Webpack config to setup some `resolve` aliases.

SPFx exposes a way to update the `webpack.config` inside of `gulpfile.js` (at the root of your project).

*Paste this into your `gulpfile.js` somewhere before `build.initialize(gulp)`*
```javascript
build.configureWebpack.mergeConfig({
  additionalConfiguration: (generatedConfiguration) => {
    generatedConfiguration.resolve.alias = {
      // TODO: Setup your aliases here!!
      // -- START OF MY ALIASES (remove them if you copy paste this) --
      "ui-toolkit": path.resolve(__dirname, "./lib/ui-toolkit/"),
      "utils": path.resolve(__dirname, "./lib/utils/"),
      // -- END OF MY ALIASES --
    };
    return generatedConfiguration;
  },
});
```
In the example above, I created two aliases, `ui-toolkit` and `utils`. Both are folders directly under `/src`.

**Gotchas**
- You have to create a separate alias for each folder under `src` that you want to directly reference.
- You need to reference them from `/lib`, not `/src`.


That's it. No more Dot City! 

> BONUS: VS Code's "auto import" feature seems to work better with this setup too.

```typescript
import Filmstrip from "ui-toolkit/components/Filmstrip";
import useAsyncData from "ui-toolkit/hooks/useAsyncData"
import { getTenant } from "utils/spUtils";

```
Developing women developers
Tags: writing, womenintech
Published: 2020-03-26 04:48:43

It has been 8 months into my computer science masters program and I have seen 3 friends switch majors or drop out. 

The only issue I have noticed is that there are not as many women developers. This is not a revolutionary statement and it is heartbreaking to think about. 
People shine when they feel comfortable and valued. The best environment is when humor is welcomed at work.

In a field when there is a lot to live up to in terms of representing women, you tend to think about performing your very best. That your actions may pave the pathway for someone after you. And that your results, define you. 
I also struggle with the image that I am not a developer and the classmates I have are nice enough to work with me because I am the only girl at class. 

Working with male classmates have been alright, they always find humor in work. They work at their best even when they struggle and they do not beat themselves up over it. I find it difficult to laugh along with them when I have this huge invisible baggage on my shoulder. The more I think about the weight, the more I fall behind in class and the cycle is endless. 

I want to love coding, I truly do. I search for inspiring women to look up to in this field. There are many out there, but it just feels like maybe they are the rarity that made it big into the field. That sometimes the odds were with them and they succeeded. I just wish they were more stories from women who began coding and struggled but eventually they are doing fine. Doing just fine sounds truly remarkable at this point because everything in this course seems so daunting. 

This is my first post, unedited, not made to impress anyone but I want it out there. I want it to be the things that I have truly felt being a minority in this field and how lonely it feels 80 percent of the time. I have been 4 years into this field and the feelings do not just fade away, it is only adapted to. 

I hope that someone out there relates to this. And if you do, just know that we will eventually find humor in our work as well. We need to throw the weight off our shoulders and just be free!

We will do just fine.
Why I built a temporary file storage and left the API Public?
Tags: showdev, devjournal, javascript, node
Published: 2020-03-26 05:04:44

---
title: Why I built a temporary file storage and left the API Public?
published: true
description: The story of a simple file storage service that I left for the community to destroy.
tags: showdev, devjournal , javascript, nodejs
---


Now, this isn't a very complex project and anyone who's worked on basic web servers can build this.

## But Why did I build it?

I had this project where I needed to upload images and Firebase's storage was my first alternative, I kept using it but then the storage quota just asked me to go find a better solution, because the moment you upload over 15-20 images you've completed your storage quota and now I'm stuck with a upload code that won't work and I can no longer upload images to Firebase. 

My next alternative was Imgur's API to upload private images but then that limits me to a certain amount of uploads per minute.

And then I started looking for a service that'd allow me to upload images for the sake of testing and then delete those images after a certain threshold time. Sadly, didn't find any or I just sucked at searching. Either way my last search result for this was [file.io](https://file.io) and it was kind off what I wanted but It would delete the file the moment I requested it for the first time. 

So, I ended up building one, for the people who'd like to know what services are being used for this, it's just a combination of Next.JS for the demo page and Node.JS and MySQL for the back-end. All of this is hosted on Heroku's free tier for now, since I'm the only one using it and both Heroku and the db would stop working if someone were to overload the API so that's that. I know it's not a good solution but it works since I'm the only one using it.

## But without any authentication, people are going to use up all your storage! 

I understand that but as of now I'm the only person who knows about it's existence so that's that and if people do start using it, let me know in the comments so I can add up a full fledged API Key based access system for the API and also move it to a Digital Ocean server to increase the storage and also increase each file's time to deletion.

Files uploaded from the demo site have a 30 second life and will be deleted after that.

Here's a link to the [demo](https://tempx.barelyhuman.dev/)
can not install react-native with expo-cli and node npm
Tags: reactnative, react, expocli, expo
Published: 2020-03-26 03:32:27

hey everyone i am new in react and I want to install it in my linux and windows os...but I have a big Problem. npm warn deprecated request@2.88.0 it is Big ERROR.
I can`t install expo-cli or react-native-cli!!!
I now request node package is deprecated and there are some alternative for that like got, axios and etc...
but I can`t and dont know How Can I Replace that with request node package, please help...

when I try to install expo-cli show me npm warn deprecated request@2.88.0...
and then intrupte to downloading...???
how Fix it?
VRMとAR Quick Lookで遊ぼう
Tags: vrm, ar
Published: 2020-03-26 03:32:23

最近Twitterで知人がVRMモデルをusdzに変換して遊んでるのを見かけたので自分もやってみた。
会社で遊んでた際に、ふと「あれ？これ遊びたい人多いと思うけど手順が結構プログラマ向けだな？」と思ったのでわかりやすい記事を書いてみようと思ったので実行（ΦωΦ）

#準備するもの
**Mac**
**対応してるiPhone or iPad**
**VRMデータ**
**AppleID**
**usdz変換ツール**
**usdzをアップする場所**

###VRMの準備
VRoidHubで持ってきたらいいんでない？（ΦωΦ）
https://hub.vroid.com/

###usdz変換ツール
↓ここからDLできるよ入るときAppleID必要だよ（ΦωΦ）
[usdz変換ツール](https://idmsa.apple.com/IDMSWebAuth/signin?appIdKey=891bd3417a7776362562d2197f89480a8547b108fd934911bcbea0110d07f757&path=%2Fdownload%2Fmore%2F%3F%3DUSDPython&rv=1)

![スクリーンショット 2019-10-23 0.05.27.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62400/b0e9be54-7d2d-85a3-68eb-dd94a5674711.png)

0.61のバージョンをDLして来たら適当に解凍しておきましょう。

###VRMモデルを.glbに変換
VRMモデルデータの.vrmを名前変更で.glbに変更してください（ΦωΦ）
![スクリーンショット 2019-10-23 0.11.09.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62400/55c5b7d0-e9ce-d9d3-7c35-9c324926094d.png)

こんな感じね。

そしたらルートの直下にでも置いてください。
ルートがわからないとな？（ΦωΦ）
他のQiitaの記事で「Macの使い方」とか探して勉強して行きましょう（’ΦωΦ）

###usdz変換ツールを使ってusdzに変換
さて、先程ダウンロードして適当なところに解答した変換ツールの中に「USD.command」というのがありますね（ΦωΦ）
![スクリーンショット 2019-10-23 0.17.23.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62400/4211ccb5-3fb5-8c7d-946b-4c64bd9b36f3.png)
これを起動します。
![スクリーンショット 2019-10-23 0.20.46.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62400/471c5e25-8b45-0696-c656-ea350bbbe896.png)

こんな感じのが出てくるので
ここで先程の.glbファイルを変換します。
usdzconvert ****.glb って入れて
![スクリーンショット 2019-10-23 0.24.22.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62400/40627fdf-e85f-e5f4-7575-949151dbb44b.png)

![スクリーンショット 2019-10-23 0.25.30.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62400/13ee1477-5deb-9cfe-f9f7-8d35124bf1d2.png)
Output file　と出てきて
ちゃんと.usdzになったファイルが出てこればOK！（ΦωΦ）

あと、このファイルを自分のサイトに入れるなり
AWSのS３にいれておくなりして手元のiPhoneのSafariから見に行けば〜
<img width="375" alt="AR.jpg" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/62400/ebc1f522-dc5b-d021-f5a1-c9d5a6df36bc.jpeg">

上手にできました〜（ΦωΦ）

興味出た人はfixOpacityでアルファ周り処理したりとか
アニメーションが入った.glb作って見たりとかしてみてく遊んでみてください。

ではでは（ΦωΦ）
Automatically change Go version with `gvm` and `zsh`
Tags: go
Published: 2020-03-26 02:55:43

---
title: Automatically change Go version with `gvm` and `zsh`
published: true
description: 
tags: go
---

`gvm` does not change Go version automatically. This is a little inconvenience when developing multiple projects that use different Go versions. Let's change Go version when moved to the directory of Go project like `rbenv`.
 
## Get Go version

Normally, we don't have a file that described Go version(like `.ruby-version`, `.node-version`). 
But since Go 1.12, `go.mod` includes Go version [1]. This probably the same with the projects' Go version. Let's reuse this.  

This can do as following with `zsh`.

```zsh 
_change_go_version() {
  if [ -f "go.mod" ]; then
    local version=(`grep -Po "^go \K([0-9\.]*)$" go.mod`)
    gvm use ${version}
  fi
}
```   

## Change Go version when directory changed
 
zsh provides some hook functions. One of them, `chpwd` executed whenever the current working directory is changed [2]. This function can use inside `zshrc`. Let's call `_change_go_version` inside this function.

```
# .zshrc
chpwd()
{
  _change_go_version
}
```  

As a result, autosomally call `gvm use` when moved directory that has the `go.mod` file. If you use another version manager, please change `gvm use` inside `_change_go_version`. 

Have a nice day!

[1]:https://github.com/golang/go/issues/28221 
[2]:http://zsh.sourceforge.net/Doc/Release/Functions.html
よく使う正規表現
Tags: gorubyjavascriptpython
Published: 2020-03-26 02:31:26

---
title: よく使う正規表現
published: true
description: 
tags: Go Ruby JavaScript Python 
---

各言語で正規表現のサンプルを書いてみました。

# 正規表現式
* Emailアドレス
`^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$`

* ドメイン名
`^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$`

* インタネットURL
`^(http|https)://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?$`

* ユーザー名 (Twitter username)
`^[a-zA-Z0-9_\-.]{3,15}$`

* 固定電話
`^0\d-\d{4}-\d{4}$`

* 携帯電話
`^(070|080|090)-\d{4}-\d{4}$`

* IP電話
`^050-\d{4}-\d{4}$`

* フリーダイヤル
`^0120-\d{3}-\d{3}$`

* パスワード(大文字小文字英数字組み合わせ、特殊文字禁止、長さは8-10
`^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$`

* 日付 (YYYY-MM-DD)
`^\d{4}-\d{1,2}-\d{1,2}$`

* 郵便番号
`^\d{3}-\d{4}$`

* XML
`^([a-zA-Z]+-?)+[a-zA-Z0-9]+\\.[x|X][m|M][l|L]$`

* 空白行
`\n\s*\r`

* 先頭後尾空白文字
`^\s*|\s*$`

* IPアドレス
`\d+\.\d+\.\d+\.\d+`

* IPアドレス
`((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))`

* 数字
`^[0-9]*$`

* N桁数字
`^\d{n}$`

* N桁以下数字
`^\d{n,}$`

* M-N桁数字
`^\d{m,n}$`

* ゼロから始まる数字
`^(0[0-9]*)$`

* ゼロ以外から始まる数字
`^([1-9][0-9]*)$`

* 小数点以下1-2位数字
`^(\-)?\d+(\.\d{1,2})?$`

* 正整数
`^[1-9]\d*$`

* 負整数
`^\-[1-9]\d*$`

* 英数字
`^[A-Za-z0-9]+$`

* 長さが3-20の全ての文字
`^.{3,20}$`

* 大文字小文字26英字
`^[A-Za-z]+$`

* 大文字26英字
`^[A-Z]+$`

* 小文字26英字
`^[a-z]+$`


# 言語別

### Go

```go
package main

import (
	"fmt"
	"regexp"
)

func main() {
	rep := regexp.MustCompile(`^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$`)
	isEmail := rep.MatchString("dongri@qiita.com")
	fmt.Println(isEmail) // true | false
}
```

### Ruby

```ruby
#!/usr/bin/env ruby

rep = Regexp.new("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$")
isEmail = rep === "dongri@qiita.com"
puts isEmail
```

### JavaScript
```javascript

var regex = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
regex.test("dongri@qiita.com"); // true | false

var regex = new RegExp('^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$');
regex.test("dongri@qiita.com"); // true | false
```

### Perl
```perl

#!/usr/bin/env perl

$rep = '^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$';
$email = 'dongri.@qiita.com';
if ($email =~ /$rep/) {
    print "valid";
} else {
    print "invalid";
}
```

### Python

```py
#!/usr/bin/env python

import re

rep = '^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$';
email = 'dongri@qiita.com';
isEmail = re.match(rep, email) != None;

print(isEmail);
```

### Swift
```swift

import Foundation

let rep = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"
let email = "dongri@qiita.com"
let isEmail = NSPredicate(format: "SELF MATCHES %@", rep).evaluate(with: email)

print(isEmail)
```

### Java
```java
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test {
    public static void main(String[] args) {
        String regex = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
        String email = "dongri@qiita.com";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(email);
        Boolean isEmail = matcher.matches();

        System.out.println(isEmail);
    }
}
```
オフィス周辺にポケモンが現れたら Slack チャンネルに通知するようにした
Tags: coffeescript, pokemongo, slack, hubot
Published: 2020-03-26 02:27:48

---
title: オフィス周辺にポケモンが現れたら Slack チャンネルに通知するようにした
published: true
description: 
tags: CoffeeScript, PokemonGo, Slack, Hubot 
---

タイトル通りにオフィス周辺（半径変更可）にポケモンが現れたらSlackのチャンネルに通知するようにしてみた。

packge.jsonに `pokego-scan` 追加

```
{
  "dependencies": {
    "pokego-scan": "0.1.5"
  }
}
```

pokemon-go.coffee 作ってhubotのscriptsに入れる。

```coffeescript

cronJob = require('cron').CronJob
pokegoScan = require('pokego-scan')

# 自分の環境合わせて設定してください（http://www.latlong.net）
coords = {
    latitude: 35.664134,
    longitude: 139.713854
};

module.exports = (robot) ->
  cronjob = new cronJob('*/5 * * * *', () =>
    channel = room: "#pokemon" # 自分の環境に合わせて変更
    pokegoScan coords, { distance: 50 }, (err, pokemons) ->
      if pokemons != undefined
        message = ""
        pokemons.forEach (pokemon) ->
          message += pokemon.name + "\n"
          message += pokemon.despawns_in_str + "\n"
          message += pokemon.image + "\n"
        if message != ""
          robot.send channel, message
  )
  cronjob.start()
```

<img width="450" alt="Screen Shot 2016-07-26 at 6.00.32 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/15490/ce36534e-9a0d-406c-7e84-a9d2a0e184b9.png">

こんな感じで通知してくれます。
二行目の数字は、ポケモンが消えるまでの時間です。

# その後

<img width="450" alt="Screen Shot 2016-07-26 at 6.00.32 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/15490/ffcedd3c-db24-df39-9057-833390f822bc.png">

# 追記（2016-07-27）

https://github.com/dgoguerra/pokego-scan
https://www.npmjs.com/package/pokego-scan

パッケージと開発がクローズされたみたいです、、、
ちょっと便利なJavaScript技
Tags: javascript
Published: 2020-03-26 02:26:15

---
title: ちょっと便利なJavaScript技
published: true
description: 
tags: Javascript
---

# !!でbool値変換

```js
function Account(cash){
  this.cash = cash;
  this.hasMoney = !!cash;
}

var account = new Account(98);
console.log(account.cash); //98
console.log(account.hasMoney); // true

var emptyAccount = new Account(0);
console.log(emptyAccount.cash); //0
console.log(emptyAccount.hasMoney); // false
```

# +文字列を数値に変換

```js
function toNumber(strNumber){
  return +strNumber;
}

console.log(toNumber("1234")); // 1234
console.log(toNumber("ABC")); //NaN
```

# && 条件式
```js
if (connected){
  login();
}

// ↑の式のを以下のように書ける
connected && login();

// 以下のようにuserオブジェクトの存在チェックにも
user && user.login();
```

# ||でデフォルト値設定
```js
function User(name, age) {
    this.name = name || "Hoge";
    this.age = age || 30;
}
var user1 = new User();
console.log(user1.name); // Hoge
console.log(user1.age); // 30
 
var user2 = new User("Boa", 25);
console.log(user2.name); // Boa
console.log(user2.age); // 25
```

# 配列切断
```js
var array = [1,2,3,4,5,6];
console.log(array.length); // 6
array.length = 3;
console.log(array.length); // 3
console.log(array); // [1,2,3]
```
愛が生まれた
Tags: go, 愛
Published: 2020-03-26 02:25:48

---
title: 愛が生まれた
published: true
description: 
tags: go,愛
---

```go
package main

import "fmt"

func main() {
    fmt.Println(string('生' & '死'))
}
```

ここから確認できます
https://play.golang.org/p/O9tJl8XkDA

解説ありがとうございます！
http://qiita.com/tienlen/items/44daf3a52eb872085556
OSXとGNU系コマンドを揃える
Tags: linux, macosx
Published: 2020-03-26 02:22:53

---
title: OSXとGNU系コマンドを揃える
published: true
description: 
tags: Linux, MacOSX 
---

OSX

```
$ echo `date -d '1 day ago' +"%Y-%m-%d"`
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]

$ echo `date -v-1d +"%Y-%m-%d"`
2014-10-23
$ 
```

Linux

```
$ echo `date -d '1 day ago' +"%Y-%m-%d"`
2014-10-23
$ echo `date -v-1d +"%Y-%m-%d"`
date: invalid option -- 'v'
Try 'date --help' for more information.
```

２つの環境揃えないとosxで書いたのがlinuxサーバーで動かない

```
$ brew install coreutils

All commands have been installed with the prefix 'g'.

If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:

    PATH="/opt/boxen/homebrew/opt/coreutils/libexec/gnubin:$PATH"

Additionally, you can access their man pages with normal names if you add
the "gnuman" directory to your MANPATH from your bashrc as well:

    MANPATH="/opt/boxen/homebrew/opt/coreutils/libexec/gnuman:$MANPATH"

$ echo `gdate -d '1 day ago' +"%Y-%m-%d"`
2014-10-23

$ vim ~/.bashrc
alias date="gdate"
$ source ~/.bashrc

$ echo `date -d '1 day ago' +"%Y-%m-%d"` 
2014-10-23
```
AWS Elastic Beanstalk bash脆弱性への対応
Tags: aws, elasticbeanstalk
Published: 2020-03-26 02:22:12

---
title: AWS Elastic Beanstalk bash脆弱性への対応
published: true
description: 
tags: AWS, ElasticBeanstalk
---
Amazon Linux 2013.09

```
sudo yum install -y http://packages.us-east-1.amazonaws.com/2013.09/updates/cad3d01bf38e/x86_64/Packages/bash-4.1.2-15.18.22.amzn1.x86_64.rpm
```

Amazon Linux 2014.03 / 2014.09

```
sudo yum install -y http://packages.us-east-1.amazonaws.com/2014.09/updates/990a91337efe/x86_64/Packages/bash-4.1.2-15.21.amzn1.x86_64.rpm
```