Multi dimension in_array function

function in_array_r($needle, $haystack, $strict = false) {
    foreach ($haystack as $item) {
        if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) {
            return true;
        }
    }

    return false;
}

jupyter_lab_install

Saved from https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html

# PIP
pip install jupyterlab



# PIPENV
pipenv install jupyterlab
pipenv shell
jupyter lab   # to run
pipenv run jupyter lab  # alternative run install

woocommerce ödeme sayfası field ayarlama

// Disable zip/postcode field
add_filter( 'woocommerce_checkout_fields' , 'QuadLayers_remove_billing_postcode_checkout' );
function QuadLayers_remove_billing_postcode_checkout( $fields ) {
unset($fields['billing']['billing_postcode']);
return $fields;
}
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
     unset($fields['billing']['billing_country']);
	 $fields['billing']['billing_address_1']['placeholder'] = 'Mahalle/Sokak/Site';
     $fields['billing']['billing_address_1']['label'] = 'Adres';
	 $fields['billing']['billing_address_2']['placeholder'] = 'Apartman/Kat/Daire';
	 $fields['billing']['billing_email']['placeholder'] = 'E-Posta';
	 $fields['billing']['billing_email']['label'] = 'E-Posta';
     return $fields;
}

add_filter( 'woocommerce_checkout_fields', 'bbloomer_set_checkout_field_input_value_default' );
 
function bb

Closure

# CLOSURE
(Kyle Simpson Deep JS Foundations)

`Closure` is when a function "remembers" its lexical scope even when the function is executed outside that lexical scope.

```
function foo() {
  var bar = "bar";

  function baz() {
    console.log(bar);
  }

  bam(baz);
}

function bam(baz) {
  // This is executed in entirely different scope than where it was declared
  // baz() still had the access to the bar variable - this is closure
  baz();  // "bar"
}

foo();
```

Passing functions as callbacks is not the only way to do so. You can also return functions

That inner function is closed over that variable which is going to perserv that variable.

```
function foo() {
  var bar = "bar";

  return function() {
    console.log(bar)
  };
}

function bam() {
  foo()();   // "bar"  ()() is because there is no name on returned function
}

bam()
```

To unset the closure, you just get rid off the reference to the function that has the closure. That could be unbinding the event handler if that 

relation 없는 테이블 조인

this.rep.createQueryBuilder('user')
      .leftJoinAndSelect(Address, 'address', 'user.addressId = address.id')
      .getOne();

login required django

from django.contrib.auth.decorators import login_required
@login_required

SQL Repclication Fix

Fixes SQL Server replication after a restore of the DB breals the agent.
exec sp_repldone @xactid = NULL, @xact_seqno = NULL, @numtrans = 0, @time = 0, @reset = 1

exec sp_replflush

Lamda function in Kotlin

##  Lamda Function in Kotlin
```
fun main(){
    val names = listOf<String>("Java","Dart", "Tareq") //how a list can be declared

  //here where is a custom Lamda function
   val temp = names.where {
       it.length==4 //in kotlin we don't need return, last line will be auto returned
   }.toList()

    print(temp)
}

//custom lamda function 
fun List<String>.where(myCallback: (String) -> Boolean) : List<String>{

   val temp = mutableListOf<String>()

    this.forEach{
          if(  myCallback(it)) temp.add(it)
    }
    return  temp
}
```
### It would print: Java Dart

![](https://cdn.cacher.io/attachments/u/397rshf2ej0sc/0lKrT7697E_wpQKLoCOOUvGKi2gEdcw3/zlle36btj.png)

Webpack config

# Webpack
https://www.youtube.com/watch?v=MpGLUVbqoYQ&feature=youtu.be

Code and commits: https://github.com/Colt/webpack-demo-app

### Basic config
```js
// webpack.config.js
module.exports = {
    entry: "...",
    output: {
        filename: "main.[contentHash].js",
        path: path.resolve(__dirname, "dist"),
    },
    mode: "development",
    devtool: "none", // unwrap the produced eval code
    module: {
        // ...
    }
}
```

### Loaders
```js
// webpack.config.js
module.exports = {
    // ...
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    'style-loader', // step 2: inject styles into DOM as <style> tags
                    'css-loader', // step 1: import css as a commonJS module
                    'sass-loader' // step 1: turns sass/scss into css
                ]
            },
            {
                test: /\.html$/,
                use: [ "html-loader" ] // <img src="imge.png"> --> requir

SaveManager.cs

using UnityEngine;
using MessagePack;
using System;
using System.IO;
using MessagePack.Resolvers;

namespace Yumineko.MessagePackSave.Sample
{
    public static class SaveManager
    {
        private static readonly string filePath = Application.dataPath + "/SaveData.bin";
        public static SaveData MySaveData { get; private set; } = new SaveData();

        /// <summary>
        /// Dataをファイルに保存する
        /// </summary>
        public static bool Save()
        {
            var serialized = MessagePackSerializer.Serialize(MySaveData);
            try
            {
                File.WriteAllBytes(filePath, serialized);
                return true;
            }
            catch(Exception e)
            {
                Debug.Log(e);
                return false;
            }
        }

        /// <summary>
        /// ファイルを読み込み、Dataに格納する
        /// </summary>
        /// <returns></returns>
        public static bool Load()
        {
 

ResolverRegister.cs

/*------------------------------------------------------------------------------
 リゾルバーの登録
------------------------------------------------------------------------------*/
[RuntimeInitializeOnLoadMethod (RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void Initialize () {
    StaticCompositeResolver.Instance.Register (
        GeneratedResolver.Instance,
        MessagePack.Unity.UnityResolver.Instance,
        BuiltinResolver.Instance,
        AttributeFormatterResolver.Instance,
        PrimitiveObjectResolver.Instance,
        StandardResolver.Instance
    );

    var option = MessagePackSerializerOptions.Standard.WithResolver (StaticCompositeResolver.Instance);
    MessagePackSerializer.DefaultOptions = option;
}

Load.cs

using UnityEngine;
using MessagePack;
using System;
using System.IO;
    
/// <summary>
/// ファイルを読み込み、Dataに格納する
/// </summary>
/// <returns></returns>
public static (bool, SaveData) Load()
{
    try
    {
        var filePath = Application.dataPath + "/SaveData.bin";
        var fileData = File.ReadAllBytes(filePath);
        var deserialized = MessagePackSerializer.Deserialize<SaveData>(loadData);
        return (true, deserialized);
    }
    catch(Exception e)
    {
        Debug.Log(e);
        return (false, null);
    }
}

TS Enum Keys


enum Color {
    Red = "RED",
    Green = "GREEN"
}
function enumKeys<O extends object, K extends keyof O = keyof O>(obj: O): K[] {
    return Object.keys(obj).filter(k => Number.isNaN(+k)) as K[];
}
function log(value: Color) {
    console.log(`Value: ${value}`);
}

for (const value of enumKeys(Color)) {
    console.log(value+" " +Color[value])
}

Save.cs

using UnityEngine;
using MessagePack;
using System;
using System.IO;

/// <summary>
/// Dataをファイルに保存する
/// </summary>
public static bool Save()
{
    SaveData saveData = new SaveData();
    
    var serialized = MessagePackSerializer.Serialize(saveData);
    var filePath = Application.dataPath + "/SaveData.bin";
    
    try
    {
        File.WriteAllBytes(filePath, serialized);
        return true;
    }
    catch(Exception e)
    {
        Debug.Log(e);
        return false;
    }
}

SaveData.cs

using MessagePack;
using System;

namespace Yumineko.MessagePackSave.Sample
{
    [MessagePackObject]
    public class SaveData
    {
        [Key(0)]
        public InputFieldData InputField = new InputFieldData();

        [Key(1)]
        public MetaData Meta = new MetaData();
        
        /// <summary>
        /// 入力フォームの情報
        /// </summary>
        [MessagePackObject]
        public class InputFieldData
        {
            
            /// <summary>
            /// 入力されたテキスト
            /// </summary>
            [Key(0)]
            public string InputText;
        }
        
        /// <summary>
        /// セーブファイル自身の情報
        /// </summary>
        [MessagePackObject]
        public class MetaData
        {
            /// <summary>
            /// セーブした時刻
            /// </summary>
            [Key(0)]
            public DateTimeOffset SavedTime;
        }

    }
}

Datetime Module

# Special Features: - Get the current timestamp. - Display info about the time zone. - Display the datetime by giving the function a formatted string **Continent/City** using new ZoneInfo module. - Transform a datetime from a time zone to an another. - ZoneInfo gets its time zone information from an IANA database installed on your computer. -If you want to use this module without errors install tzdata with : **python -m pip install tzdata** - If you want to use this in Python versions anterior to 3.9 use the following command: python -m pip install backports.zoneinfo ![](https://cdn.cacher.io/attachments/u/3d66b3pypor7b/ittidYtYHFyCnfBQ-U8aTsZJNHuHUydP/26a6y97hj.png)
from datetime import datetime, timezone
from zoneinfo import ZoneInfo

print(datetime.now())
# Returns the current time (timestamp) called naive datetime
# 2020-11-29 12:23:31.628196

print(datetime.now(tz=timezone.utc))
# returns an associated timezone, utc here
# 2020-11-29 11:26:20.152661+00:00

ZoneInfo(key="Europe/Oslo")
# access you computer time zone database

# You can do the same with the previous function by specifying the time zone in a string format Continent/City/
print(datetime.now(tz=ZoneInfo("Europe/Paris")))
# 2020-11-29 18:59:47.331929+01:00