00_ReactPassingDataBetweenParentAndChild.md

Reactの親子コンポーネントにおける情報の受け渡し

親コンポーネント→子コンポーネント:Props

子コンポーネント→親コンポーネント:State

169. Majority Element

Divide and Conquer && vote
class Solution {
    public int majorityElement(int[] nums) {
        int count = 0;
        int candidate = 0;
        
        for(int num : nums) {
            if(count == 0) {
                candidate = num;
            }
            
            if(candidate == num) {
                count++;
            } else {
                count--;
            }
        }
        
        return candidate;
    }
}

00_ReactEventPooling.md

- https://reactjs.org/docs/events.html#event-pooling
- https://ja.reactjs.org/docs/events.html#event-pooling

cf.
- [イベントプーリング](https://react.keicode.com/basics/event-pooling.php)
- [シンセティックイベントとは](https://react.keicode.com/basics/synthetic-events.php)

ClipboardHelper.cs UI Triks

 using UnityEngine;
 using System;
 using System.Reflection;
 
 public class ClipboardHelper
 {
     private static PropertyInfo m_systemCopyBufferProperty = null;
     private static PropertyInfo GetSystemCopyBufferProperty()
     {
         if (m_systemCopyBufferProperty == null)
         {
             Type T = typeof(GUIUtility);
             m_systemCopyBufferProperty = T.GetProperty("systemCopyBuffer", BindingFlags.Static | BindingFlags.NonPublic);
             if (m_systemCopyBufferProperty == null)
                 throw new Exception("Can't access internal member 'GUIUtility.systemCopyBuffer' it may have been removed / renamed");
         }
         return m_systemCopyBufferProperty;
     }
     public static string clipBoard
     {
         get 
         {
             PropertyInfo P = GetSystemCopyBufferProperty();
             return (string)P.GetValue(null,null);
         }
         set
         {
             PropertyInfo P = GetSystemCopyBuffer

Rebase commit

$ git log  # take A commit_id
$ git rebase -i "A_commit_ID" # do an interactive rebase
$ change commit to 'e' in rebase vim # means commit will be editet. Enter edit mode and replace "pick" with "e"
$ git rm unwanted_file
$ git rebase --continue
$ git push --force-with-lease <branchName>    

00_ReactBindThis.md

Reactでthisのバインドの方法

コンストラクター内でbindする方法に統一するのがおすすめ

137. Single Number II

位运算方法不会
/*
求和再做差
*/

class Solution {
  public int singleNumber(int[] nums) {
    Set<Long> set = new HashSet<>();
    long sumSet = 0, sumArray = 0;
    for(int n : nums) {
      sumArray += n;
      set.add((long)n);
    }
    for(Long s : set) sumSet += s;
    return (int)((3 * sumSet - sumArray) / 2);
  }
}

136. Single Number

XOR
/*
XOR:
  1. a ^ b = b ^ a
  4. a ^ a = 0.
  5. 0 ^ a = a.
*/

class Solution {
    public int singleNumber(int[] nums) {
        int res = 0;

        int len = nums.length;
        for(int i = 0; i < len; i++)
            res ^= nums[i];

        return res;

    }
}

img vertical and horizontal center

    <div text-center style="vertical-align: middle;">
      <img src="../../assets/imgs/nuuruddin-white.png" style="position:absolute;
      left: 0;
      right: 0;
      margin:0 auto;
      top:50%;
      max-width: 40%;
      transform:translateY(-50%);"/>
    </div>

123. Best Time to Buy and Sell Stock III

经典,多理解
/*
理解思路和The order of maxProfit2, lowestBuyPrice2, maxProfit1, lowestBuyPrice1
lowestBuyPrice2 = min(p - maxProfit1[high] + maxProfit1[low])
*/


class Solution {
	public static int maxProfit(int [] prices){
	    int maxProfit1 = 0; 
	    int maxProfit2 = 0; 
	    int lowestBuyPrice1 = Integer.MAX_VALUE;
	    int lowestBuyPrice2 = Integer.MAX_VALUE;
	   
	    for(int p:prices){
	    	maxProfit2 = Math.max(maxProfit2, p - lowestBuyPrice2);
            // lowestBuyPrice2 = min(p - maxProfit1[high] + maxProfit1[low])
	    	lowestBuyPrice2 = Math.min(lowestBuyPrice2, p - maxProfit1);
	    	maxProfit1 = Math.max(maxProfit1, p - lowestBuyPrice1);
	    	lowestBuyPrice1 = Math.min(lowestBuyPrice1, p);
	    }
	    return maxProfit2;
    }
}

awr_generator

--  AWR-Generator.sql: Script for creating multiple consecutive Oracle AWR Reports
--                     Creates an output SQL script which, when run, will generate
--                     all AWR Reports between the specificed start and end snapshot
--                     IDs, for all instances
--
--  See GitHub repository at https://github.com/flashdba/scripts
--
--  ###########################################################################
--  #                                                                         #
--  # Copyright (C) {2014,2015}  Author: flashdba (http://flashdba.com)       #
--  #                                                                         #
--  # This program is free software; you can redistribute it and/or modify    #
--  # it under the terms of the GNU General Public License as published by    #
--  # the Free Software Foundation; either version 2 of the License, or       #
--  # (at your option) any later version.                 

Serve static HTML

# https://www.npmjs.com/package/servor
# https://parceljs.org/getting_started.html

Init NPM project

# init project creating package.json
npm init

# init project and not make questions
npm init -y

Mac app icns size list.


```sh
$ mkdir app.iconset
```

```sh
$ iconutil -c icns app.iconset
```


| Filename            | Size   |
|---------------------|--------|
| `icon_512x512@2x.png` | 1024px |
| `icon_512x512.png`    | 512px  |
| `icon_256x256@2x.png` | 512px  |
| `icon_256x256.png`    | 256px  |
| `icon_128x128@2x.png` | 256px  |
| `icon_128x128.png`    | 128px  |
| `icon_32x32@2x.png`   | 64px   |
| `icon_32x32.png`      | 32px   |
| `icon_16x16@2x.png`   | 32px   |
| `icon_16x16.png`      | 16px   |


 




React - Post data from a form using Axios

import React, { Component } from 'react';
import axios from 'axios';

class NewPost extends Component {
  state = {
    title: "",
    content: "",
    author: "Max",
  };

    postDataHandler = () => {
        const data = {
            title: this.state.title,
            body: this.state.content,
            author: this.state.author
        };
        axios.post("https://jsonplaceholder.typicode.com/posts", data)
            .then(response => {
                console.log(response)
            });
    };

  render() {
    return (
      <div className="NewPost">
        <h1>Add a Post</h1>
        <label>Title</label>
        <input
          type="text"
          value={this.state.title}
          onChange={(event) => this.setState({ title: event.target.value })}
        />
        <label>Content</label>
        <textarea
          rows="4"
          value={this.state.content}
          onChange={(event) => this.setState({ content: event.target.value })}
        />
        <label>

Stress using docker

#### Run the docker image

```
docker run --rm -it progrium/stress -m 20  --timeout 1440s
```