client-go

package main

import (
	"fmt"
	metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/clientcmd"
	"os"
)

func main() {

	// Location of kubeconfig file
	kubeconfig := os.Getenv("HOME") + "/.kube/config"

	// Create a Config (k8s.io/client-go/rest)
	config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
	if err != nil {
		panic(err.Error())
	}

	// Create an API Clientset (k8s.io/client-go/kubernetes)
	clientset, err := kubernetes.NewForConfi

Webシステムの脆弱性攻撃手法まとめ

# XSS (Cross-Site Scripting)

# CSRF (Cross-Site Request Forgeries)

# SQLインジェクション (SQL Injection)

# セッションハイジャック (Session Hijacking)

# ディレクトリ・トラバーサル (Directory Traversal)

# 参考記事

[ウェブアプリケーションとセキュリティ実装](https://qiita.com/Morinikiz/items/40433c41a0dffc6d7a46)  
[Webサービス実装時に注意したい脆弱性](https://qiita.com/takamisa/items/8cade6d794b46c50f1b2)  

df -h

```
df -h
```

オブジェクトをマージする

const ANIMATION_DEFAULTS = {
  duration: 10000,
  updateInterval: 200,
  endHold: 1500
};

function startAnimation(options = {}) {
  const { duration, updateInterval, endHold } = { ...ANIMATION_DEFAULTS, ...options };
  console.log(duration, updateInterval, endHold); // 30000 1000 1500
}

startAnimation({ duration: 30000, updateInterval: 1000 });

for

const arr = ['one', 'two', 'three'];

for (const a of arr) {
  console.log(a);
}

PHP

<p><?php $content = get_the_content(); $content = strip_shortcodes( $content ); echo wp_trim_words($content, 58, '...');?></p>

Refresh Pivot Cache

Sub RefreshPivotCache()
    Dim ws As Worksheet
    Dim PT As PivotTable

    For Each ws In ActiveWorkbook.Worksheets '<~~ Loop all worksheets in workbook
        For Each PT In ws.PivotTables        '<~~ Loop all pivot tables in worksheet
            PT.PivotCache.Refresh
        Next PT
    Next ws
End Sub

構造体 スライス struct slice

構造体 スライス struct slice
package main

import "fmt"

// 構造体
// スライス

type Person struct {
	Name string
}

type Persons struct {
	Persons []*Person
}

func main() {
	ps := make([]Person, 5)
	fmt.Println(ps)

	ps[0].Name = "Mike"
	ps[1].Name = "John"
	ps[2].Name = "Nina"
	ps[3].Name = "Bob"
	ps[4].Name = "Nancy"

	fmt.Println(ps)

	// appendで追加する
	p1 := Person{"Mike"}
	p2 := Person{"John"}
	p3 := Person{"Nina"}
	p4 := Person{"Bob"}
	p5 := Person{"Nancy"}

	ps2 := Persons{}
	ps2.Persons = append(ps2.Persons, &p1, &p2, &p3,

add multiple lines of css at once while using dev tool

//add multiple lines of css at once while using dev tool
//put this in dev console
(function(){
    let style = `<style>
/* your style here */
body {
  display: none;
}
</style>`;
  document.head.insertAdjacentHTML("beforeend", style);
})();

Enumerate set counter

\begin{enumerate}
  \setcounter{enumi}{4}
  \item fifth element
\end{enumerate}

git-bash-vim.md


[Source](http://www.fprintf.net/vimCheatSheet.html "Permalink to Vim Commands Cheat Sheet")

# Vim Commands Cheat Sheet

* * *

## How to Exit

:q[uit]
Quit Vim. This fails when changes have been made.

:q[uit]!
Quit without writing.

:cq[uit]
Quit always, without writing.

:wq
Write the current file and exit.

:wq!
Write the current file and exit always.

:wq {file}
Write to {file}. Exit if not editing the last

:wq! {file}
Write to {file} and exit always.

:[range]wq[!]
[file] Same as above, 

Instagram Story Loading Animation

Run in playground: PlaygroundPage.current.liveView = ViewControllerWithLoader()
import UIKit

class ViewControllerWithLoader : UIViewController {
    var fromColor: UIColor = UIColor(red: 138.0 / 255, green: 59.0 / 255, blue: 184.0 / 255, alpha: 1)
    var toColor: UIColor = UIColor(red: 205.0 / 255, green: 71.0 / 255, blue: 107.0 / 255, alpha: 1)
    var ringWidth: CGFloat = 8
    var duration: TimeInterval = 4.5
   
    override func loadView() {
        let rootView = UIView(
            frame: CGRect(x: 0.0, y: 0.0, width: 300.0, height: 300.0)
        )
        rootVie

Primary Keys on AOE

SET @table = 'wp_[tablename]';
SET @newtable = 'wp_[tablename]_COPY';

SET @create = CONCAT(
  'CREATE TABLE ', @newtable ,' (
    [script for table columns here]
  )'
);

PREPARE create1 FROM @create;
EXECUTE create1;

SET @copy = CONCAT('
	INSERT INTO ', @newtable ,
	' SELECT * FROM ' , @table
);

PREPARE copy1 FROM @copy;
EXECUTE copy1;

SET @pk = CONCAT('
	ALTER TABLE ' , @newtable ,
 	' ADD id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
');

PREPARE pk1 FROM @pk;
EXECUTE pk1;

SET 

Safe JS-initiated animation to a final persisted keyframe

/** 
 * This is a better alternative to using 'forwards'
 * fill mode, as it allows you to update inline styles
 * after the animation has completed. Contrast with:
 * 
 * element.animate({
 *   { opacity: '0.2' },
 *   {
 *     duration: 500,
 *     easing: 'ease-in-out',
 *     fill: 'forwards',
 *   }, 
 * });
 * 
 * element.style.opacity = '1'; // never applied
 */
function animateTo(element, keyframes, options) {
  const anim = element.animate(
    keyframes,
    { ...options, fill: 'both' 

Our Approach

---

- entity: 'media'
  bundle: 'image'
  title: 'IG Living Plan'
  status: 1
  uuid: b619b3e5-b177-4bb1-ad0b-4ff46dd1c319
  # Rich text fields contain multiple keys that must be provided.
  field_image:
    # To lookup and add files we'll need to use a different callback function.
    - '#process':
        # In this case we're looking up a file, so we'll use the `file` callback.
        callback: 'file'
        args:
          # Our first argument is, again, the bundle of the entity type.
    

Hide Shipping Fields Based on Shipping Method (Select Box Edition)

1. Get the available shipping methods 2. If the chosen method is "local pickup" at cart, fadeout the shipping fields at checkout 3. On change during checkout, if chosen method is "local pickup", fadeout shipping fields 4. If the only option available (AKA hidden) is "local pickup", fadeout shipping fields

function disable_shipping_local_pickup( $available_gateways ) {
    
   // Part 1: Hide shipping based on the static choice @ Cart
 
   $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
   $chosen_shipping = $chosen_methods[0];
   if ( 0 === strpos( $chosen_shipping, 'local_pickup' ) ) {
   ?>
      <script type="text/javascript">
         jQuery('#customer_details .woocommerce-shipping-fields').fadeOut();
      </script>
   <?php  
   } 
 
   // Part 2: Hide shipping based on