text:
Q: how to get Kucoin Api Websockets like binance websockets? How to Get KuCoin Api Websockets like Binance Api Websockets?
Actually in Binance Api Websockets when the price will change of a specific coin it will give a message but in Kucoin it is not like that and i cant apply a Strategy also on it?
This is the Binance Websockets Code
async def main(coin):
    bm = BinanceSocketManager(client)
    ts = bm.kline_socket(symbol=coin,interval='1m')
    async with ts as tscm:
        while True:
            res= await tscm.recv()
            candle = res['k']
            close = candle['c']
            if res:
                print(close+coin)
                close = float(close)

This is The Kucoin Websockets Code
async def main():
    global loop

    # callback function that receives messages from the socket
    async def handle_evt(msg):
        if msg['topic'] == '/market/ticker:ETH-USDT':
            print(f'got ETH-USDT tick:{msg["data"]}')

        elif msg['topic'] == '/market/snapshot:BTC':
            print(f'got BTC market snapshot:{msg["data"]}')

        elif msg['topic'] == '/market/snapshot:KCS-BTC':
            print(f'got KCS-BTC symbol snapshot:{msg["data"]}')

        elif msg['topic'] == '/market/ticker:all':
            print(f'got all market snapshot:{msg["data"]}')

        elif msg['topic'] == '/account/balance':
            print(f'got account balance:{msg["data"]}')

        elif msg['topic'] == '/market/level2:KCS-BTC':
            print(f'got L2 msg:{msg["data"]}')

        elif msg['topic'] == '/market/match:BTC-USDT':
            print(f'got market match msg:{msg["data"]}')

        elif msg['topic'] == '/market/level3:BTC-USDT':
            if msg['subject'] == 'trade.l3received':
                if msg['data']['type'] == 'activated':
                    # must be logged into see these messages
                    print(f"L3 your order activated: {msg['data']}")
                else:
                    print(f"L3 order received:{msg['data']}")
            elif msg['subject'] == 'trade.l3open':
                print(f"L3 order open: {msg['data']}")
            elif msg['subject'] == 'trade.l3done':
                print(f"L3 order done: {msg['data']}")
            elif msg['subject'] == 'trade.l3match':
                print(f"L3 order matched: {msg['data']}")
            elif msg['subject'] == 'trade.l3change':
                print(f"L3 order changed: {msg['data']}")

    client = Client(api_key, api_secret, api_passphrase)

    ksm = await KucoinSocketManager.create(loop, client, handle_evt)

    # Note: try these one at a time, if all are on you will see a lot of output

    # ETH-USDT Market Ticker
    await ksm.subscribe('/market/ticker:ETH-USDT')
    # BTC Symbol Snapshots
    await ksm.subscribe('/market/snapshot:BTC')
    # KCS-BTC Market Snapshots
    await ksm.subscribe('/market/snapshot:KCS-BTC')
    # All tickers
    await ksm.subscribe('/market/ticker:all')
    # Level 2 Market Data
    await ksm.subscribe('/market/level2:KCS-BTC')
    # Market Execution Data
    await ksm.subscribe('/market/match:BTC-USDT')
    # Level 3 market data
    await ksm.subscribe('/market/level3:BTC-USDT')
    # Account balance - must be authenticated
    await ksm.subscribe('/account/balance')

    while True:
        print("sleeping to keep loop open")
        await asyncio.sleep(20, loop=loop)

I Have Tried This.
async def main(coin):
    global loop
    async def handle_evt(msg):
        if msg['topic'] == f'/market/candles:{coin}_{timestamp}':
            tickbars = [msg["data"]['candles'],[0, 1, 2, 3, 4, 5, 6]]
            tickdata = pd.DataFrame(tickbars[:-1], columns=['timestamp', 'open', 'close', 'high', 'low', 'TransactionVolume', 'TransactionAmount'])
            tickdata['timestamp'] = pd.to_datetime(tickdata['timestamp'], unit='s')
            bars5m = ex.fetch_ohlcv(f'{coin}', timeframe='5m', limit=284)
            data5m = pd.DataFrame(bars5m[:-1], columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
            data5m['timestamp'] = pd.to_datetime(data5m['timestamp'], unit='ms')

            CurrentTimestamp = tickdata.iloc[-1]['timestamp']
            CurrentOpen = tickdata.iloc[-1]['open']
            CurrentHigh = tickdata.iloc[-1]['high']
            CurrentLow = tickdata.iloc[-1]['low']
            CurrentClose = tickdata.iloc[-1]['close']
            CurrentVolume = tickdata.iloc[-1]['TransactionVolume']

            df2 = pd.DataFrame({'timestamp': [CurrentTimestamp],
                                'open': [CurrentOpen],
                                'high': [CurrentHigh],
                                'low': [CurrentLow],
                                'close': [CurrentClose],
                                'volume': [CurrentVolume]})

            dataFrame = pd.concat([data5m, df2], ignore_index=True, axis=0)

            dataFrame['5_EMA'] = dataFrame['close'].ewm(span=5, adjust=False).mean()
            PreviousOpen = dataFrame.iloc[-2]['open']
            PreviousHigh = dataFrame.iloc[-2]['high']
            PreviousLow = dataFrame.iloc[-2]['low']
            PreviousClose = dataFrame.iloc[-2]['close']
            PreviousEMA = dataFrame.iloc[-2]['5_EMA']

    client = Client(api_key, api_secret, api_passphrase)
    ksm = await KucoinSocketManager.create(loop, client, handle_evt)
    await ksm.subscribe(f'/market/candles:{coin}_{timestamp}')
    while True:
        await asyncio.sleep(20, loop=loop)

So actually I want to apply the strategy on multiple coins that's why i need this i want the kucoin websockets to work as a binance websockets Actually i am a beginner so i have tried a lot plz help me
Like This Strategy i want to apply
import asyncio
import config as C
import pandas as pd
from binance import BinanceSocketManager
from binance.client import Client
import json
import webbrowser
import ccxt
from threading import Thread
import tkinter as tk
import numpy as np
import warnings
from tradingview_ta import TA_Handler, Interval, Exchange
import sys
import pyttsx3
import talib as ta
warnings.filterwarnings('ignore')

api_key = C.BINANCE_API_KEY
api_secret = C.BINANCE_SECRET_KEY
ex = ccxt.binance()
client = Client(api_key, api_secret)

with open("WebSocketsEMA5m.txt", "w") as w:
    w.truncate(0)
    w.close()

#Speak Function
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
# print (voices[0].id)
engine.setProperty('voices', voices[0].id)

def speak(audio):
    engine.say(audio)
    print(audio)
    engine.runAndWait()

async def main(coin):
    bm = BinanceSocketManager(client)
    ts = bm.kline_socket(symbol=coin,interval='15m')
    async with ts as tscm:
        while True:
            res= await tscm.recv()
            candle = res['k']
            close = candle['c']
            if res:
                print(close+' '+coin)
                close = float(close)
                bars5m = ex.fetch_ohlcv(f'{coin}', timeframe='15m', limit=100)
                print(bars5m)
                data5m = pd.DataFrame(bars5m[:-1], columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])

                data5m['RSI'] = ta.RSI(data5m['close'], 14)
                RSI = float(data5m.iloc[-1]['RSI'])

                if RSI > 25 and RSI < 30:
                    webbrowser.open(f"https://in.tradingview.com/chart/qB0Sl3NE/?symbol=BINANCE%3A{coin}")
                    speak("R S I 5 minutes")
                    break

async def run():
    f1 = loop.create_task(main("ZILUSDT"))
    f2 = loop.create_task(main("VETUSDT"))
    f4 = loop.create_task(main("APEUSDT"))
    f5 = loop.create_task(main("FILUSDT"))
    f6 = loop.create_task(main("XRPUSDT"))
    f7 = loop.create_task(main("GALUSDT"))
    f8 = loop.create_task(main("DOGEUSDT"))
    f9 = loop.create_task(main("ADAUSDT"))
    f10 = loop.create_task(main("AVAXUSDT"))
    f11 = loop.create_task(main("GALAUSDT"))
    f12 = loop.create_task(main("ETCUSDT"))
    f14 = loop.create_task(main("HOTUSDT"))
    f15 = loop.create_task(main("EOSUSDT"))
    f17 = loop.create_task(main("TRXUSDT"))
    f18 = loop.create_task(main("FTMUSDT"))
    f19 = loop.create_task(main("SANDUSDT"))
    f20 = loop.create_task(main("LRCUSDT"))
    f21 = loop.create_task(main("JASMYUSDT"))
    f22 = loop.create_task(main("LPTUSDT"))
    f23 = loop.create_task(main("NMRUSDT"))
    f24 = loop.create_task(main("ARPAUSDT"))
    f25 = loop.create_task(main("MDTUSDT"))
    f26 = loop.create_task(main("MDXUSDT"))
    f27 = loop.create_task(main("DFUSDT"))
    f43 = loop.create_task(main("NEARUSDT"))
    f44 = loop.create_task(main("AXSUSDT"))
    f45 = loop.create_task(main("ICPUSDT"))
    f46 = loop.create_task(main("ATOMUSDT"))
    f47 = loop.create_task(main("WAVESUSDT"))
    f49 = loop.create_task(main("MANAUSDT"))
    f50 = loop.create_task(main("MBLUSDT"))
    f51 = loop.create_task(main("SLPUSDT"))
    f52 = loop.create_task(main("CHZUSDT"))
    f53 = loop.create_task(main("THETAUSDT"))
    f54 = loop.create_task(main("RUNEUSDT"))
    f55 = loop.create_task(main("DENTUSDT"))
    f56 = loop.create_task(main("SUSHIUSDT"))
    f57 = loop.create_task(main("IMXUSDT"))
    f58 = loop.create_task(main("PEOPLEUSDT"))
    f59 = loop.create_task(main("ROSEUSDT"))
    f60 = loop.create_task(main("GRTUSDT"))
    f61 = loop.create_task(main("KAVAUSDT"))
    f62 = loop.create_task(main("CRVUSDT"))
    f64 = loop.create_task(main("ONEUSDT"))
    f65 = loop.create_task(main("WINUSDT"))
    f66 = loop.create_task(main("DARUSDT"))
    f67 = loop.create_task(main("XECUSDT"))
    f68 = loop.create_task(main("DYDXUSDT"))
    f69 = loop.create_task(main("OGNUSDT"))
    f70 = loop.create_task(main("GLMRUSDT"))
    f71 = loop.create_task(main("BSWUSDT"))
    f72 = loop.create_task(main("UNIUSDT"))
    f73 = loop.create_task(main("TLMUSDT"))
    f74 = loop.create_task(main("RSRUSDT"))
    f75 = loop.create_task(main("CHRUSDT"))
    f76 = loop.create_task(main("ALGOUSDT"))
    f77 = loop.create_task(main("XLMUSDT"))
    f78 = loop.create_task(main("ALICEUSDT"))
    f79 = loop.create_task(main("CELOUSDT"))
    f80 = loop.create_task(main("RVNUSDT"))
    f81 = loop.create_task(main("SXPUSDT"))
    f82 = loop.create_task(main("NEOUSDT"))
    f83 = loop.create_task(main("MBOXUSDT"))
    f85 = loop.create_task(main("KLAYUSDT"))
    f86 = loop.create_task(main("HBARUSDT"))
    f87 = loop.create_task(main("OMGUSDT"))
    f88 = loop.create_task(main("HIGHUSDT"))
    f89 = loop.create_task(main("TWTUSDT"))
    f90 = loop.create_task(main("HNTUSDT"))
    f91 = loop.create_task(main("MIRUSDT"))
    f92 = loop.create_task(main("ALPHAUSDT"))
    f93 = loop.create_task(main("MASKUSDT"))
    f94 = loop.create_task(main("CELRUSDT"))
    f95 = loop.create_task(main("MINAUSDT"))
    f96 = loop.create_task(main("FIROUSDT"))
    f97 = loop.create_task(main("IOTXUSDT"))
    f98 = loop.create_task(main("QTUMUSDT"))
    f99 = loop.create_task(main("BETAUSDT"))
    f100 = loop.create_task(main("BATUSDT"))
    f101 = loop.create_task(main("ICXUSDT"))
    f102 = loop.create_task(main("SKLUSDT"))
    f103 = loop.create_task(main("VOXELUSDT"))
    f104 = loop.create_task(main("ATAUSDT"))
    f106 = loop.create_task(main("XTZUSDT"))
    f108 = loop.create_task(main("OCEANUSDT"))
    f109 = loop.create_task(main("REEFUSDT"))
    f110 = loop.create_task(main("KDAUSDT"))
    f112 = loop.create_task(main("UNFIUSDT"))
    f113 = loop.create_task(main("RENUSDT"))
    f114 = loop.create_task(main("ANTUSDT"))
    f115 = loop.create_task(main("SYSUSDT"))
    f116 = loop.create_task(main("PAXGUSDT"))
    f117 = loop.create_task(main("API3USDT"))
    f118 = loop.create_task(main("CTXCUSDT"))
    f119 = loop.create_task(main("LITUSDT"))
    f120 = loop.create_task(main("YGGUSDT"))
    f121 = loop.create_task(main("NKNUSDT"))
    f122 = loop.create_task(main("ALPINEUSDT"))
    f123 = loop.create_task(main("RAYUSDT"))
    f124 = loop.create_task(main("RNDRUSDT"))
    f127 = loop.create_task(main("BICOUSDT"))
    f128 = loop.create_task(main("ONTUSDT"))
    f129 = loop.create_task(main("STMXUSDT"))
    f130 = loop.create_task(main("WAXPUSDT"))
    f132 = loop.create_task(main("ZRXUSDT"))
    f134 = loop.create_task(main("MITHUSDT"))
    f135 = loop.create_task(main("IDEXUSDT"))
    f136 = loop.create_task(main("ACAUSDT"))
    f137 = loop.create_task(main("TVKUSDT"))
    f138 = loop.create_task(main("TROYUSDT"))
    f139 = loop.create_task(main("WOOUSDT"))
    f140 = loop.create_task(main("SCRTUSDT"))
    f141 = loop.create_task(main("COCOSUSDT"))
    f142 = loop.create_task(main("XEMUSDT"))
    f143 = loop.create_task(main("FLUXUSDT"))
    f144 = loop.create_task(main("COSUSDT"))
    f145 = loop.create_task(main("OOKIUSDT"))
    f146 = loop.create_task(main("RAREUSDT"))
    f148 = loop.create_task(main("MKRUSDT"))
    f149 = loop.create_task(main("TKOUSDT"))
    f150 = loop.create_task(main("MFTUSDT"))
    f153 = loop.create_task(main("KNCUSDT"))
    f154 = loop.create_task(main("JOEUSDT"))
    f155 = loop.create_task(main("ORNUSDT"))
    f156 = loop.create_task(main("BNTUSDT"))
    f157 = loop.create_task(main("TRUUSDT"))
    f158 = loop.create_task(main("OMUSDT"))
    f159 = loop.create_task(main("RADUSDT"))
    f160 = loop.create_task(main("CVCUSDT"))
    f161 = loop.create_task(main("GTOUSDT"))
    f162 = loop.create_task(main("FISUSDT"))
    f163 = loop.create_task(main("VITEUSDT"))
    f164 = loop.create_task(main("COTIUSDT"))
    f166 = loop.create_task(main("KEYUSDT"))
    f167 = loop.create_task(main("INJUSDT"))
    f169 = loop.create_task(main("FIOUSDT"))
    f170 = loop.create_task(main("ASTRUSDT"))
    f171 = loop.create_task(main("SRMUSDT"))
    f172 = loop.create_task(main("DATAUSDT"))
    f173 = loop.create_task(main("WTCUSDT"))
    f174 = loop.create_task(main("FORUSDT"))
    f175 = loop.create_task(main("BURGERUSDT"))
    f176 = loop.create_task(main("SANTOSUSDT"))
    f177 = loop.create_task(main("DREPUSDT"))
    f178 = loop.create_task(main("HARDUSDT"))
    f179 = loop.create_task(main("DOCKUSDT"))
    f180 = loop.create_task(main("GMTUSDT"))
    f181 = loop.create_task(main("FIDAUSDT"))
    f182 = loop.create_task(main("STORJUSDT"))
    f183 = loop.create_task(main("PHAUSDT"))
    f184 = loop.create_task(main("MCUSDT"))
    f185 = loop.create_task(main("RLCUSDT"))
    f186 = loop.create_task(main("ADXUSDT"))
    f187 = loop.create_task(main("SNXUSDT"))
    f188 = loop.create_task(main("WRXUSDT"))
    f190 = loop.create_task(main("DEGOUSDT"))
    f191 = loop.create_task(main("STRAXUSDT"))
    f193 = loop.create_task(main("CKBUSDT"))
    f194 = loop.create_task(main("LSKUSDT"))
    f195 = loop.create_task(main("POLYUSDT"))
    f197 = loop.create_task(main("POWRUSDT"))
    f198 = loop.create_task(main("CTSIUSDT"))
    f199 = loop.create_task(main("LINAUSDT"))
    f200 = loop.create_task(main("WANUSDT"))
    f201 = loop.create_task(main("CVPUSDT"))
    f202 = loop.create_task(main("MATICUSDT"))
    f203 = loop.create_task(main("PUNDIXUSDT"))
    f204 = loop.create_task(main("FLOWUSDT"))
    f205 = loop.create_task(main("DODOUSDT"))
    f206 = loop.create_task(main("CAKEUSDT"))
    f207 = loop.create_task(main("STXUSDT"))
    f208 = loop.create_task(main("REQUSDT"))
    f209 = loop.create_task(main("ELFUSDT"))
    f213 = loop.create_task(main("PNTUSDT"))
    f232 = loop.create_task(main("TUSDT"))
    f233 = loop.create_task(main("SFPUSDT"))
    f234 = loop.create_task(main("ACHUSDT"))
    f235 = loop.create_task(main("UTKUSDT"))
    f236 = loop.create_task(main("RIFUSDT"))
    f237 = loop.create_task(main("CFXUSDT"))
    f238 = loop.create_task(main("ANKRUSDT"))
    f239 = loop.create_task(main("TCTUSDT"))
    f240 = loop.create_task(main("BLZUSDT"))
    f241 = loop.create_task(main("QIUSDT"))
    f243 = loop.create_task(main("SUNUSDT"))
    f244 = loop.create_task(main("FUNUSDT"))
    f245 = loop.create_task(main("GHSTUSDT"))
    f247 = loop.create_task(main("TFUELUSDT"))
    f248 = loop.create_task(main("TRIBEUSDT"))
    f249 = loop.create_task(main("FLMUSDT"))
    f250 = loop.create_task(main("BELUSDT"))
    f251 = loop.create_task(main("BTCDOWNUSDT"))
    f252 = loop.create_task(main("ETHDOWNUSDT"))
    f253 = loop.create_task(main("ADADOWNUSDT"))
    f254 = loop.create_task(main("DOTDOWNUSDT"))
    f255 = loop.create_task(main("ALPACAUSDT"))
    f256 = loop.create_task(main("DIAUSDT"))
    f262 = loop.create_task(main("FXSUSDT"))
    f263 = loop.create_task(main("GTCUSDT"))
    f264 = loop.create_task(main("TOMOUSDT"))
    f265 = loop.create_task(main("PYRUSDT"))
    f266 = loop.create_task(main("ONGUSDT"))
    f267 = loop.create_task(main("EPXUSDT"))
    f268 = loop.create_task(main("ERNUSDT"))
    f269 = loop.create_task(main("AUCTIONUSDT"))
    f270 = loop.create_task(main("VGXUSDT"))
    f271 = loop.create_task(main("ACMUSDT"))
    f272 = loop.create_task(main("MULTIUSDT"))
    f273 = loop.create_task(main("MOBUSDT"))
    f274 = loop.create_task(main("SCUSDT"))
    f275 = loop.create_task(main("BANDUSDT"))
    f276 = loop.create_task(main("OXTUSDT"))
    f277 = loop.create_task(main("KMDUSDT"))
    f278 = loop.create_task(main("HIVEUSDT"))
    f279 = loop.create_task(main("CTKUSDT"))
    f280 = loop.create_task(main("NEXOUSDT"))
    f281 = loop.create_task(main("IOSTUSDT"))
    f282 = loop.create_task(main("AMPUSDT"))
    f283 = loop.create_task(main("ANCUSDT"))
    f284 = loop.create_task(main("UMAUSDT"))
    f285 = loop.create_task(main("DUSKUSDT"))
    f286 = loop.create_task(main("ATMUSDT"))
    f287 = loop.create_task(main("CITYUSDT"))
    f288 = loop.create_task(main("STPTUSDT"))
    f289 = loop.create_task(main("AKROUSDT"))
    f290 = loop.create_task(main("JUVUSDT"))
    f291 = loop.create_task(main("ENSUSDT"))
    f292 = loop.create_task(main("REIUSDT"))
    f293 = loop.create_task(main("LOKAUSDT"))
    f294 = loop.create_task(main("POLSUSDT"))
    f295 = loop.create_task(main("FRONTUSDT"))
    f296 = loop.create_task(main("PLAUSDT"))
    f297 = loop.create_task(main("AGLDUSDT"))
    f298 = loop.create_task(main("CVXUSDT"))
    f299 = loop.create_task(main("OPUSDT"))
    f300 = loop.create_task(main("SPELLUSDT"))
    f301 = loop.create_task(main("REPUSDT"))
    f302 = loop.create_task(main("SUPERUSDT"))
    f303 = loop.create_task(main("FETUSDT"))
    f305 = loop.create_task(main("AUDIOUSDT"))
    f306 = loop.create_task(main("JSTUSDT"))
    f307 = loop.create_task(main("BTSUSDT"))
    f308 = loop.create_task(main("XVSUSDT"))
    f309 = loop.create_task(main("LUNAUSDT"))
    f310 = loop.create_task(main("PONDUSDT"))
    f311 = loop.create_task(main("BONDUSDT"))
    f312 = loop.create_task(main("PSGUSDT"))
    f313 = loop.create_task(main("AVAUSDT"))
    f314 = loop.create_task(main("BAKEUSDT"))
    f315 = loop.create_task(main("IRISUSDT"))
    f316 = loop.create_task(main("VTHOUSDT"))
    f317 = loop.create_task(main("ASRUSDT"))
    f318 = loop.create_task(main("XVGUSDT"))
    f319 = loop.create_task(main("ARDRUSDT"))
    f320 = loop.create_task(main("PERPUSDT"))
    f321 = loop.create_task(main("AIONUSDT"))
    f322 = loop.create_task(main("PERLUSDT"))
    f323 = loop.create_task(main("NULSUSDT"))
    f324 = loop.create_task(main("BALUSDT"))
    f325 = loop.create_task(main("XNOUSDT"))
    f326 = loop.create_task(main("TRBUSDT"))
    f327 = loop.create_task(main("NBSUSDT"))
    f328 = loop.create_task(main("ARUSDT"))
    f329 = loop.create_task(main("OGUSDT"))
    f330 = loop.create_task(main("FORTHUSDT"))
    f331 = loop.create_task(main("PORTOUSDT"))
    f332 = loop.create_task(main("BTCSTUSDT"))
    f333 = loop.create_task(main("BEAMUSDT"))
    f334 = loop.create_task(main("DEXEUSDT"))
    f335 = loop.create_task(main("LAZIOUSDT"))
    await asyncio.wait([f1,
                        f2,
                        f4,
                        f5,
                        f6,
                        f7,
                        f8,
                        f9,
                        f10,
                        f11,
                        f12,
                        f14,
                        f15,
                        f17,
                        f18,
                        f19,
                        f20,
                        f21,
                        f22,
                        f23,
                        f24,
                        f25,
                        f26,
                        f27,
                        f43,
                        f44,
                        f45,
                        f46,
                        f47,
                        f49,
                        f50,
                        f51,
                        f52,
                        f53,
                        f54,
                        f55,
                        f56,
                        f57,
                        f58,
                        f59,
                        f60,
                        f61,
                        f62,
                        f64,
                        f65,
                        f66,
                        f67,
                        f68,
                        f69,
                        f70,
                        f71,
                        f72,
                        f73,
                        f74,
                        f75,
                        f76,
                        f77,
                        f78,
                        f79,
                        f80,
                        f81,
                        f82,
                        f83,
                        f85,
                        f86,
                        f87,
                        f88,
                        f89,
                        f90,
                        f91,
                        f92,
                        f93,
                        f94,
                        f95,
                        f96,
                        f97,
                        f98,
                        f99,
                        f100,
                        f101,
                        f102,
                        f103,
                        f104,
                        f106,
                        f108,
                        f109,
                        f110,
                        f112,
                        f113,
                        f114,
                        f115,
                        f117,
                        f118,
                        f119,
                        f120,
                        f121,
                        f122,
                        f123,
                        f124,
                        f127,
                        f128,
                        f129,
                        f130,
                        f132,
                        f134,
                        f135,
                        f136,
                        f137,
                        f138,
                        f139,
                        f140,
                        f141,
                        f142,
                        f143,
                        f144,
                        f145,
                        f146,
                        f148,
                        f149,
                        f150,
                        f153,
                        f154,
                        f155,
                        f156,
                        f157,
                        f158,
                        f159,
                        f160,
                        f161,
                        f162,
                        f163,
                        f164,
                        f166,
                        f167,
                        f169,
                        f170,
                        f171,
                        f172,
                        f173,
                        f174,
                        f175,
                        f176,
                        f177,
                        f178,
                        f179,
                        f180,
                        f181,
                        f182,
                        f183,
                        f184,
                        f185,
                        f186,
                        f187,
                        f188,
                        f190,
                        f191,
                        f193,
                        f194,
                        f195,
                        f197,
                        f198,
                        f199,
                        f200,
                        f201,
                        f202,
                        f203,
                        f204,
                        f205,
                        f206,
                        f207,
                        f208,
                        f209,
                        f213,
                        f232,
                        f232,
                        f233,
                        f234,
                        f235,
                        f236,
                        f237,
                        f238,
                        f239,
                        f240,
                        f241,
                        f243,
                        f244,
                        f245,
                        f247,
                        f248,
                        f249,
                        f250,
                        f251,
                        f252,
                        f253,
                        f254,
                        f255,
                        f256,
                        f262,
                        f263,
                        f264,
                        f265,
                        f266,
                        f267,
                        f268,
                        f269,
                        f270,
                        f270,
                        f271,
                        f272,
                        f273,
                        f274,
                        f275,
                        f276,
                        f277,
                        f278,
                        f279,
                        f280,
                        f281,
                        f282,
                        f283,
                        f284,
                        f285,
                        f286,
                        f287,
                        f288,
                        f289,
                        f290,
                        f291,
                        f292,
                        f293,
                        f294,
                        f295,
                        f296,
                        f297,
                        f298,
                        f299,
                        f300,
                        f301,
                        f302,
                        f303,
                        f305,
                        f306,
                        f307,
                        f308,
                        f309,
                        f310,
                        f311,
                        f312,
                        f313,
                        f314,
                        f315,
                        f316,
                        f317,
                        f318,
                        f319,
                        f320,
                        f321,
                        f322,
                        f323,
                        f324,
                        f325,
                        f326,
                        f327,
                        f328,
                        f329,
                        f330,
                        f331,
                        f332,
                        f333,
                        f334,
                        f335,
                        ])

loop = asyncio.get_event_loop()
loop.run_until_complete(run())
loop.close()

# if __name__ == "__main__":
#     loop = asyncio.get_event_loop()
#     loop.run_until_complete(main('ADAUSDT')) and loop.run_until_complete(main('BTCUSDT'))


text:
Q: The private key for code signing is missing The error xCode 5.1.1 is giving me ...
"The private key for code signing is missing".
The problem is the certificate is sitting on my desktop and its already in my keychain. I double clicked it for installation.
It gives me an option to import a profile or "revoke and request." I don't want to revoke a good profile and when I click to import, all the files are greyed out.
Is there a fix for this?

A: 1) In xCode go to xCode-preferances-accounts-view details.
2) look at the status of each certificate
if (certificate status != @"Vaild")
{
1) go to the developer portal and select certificate tab.
2)  delete certificates != @"Valid" status in the certificates.
2a) delete the certificates from keychain if they are there.
3) follow the steps to regenerate and install the certificates by clicking the + button in the certificates section.
4) regenerate the dev and distribution provisioning profiles as needed.
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Error using python doctest I try to use doctest from example from http://docs.python.org/library/doctest.html
But when I run
python example.py -v

I get this
Traceback (most recent call last):
  File "example.py", line 61, in <module>
    doctest.testmod()
AttributeError: 'module' object has no attribute 'testmod'

But I can import doctest in python interactive shell and enable to use doctest.testmod() as well. I searched in google and didn't find the solution.
Python version is 2.5.1 on Max OSX

A: Clearly the doctest module object you have at hand at that point is NOT the normal, unadulterated one you get from an import doctest from the standard library.  Printing doctest.__file__ (and sys.stdout.flush()ing after that, just to make sure you do get to see the results;-) before the line-61 exception will let you know WHERE that stray doctest module is coming from.
If you show us example.py as well as that output we can probably point out what exactly you may be doing wrong, if it doesn't already become obvious to you.

A: Try inserting a
print doctest, dir(doctest)

before line 61. This will tell you the location of the doctest module, and what attributes it has. You can do this to make sure that there's nothing wrong with your doctest module.


text:
Q: Lebesgue measure of a lower-bounded set Let $A \subset (0, 1)$ be a Lebesgue measurable set and let $k > 0$. Suppose that if $0 \leq a < b \leq 1$, then $\mu_L(A \cap (a, b)) \geq k\mu_{L}((a, b))$. Prove that $\mu_L(A) = 1.$
I thought to prove that $\mu_L(A^c)=0$ by covering it by a union of intervals that could be as small as I wanted, but I couldn't do it. I don't think it is a hard one... it just needs some trick I can't think of right now.

A: Let $\varepsilon>0$.  If $\mu_L((0,1)\setminus A)=a$, then there is an open set $U$ with $((0,1)\setminus A)\subseteq U\subseteq (0,1)$ such that $\mu_L(U)<a+\varepsilon$.  Because $U$ is a countable disjoint union of open intervals, your hypothesis implies that $\mu_L(U\cap A)\geq k\mu_L(U)\geq ka$.  But then $a+\varepsilon>\mu_L(U)=\mu_L(U\setminus A)+\mu_L(U\cap A)=\mu_L((0,1)\setminus A)+\mu_L(U\cap A)\geq a+ka$.  This implies that $a<\dfrac{\varepsilon}{k}$.  Because $\varepsilon>0$ was arbitrary, this implies that $a=0$.


text:
Q: Custom Leaflet layer control I have 7 leaflet maps created via loop and data which is exactly the same on each map controlled by a checkbox; however, my plan was to make one layer visible per map. I have searched for a solution where my maps can remain while having one layer per map, but to no avail. I had the idea of keeping one of each layer on by default when the page loads in, but I can't seem to find anything on that either. Does anyone know how to do that? I have left one layer's coordinates in the code Toe_11000 (the "11000 years ago" checkbox) since my coordinates went over the character limit but please let me know if you need clarification. If you need more of the coordinates for the layers, the full code can be found in this JSFiddle: https://jsfiddle.net/wpc6707/3ksjh06p/21/
Here's my code:

var basemapTile =
  "https://stamen-tiles-{s}.a.ssl.fastly.net/terrain-background/{z}/{x}/{y}.{ext}";

var basemapOptions = {
  attribution: 'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap contributors',
  subdomains: "abcd",
  minZoom: 0,
  maxZoom: 18,
  ext: "png",
};

var glacier_map_Data = {
  glacier_1: {
    center: [45.5, -89.5],
    zoom: 7,
    description: "Glacier one",
    // add title, shapes etc here
    /*Glacier 11000*/
    shape: (Toe_11000 = {
      type: "FeatureCollection",
      features: [{
        type: "Feature",
        geometry: {
          type: "Polygon",
          coordinates: [
            [
              [-89.01714901099996, 47.701660041000025],
              [-88.98864567199996, 47.67105872900004],
              [-88.89693208899996, 47.632717624000065],
              [-88.76124959199996, 47.56169631900008],
              [-88.58375016199994, 47.49178961600006],
              [-88.44017698199997, 47.44707161100007],
              [-88.30330388599998, 47.44691295700005],
              [-88.17169811099996, 47.44667491700005],
              [-88.02148343399995, 47.45132287700005],
              [-87.87715720599994, 47.43981218000005],
              [-87.74844734199996, 47.433784306000064],
              [-87.64558455399998, 47.43885976400003],
              [-87.53193680099997, 47.44896815100003],
              [-87.38107493899997, 47.46526214000005],
              [-87.24572687999995, 47.48530297000008],
              [-87.13143423099996, 47.50392737300007],
              [-86.98182199599995, 47.53937042800004],
              [-86.82927429899996, 47.57632309400003],
              [-86.62586405499997, 47.62051563700004],
              [-86.53722267999996, 47.642872296000064],
              [-86.52848360499996, 47.655108436000035],
              [-86.66049972099995, 47.65724573000006],
              [-89.01447077999995, 47.70342257000004],
              [-89.01714901099996, 47.701660041000025],
            ],
          ],
        },
        properties: {
          OBJECTID_1: 1,
          OBJECTID: 1,
          Years_Ago: 11000,
          SHAPE_Leng: 387749.141631,
          Shape_Le_1: 5.06435076694,
          Shape_Area: 0.429078160361,
          filename: "11000.jpg",
        },
      }, ],
    }),

    shape_style: (g11000 = L.geoJSON(Toe_11000, {
      style: {
        color: "#e41a1c"
      },
    })),

    shape_listener: g11000.on({
      click: function() {
        $("#panel").html(
          Toe_11000.features[0].properties.Years_Ago +
          " Years Ago" +
          info11000 +
          glacierInfo +
          selfPlug
        );
      },
    }),
  },

  glacier_2: {
    center: [45.5, -89.5],
    zoom: 7,
    description: "Glacier two",
    // add title, shapes etc here
    /*Glacier 14600*/
    shape: (Toe_14600 = {
      type: "FeatureCollection",
      features: [{
        type: "Feature",
        geometry: {
          type: "Polygon",
          coordinates: [
            [

            ],
          ],
        },
        properties: {
          OBJECTID_1: 1,
          OBJECTID: 1,
          Years_Ago: 14600,
          SHAPE_Leng: 2202706.20984,
          Shape_Le_1: 25.0028099606,
          Shape_Area: 17.1995913109,
          filename: "14600.jpg",
        },
      }, ],
    }),

    shape_style: (g14600 = L.geoJSON(Toe_14600, {
      style: {
        color: "blue"
      },
    })),

    shape_listener: g14600.on({
      click: function() {
        $("#panel").html(
          Toe_14600.features[0].properties.Years_Ago +
          " Years Ago" +
          info14600 +
          glacierInfo +
          selfPlug
        );
      },
    }),
  },

  glacier_3: {
    center: [45.5, -89.5],
    zoom: 7,
    description: "Glacier three",
    // add title, shapes etc here
    shape: (Toe_17000 = {
      type: "FeatureCollection",
      features: [{
        type: "Feature",
        geometry: {
          type: "Polygon",
          coordinates: [
            [

            ],
          ],
        },
        properties: {
          OBJECTID_1: 1,
          OBJECTID: 2,
          Years_Ago: 17000,
          SHAPE_Leng: 2261336.18634,
          Shape_Le_1: 24.4337768448,
          Shape_Area: 21.6098467975,
          filename: "17000.jpg",
        },
      }, ],
    }),

    shape_style: (g17000 = L.geoJSON(Toe_17000, {
      style: {
        color: "#4daf4a"
      },
    })),

    shape_listener: g17000.on({
      click: function() {
        $("#panel").html(
          Toe_17000.features[0].properties.Years_Ago +
          " Years Ago" +
          info17000 +
          glacierInfo +
          selfPlug
        );
      },
    }),
  },

  glacier_4: {
    center: [45.5, -89.5],
    zoom: 7,
    description: "Glacier four",
    // add title, shapes etc here
    /*Glacier 20500*/
    shape: (Toe_20500 = {
      type: "FeatureCollection",
      features: [{
        type: "Feature",
        geometry: {
          type: "MultiPolygon",
          coordinates: [
            [
              [

              ],
            ],
            [
              [

              ],
            ],
          ],
        },
        properties: {
          OBJECTID_1: 1,
          OBJECTID: 1,
          Years_Ago: 20500,
          SHAPE_Leng: 3087165.91023,
          Shape_Le_1: 33.5221258781,
          Shape_Area: 32.9568211425,
          filename: "20500.jpg",
        },
      }, ],
    }),

    shape_style: (g20500 = L.geoJSON(Toe_20500, {
      style: {
        color: "#ffff33"
      },
    })),

    shape_listener: g20500.on({
      click: function() {
        $("#panel").html(
          Toe_20500.features[0].properties.Years_Ago +
          " Years Ago" +
          info20500 +
          glacierInfo +
          selfPlug
        );
      },
    }),
  },

  glacier_5: {
    center: [45.5, -89.5],
    zoom: 7,
    description: "Glacier five",
    // add title, shapes etc here
    /*Glacier 24000*/
    shape: (Toe_24000 = {
      type: "FeatureCollection",
      features: [{
        type: "Feature",
        geometry: {
          type: "Polygon",
          coordinates: [
            [

            ],
          ],
        },
        properties: {
          OBJECTID_1: 1,
          OBJECTID: 1,
          Years_Ago: 24000,
          SHAPE_Leng: 3034250.36063,
          Shape_Le_1: 33.0014683974,
          Shape_Area: 35.7394984299,
          filename: "24000.jpg",
        },
      }, ],
    }),

    shape_style: (g24000 = L.geoJSON(Toe_24000, {
      style: {
        color: "#984ea3"
      },
    })),
    shape_listener: g24000.on({
      click: function() {
        $("#panel").html(
          Toe_24000.features[0].properties.Years_Ago +
          " Years Ago" +
          info24000 +
          glacierInfo +
          selfPlug
        );
      },
    }),
  },

  glacier_6: {
    center: [45.5, -89.5],
    zoom: 7,
    description: "Glacier six",
    // add title, shapes etc here
    /*Glacier 27500*/
    shape: (Toe_27500 = {
      type: "FeatureCollection",
      features: [{
        type: "Feature",
        geometry: {
          type: "Polygon",
          coordinates: [
            [

            ],
          ],
        },
        properties: {
          OBJECTID_1: 1,
          OBJECTID: 1,
          Years_Ago: 27500,
          SHAPE_Leng: 2984589.95454,
          Shape_Le_1: 32.3931138132,
          Shape_Area: 34.4347324387,
          filename: "27500.jpg",
        },
      }, ],
    }),

    shape_style: (g27500 = L.geoJSON(Toe_27500, {
      style: {
        color: "#ff7f00"
      },
    })),
    shape_listener: g27500.on({
      click: function() {
        $("#panel").html(
          Toe_27500.features[0].properties.Years_Ago +
          " Years Ago" +
          info27500 +
          glacierInfo +
          selfPlug
        );
      },
    }),
  },

  glacier_7: {
    center: [45.5, -89.5],
    zoom: 7,
    description: "Glacier seven",
    // add title, shapes etc here
    shape: (Toe_31500 = {
      type: "FeatureCollection",
      features: [{
        type: "Feature",
        geometry: {
          type: "Polygon",
          coordinates: [
            [

            ],
          ],
        },
        properties: {
          OBJECTID_1: 1,
          OBJECTID: 2,
          Years_Ago: 31500,
          SHAPE_Leng: 1478866.18087,
          Shape_Le_1: 15.9994195189,
          Shape_Area: 9.83976333148,
          filename: "31500.jpg",
        },
      }, ],
    }),

    shape_style: (g31500 = L.geoJSON(Toe_31500, {
      style: {
        color: "#a65628"
      },
    })),
    shape_listener: g31500.on({
      click: function() {
        $("#panel").html(
          Toe_31500.features[0].properties.Years_Ago +
          " Years Ago" +
          info31500 +
          glacierInfo +
          selfPlug
        );
      },
    }),
  },
};

var initMap = (EL) => {
  var id = EL.dataset.map; // returns i.e: "glacier_1"
  var data = glacier_map_Data[id];
  var map = L.map(EL).setView(data.center, data.zoom);
  L.tileLayer(basemapTile, basemapOptions).addTo(map);

  var glacierLayers = L.control
    .layers(null, {
      //formatting from iH8 answer on StackOverflow https://stackoverflow.com/a/46044847/16538252
      "31500 years ago": g31500,
      "27500 years ago": g27500,
      "24000 years ago": g24000,
      "20500 years ago": g20500,
      "17000 years ago": g17000,
      "14600 years ago": g14600,
      "11000 years ago": g11000,
    })
    .addTo(map);
};
var ELS_map = document.querySelectorAll("[data-map]");
ELS_map.forEach(initMap);
/*Stylesheet by Will P. Campbell,2021*/

body {
  background-color: #ececec;
}

/* idea from Roko C Buljian answer on StackOverflow: https://stackoverflow.com/q/68836662/16538252 */

[data-map] {
  height: 650px;
  width: 60%;
  border: 5px solid black;
  margin: 20px;
}

h1 {
  font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
}

#panel {
  position: relative;
  right: 0;
  border: 5px outset black;
  background-color: lightblue;
  text-align: center;
  width: 25%;
  height: auto;
  padding: 20px;
  display: inline-block;
}

<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin="" />

<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>WISCONSIN GLACIER TIME LAPSE</title>

WISCONSIN GLACIER TIME LAPSE

Glacier Information Panel

Use the checkbox and click on each glacier to learn more about them!

A: You were on the right direction!
So, if you use all your data inside glacier_map_Data, where the properties reflect the data-* attribute of each element in the Document i.e:

 add inside it also the properties label, shape and style :
Here's the "new" data example for every glacier_(N)
// glacier_* :
{
    center: [45.5, -89.5],
    zoom: 7,
    label: "11000 years ago",
    description: "Glacier one description info goes here...",
    shape: {
        type: "FeatureCollection",
        features: [
            {
                type: "Feature",
                geometry: {
                    type: "Polygon",
                    coordinates: [[/* .... */],],
                },
                properties: { /* .... */ },
            },
        ],
    },
    style: {
        color: "#e41a1c",
    }
},

having that kind of data, you first need to:
Create all the LeafLet layers
Create all the LeafLet layers inside a separate Object. You'll later add that object to every map:
// Create the L.geoJSON LAYERS to be later added to each map!
const overlays = Object.entries(glacier_map_Data).reduce((acc_obj, [key, data]) => {

    // Define the geoJSON layer instance
    const L_geoLSON = L.geoJSON(data.shape, {style: data.style});

    // Add click listener to layer
    L_geoLSON.on({
        click() {
            EL_panel.innerHTML = `<h2>${data.title}</h2><p>${data.description}</p>`;
        }
    });

    // Create the return Object:
    acc_obj[key] = {
        label: data.title,
        L_geoJSON
    };

    // Return the accumulator (see: MDN: Array.prototype.reduce() for more info)
    return acc_obj;
}, {});

the above will generate something similar as what you used in your code for var glacierLayers but - with a slight difference:
// overlays =
{
  glacier_1 : {
    label: "11000 years ago",
    L_geoJSON: {} // the LeafLet geoJSON instance
  },
  // glacier 2, 3 etc...
}

having that custom object in place now, all you need is to: when looping your Maps convert it to the format expected by LeafLet {"layer description 1": geoJSON, /* etc */}
Add multiple layers to LeafLet map and make respective one active:
while looping your Maps ELements, you get the current element's data-* attribute const id = EL.dataset.map ID - that ID can be now referenced to get the active layer too:
// Maps initializator
// Applays LeafLet to each map Element `EL`
const initMap = (EL) => {
    const id = EL.dataset.map; // gives back i.e: "glacier_1" 2, 3 etc...
    const data = glacier_map_Data[id];

    // Assign a LeafLet Map instance to a specific DOM element and set its view
    const L_map = L.map(EL).setView(data.center, data.zoom);
    L.tileLayer(L_basemapTile, L_basemapOptions).addTo(L_map);

    // Convert the
    const overlayMaps = Object.values(overlays).reduce((acc_obj, data) => {
        acc_obj[data.label] = data.L_geoLSON
        return acc_obj;
    }, {});

    // Add control layers to map:
    L.control.layers(null, overlayMaps).addTo(L_map);

    // Make specific one "Active" (checked!) and visible on map:
    L_map.addLayer(overlays[id].L_geoJSON);
};

That's basically it. See in the below example how the click handlers are resolved to make it all work:

const EL_panel = document.querySelector("#panel");

const L_basemapTile = "https://stamen-tiles-{s}.a.ssl.fastly.net/terrain-background/{z}/{x}/{y}.{ext}";

const L_basemapOptions = {
  attribution: 'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap contributors',
  minZoom: 0,
  maxZoom: 18,
  ext: "png",
};

const glacier_map_Data = {
  glacier_1: {
    center: [45.5, -89.5],
    zoom: 7,
    label: "11000 years ago",
    description: "Glacier one description goes here...",
    shape: {
      type: "FeatureCollection",
      features: [{
        type: "Feature",
        geometry: {
          type: "Polygon",
          coordinates: [
            [
              [-89.01714901099996, 47.701660041000025],
              [-88.98864567199996, 47.67105872900004],
              [-88.89693208899996, 47.632717624000065],
              [-88.76124959199996, 47.56169631900008],
              [-88.58375016199994, 47.49178961600006],
              [-88.44017698199997, 47.44707161100007],
              [-88.30330388599998, 47.44691295700005],
              [-88.17169811099996, 47.44667491700005],
              [-88.02148343399995, 47.45132287700005],
              [-87.87715720599994, 47.43981218000005],
              [-87.74844734199996, 47.433784306000064],
              [-87.64558455399998, 47.43885976400003],
              [-87.53193680099997, 47.44896815100003],
              [-87.38107493899997, 47.46526214000005],
              [-87.24572687999995, 47.48530297000008],
              [-87.13143423099996, 47.50392737300007],
              [-86.98182199599995, 47.53937042800004],
              [-86.82927429899996, 47.57632309400003],
              [-86.62586405499997, 47.62051563700004],
              [-86.53722267999996, 47.642872296000064],
              [-86.52848360499996, 47.655108436000035],
              [-86.66049972099995, 47.65724573000006],
              [-89.01447077999995, 47.70342257000004],
              [-89.01714901099996, 47.701660041000025],
            ],
          ],
        },
        properties: {
          OBJECTID_1: 1,
          OBJECTID: 1,
          Years_Ago: 11000,
          SHAPE_Leng: 387749.141631,
          Shape_Le_1: 5.06435076694,
          Shape_Area: 0.429078160361,
          filename: "11000.jpg",
        },
      }, ],
    },
    style: {
      color: "#e41a1c",
    }
  },

  glacier_2: {
    center: [45.5, -89.5],
    zoom: 7,
    label: "14600 years ago",
    description: "Glacier two description goes here...",
    shape: {
      type: "FeatureCollection",
      features: [{
        type: "Feature",
        geometry: {
          type: "Polygon",
          coordinates: [
            [
              [-90.65116417499996, 47.70293454200004],
              [-90.72482365299999, 47.673924999000064],
              [-90.79822703099995, 47.63344243800003],
              [-90.87151684099996, 47.592913355000064],
              [-90.93607653299995, 47.54240954900007],
              [-90.98389479799994, 47.50486972300007],
              [-91.01266156999998, 47.46605101600005],
              [-91.03524057399994, 47.43585163000006],
              [-91.09569047499997, 47.40672034700003],
              [-91.16068607799997, 47.39608128700007],
              [-91.20242634199997, 47.38136616700007],
              [-91.24370674999994, 47.34807033200008],
              [-91.24727017899994, 47.32089010200008],
              [-91.27829107399998, 47.30054916700004],
              [-91.35252049299999, 47.24684182500005],
              [-91.42454322999998, 47.19454164700005],
              [-91.49851758599999, 47.142169952000074],
              [-91.58297018999997, 47.09531966900005],
              [-91.69593298799998, 47.02941600500003],
              [-91.78970295499994, 46.95941544900006],
              [-91.82835428899995, 46.930232197000066],
              [-91.91162510599997, 46.86744039100006],
              [-91.99554737199998, 46.82743409100004],
              [-92.06911560299994, 46.79183942000003],
              [-92.12271105199994, 46.779428163000034],
              [-92.18228311199994, 46.76116312500005],
              [-92.25397574199997, 46.73548525600006],
              [-92.32346255299996, 46.70837829200008],
              [-92.37452539699996, 46.68875637000008],
              [-92.41380912499994, 46.68507654200005],
              [-92.47155654999995, 46.67669948400004],
              [-92.49779041299996, 46.66041357700004],
              [-92.53630909799995, 46.640992280000034],
              [-92.60352557599998, 46.61519304900003],
              [-92.65025475699997, 46.595545755000046],
              [-92.66997578199994, 46.57508444400003],
              [-92.69410222099998, 46.56023089900003],
              [-92.73425967299994, 46.53498854400004],
              [-92.79268852199999, 46.503571829000066],
              [-92.84256524699998, 46.468051606000074],
              [-92.88183268599994, 46.42849094400003],
              [-92.92753540999996, 46.394466917000045],
              [-92.94989701799994, 46.34959887800005],
              [-92.95186608799997, 46.30954130100008],
              [-92.92975250899997, 46.28153421700006],
              [-92.85925850399997, 46.27331860700008],
              [-92.79127616799997, 46.27357100900008],
              [-92.71321257399995, 46.27830917600005],
              [-92.63952461199995, 46.28860811000004],
              [-92.57829646799996, 46.301436514000045],
              [-92.50925582199994, 46.32440533500005],
              [-92.44221727099995, 46.347289440000054],
              [-92.41261793199999, 46.37792243000007],
              [-92.37035638299994, 46.40309578500006],
              [-92.32010085699994, 46.43555965100006],
              [-92.22421472899998, 46.46604055800003],
              [-92.16676037899998, 46.47714513900007],
              [-92.07164040799995, 46.47747958900004],
              [-91.96355058399996, 46.462242262000075],
              [-91.88129117799997, 46.47505522800003],
              [-91.84860834599993, 46.487018110000065],
              [-91.75759648199994, 46.48702458100007],
              [-91.67480884399998, 46.485409692000076],
              [-91.61092690599997, 46.49347106100004],
              [-91.53298945499995, 46.517401738000046],
              [-91.46184380399995, 46.56548027200006],
              [-91.39439978099995, 46.60108704600003],
              [-91.31293960199997, 46.66110276500007],
              [-91.18166198599994, 46.731109263000064],
              [-91.12163612599994, 46.77552488500004],
              [-91.02482937399998, 46.78786178000007],
              [-90.98063779999995, 46.797773128000074],
              [-90.96927097899999, 46.782631328000036],
              [-90.95760682899999, 46.75034730400006],
              [-91.00666688699994, 46.706114670000034],
              [-91.04472870499995, 46.66958103600007],
              [-91.09664029099997, 46.636712301000045],
              [-91.13687825499994, 46.57726777900007],
              [-91.18839689999999, 46.532931133000034],
              [-91.22591702999995, 46.48300696300004],
              [-91.22480609399997, 46.433490293000034],
              [-91.18738430599996, 46.359591409000075],
              [-91.12616009499999, 46.325921202000075],
              [-90.99618142799994, 46.285217860000046],
              [-90.89141040599998, 46.26322281700004],
              [-90.77320977799997, 46.256463342000075],
              [-90.59165834999999, 46.22897204100008],
              [-90.47359851299996, 46.22571206300006],
              [-90.21011180299996, 46.22840493600006],
              [-90.07834092799999, 46.21714115300006],
              [-89.99052527699996, 46.20002253800004],
              [-89.63663278999996, 46.19754044900003],
              [-89.30472963899996, 46.19409865700004],
              [-89.14564109599996, 46.193020372000035],
              [-89.10690236799996, 46.21367948200003],
              [-88.97509624199995, 46.21828879600008],
              [-88.74396655199996, 46.24455812300005],
              [-88.43920812199997, 46.263282384000036],
              [-88.18463496799995, 46.27857294900008],
              [-88.00977466999996, 46.175646776000065],
              [-87.99389010599998, 46.04677587200007],
              [-88.03142757799998, 45.90454467200004],
              [-88.07824403599994, 45.733876871000064],
              [-88.11693049199994, 45.64521481500003],
              [-88.15630836499997, 45.53154329200004],
              [-88.25459067099996, 45.31159869500004],
              [-88.32963412999999, 45.169820886000025],
              [-88.40834291299996, 45.06376788400007],
              [-88.48581727299995, 44.99336901300006],
              [-88.79481685399998, 44.90415892300007],
              [-88.88639060299994, 44.84792515000004],
              [-88.88261184299995, 44.78357859500005],
              [-88.94319230899998, 44.76271860500003],
              [-88.97231671099996, 44.62840776200005],
              [-89.00318747399996, 44.57866096200007],
              [-89.02004076199995, 44.46804576400007],
              [-89.04649611099995, 44.37537170000007],
              [-89.10740785599995, 44.30082986600007],
              [-89.08883401599996, 44.21492877800006],
              [-89.02088686299999, 44.117891385000064],
              [-88.83475711099999, 43.998228366000035],
              [-88.68786675299998, 43.92517043600003],
              [-88.62533997199995, 43.84939582800007],
              [-88.57299960499995, 43.76656712400006],
              [-88.46045322499998, 43.73294585800005],
              [-88.39507582999994, 43.78207346700003],
              [-88.33422715399996, 43.841949181000075],
              [-88.26389529699998, 43.883781630000044],
              [-88.26171217099994, 43.95878690500007],
              [-88.25436012199998, 44.04085874400005],
              [-88.13665456199999, 44.003267237000045],
              [-88.04759712699996, 44.00177966800004],
              [-87.97724235799996, 44.03271403600007],
              [-87.91264601899996, 44.03869804900006],
              [-87.85100620199995, 43.96251794800003],
              [-87.84031258699997, 43.84797273600003],
              [-87.77934997599993, 43.76104507100007],
              [-87.69970123099995, 43.65226923900008],
              [-87.59451333699997, 43.57506238600007],
              [-87.41895871099996, 43.54264457600004],
              [-87.19847646199997, 43.53030423300004],
              [-87.05535483399996, 43.54457143500008],
              [-86.90199607799997, 43.56552812900003],
              [-86.73246550099998, 43.61082922300005],
              [-86.59688342599998, 43.66046715300007],
              [-86.47311237099996, 43.75675903800004],
              [-86.41494068499998, 43.905016706000026],
              [-86.38487126299998, 43.99339418100004],
              [-86.33611529199999, 44.14190469500005],
              [-86.23094835399996, 44.23494796600005],
              [-86.07578505799995, 44.32618325100003],
              [-85.99546925899995, 44.409139733000075],
              [-85.93780993299998, 44.44997420000004],
              [-85.94529025199995, 44.48596854700003],
              [-85.88575853799995, 44.551719080000055],
              [-85.82903334099996, 44.64612264200008],
              [-85.67299230199995, 44.65817042300006],
              [-85.49721378799995, 44.66565292100006],
              [-85.37988257999996, 44.69311130300008],
              [-85.26070073999995, 44.74180747400004],
              [-85.20102381099997, 44.79647274300004],
              [-85.12731019099994, 44.896951657000045],
              [-85.07522771199996, 44.976883351000026],
              [-84.82164997499996, 47.579520486000035],
              [-90.67336377599997, 47.71242423500007],
              [-90.65116417499996, 47.70293454200004],
            ],
          ],
        },
        properties: {
          OBJECTID_1: 1,
          OBJECTID: 1,
          Years_Ago: 14600,
          SHAPE_Leng: 2202706.20984,
          Shape_Le_1: 25.0028099606,
          Shape_Area: 17.1995913109,
          filename: "14600.jpg",
        },
      }, ],
    },
    style: {
      color: "blue",
    }
  },

  glacier_3: {
    center: [45.5, -89.5],
    zoom: 7,
    label: "17000 years ago",
    description: "Glacier three description goes here...",
    shape: {
      type: "FeatureCollection",
      features: [{
        type: "Feature",
        geometry: {
          type: "Polygon",
          coordinates: [
            [
              [-90.80257177799996, 47.694422805000045],
              [-90.86222397199998, 47.665247442000066],
              [-90.91508604399996, 47.62484245700006],
              [-90.95803303899999, 47.58544825300004],
              [-91.01917862199997, 47.54492503300003],
              [-91.09271780999995, 47.49663293300006],
              [-91.13744776499999, 47.48572257300003],
              [-91.19432270499999, 47.453717991000076],
              [-91.22598803099999, 47.42671888800004],
              [-91.25327888599998, 47.39404483100003],
              [-91.29858830799998, 47.35449497500008],
              [-91.35488375299997, 47.30908341500003],
              [-91.41382942899997, 47.261706307000054],
              [-91.49191066199995, 47.20262235200005],
              [-91.56326114699999, 47.15786191900003],
              [-91.61665197199994, 47.12283520300008],
              [-91.64494317099997, 47.09005134100005],
              [-91.68031442299997, 47.061918510000055],
              [-91.73452409299995, 47.01444274000005],
              [-91.74858348099997, 46.94175084200003],
              [-91.73854830599998, 46.900235628000075],
              [-91.72864410799997, 46.86228889100005],
              [-91.70514887199994, 46.83287815500006],
              [-91.66600897199999, 46.80131027900006],
              [-91.62366569299996, 46.776917671000035],
              [-91.55026225899996, 46.75531549600004],
              [-91.46858503999994, 46.74567813800007],
              [-91.38377803899994, 46.747925758000065],
              [-91.24871820299995, 46.74947940000004],
              [-91.19708552899993, 46.76431757600005],
              [-91.14894001899995, 46.781478469000035],
              [-91.08834267399999, 46.78445186300007],
              [-91.00692035499998, 46.786387758000046],
              [-90.97908530999996, 46.78067668300008],
              [-90.94737340199998, 46.75118052900007],
              [-90.93838366699998, 46.73220616100008],
              [-90.94831208099998, 46.70593260000004],
              [-90.95989734799997, 46.67607254100005],
              [-91.00120538799996, 46.66500363200004],
              [-91.02850889499996, 46.64571269000004],
              [-91.05754397599998, 46.62758970900006],
              [-91.07281220699997, 46.61316088700005],
              [-91.09452456799994, 46.57604782900006],
              [-91.11295233699997, 46.54848696500005],
              [-91.11776169199999, 46.53058148500003],
              [-91.12399765899994, 46.498374786000056],
              [-91.12685495599999, 46.46977266600004],
              [-91.11093806599996, 46.449688397000045],
              [-91.08423164199996, 46.405892745000074],
              [-91.04970107799994, 46.400261948000036],
              [-91.00833934399998, 46.39706236200004],
              [-90.95158052599999, 46.39873937200008],
              [-90.91358681599996, 46.39071504300006],
              [-90.87046244599998, 46.383907855000075],
              [-90.81185063999999, 46.37600480700007],
              [-90.76383959199995, 46.38705097700006],
              [-90.72438110399997, 46.39564190900006],
              [-90.63847221899994, 46.40686916000004],
              [-90.56462655999997, 46.42273526000008],
              [-90.51134690599997, 46.432510584000056],
              [-90.45289127799998, 46.44347225900003],
              [-90.32730869399995, 46.46771218100008],
              [-90.26707800199995, 46.483346151000035],
              [-90.14297639499995, 46.48118746100005],
              [-89.84300789599996, 46.47969872700003],
              [-89.65732711399994, 46.40785826900003],
              [-89.46590880699995, 46.26901435500008],
              [-89.38473015499994, 46.15906824800004],
              [-89.37232217399998, 46.044697961000054],
              [-89.29895872499998, 45.89662691800004],
              [-89.19127953899994, 45.795896034000066],
              [-89.04288713099999, 45.713779739000074],
              [-88.81317766399997, 45.64494244800005],
              [-88.52326877299998, 45.56535339100003],
              [-88.34772919599999, 45.53913320500004],
              [-88.28172005799996, 45.481001443000025],
              [-88.24935543399994, 45.432878068000036],
              [-88.29265439599999, 45.34303229100004],
              [-88.51505546999994, 45.10321006100003],
              [-88.68092601499995, 44.90994226600003],
              [-88.83212689599998, 44.72580551000004],
              [-88.88282864799999, 44.521468026000036],
              [-88.93928291699996, 44.345738820000065],
              [-88.91597518599997, 44.16924722700003],
              [-88.90511613299998, 44.04050887900007],
              [-88.77686594499994, 43.85339730000004],
              [-88.63498640399996, 43.723149343000046],
              [-88.45317832499995, 43.63983570600004],
              [-88.30836892799994, 43.656842280000035],
              [-88.18115130199999, 43.74064944300005],
              [-88.10533528899998, 43.64412736300005],
              [-88.07694916099996, 43.50548020300005],
              [-88.01697621299996, 43.33769126900006],
              [-88.02053189599997, 43.22816265400007],
              [-87.97488779599996, 43.032002686000055],
              [-87.92574681699995, 42.754748824000046],
              [-87.89018209199998, 42.46818362000005],
              [-87.89013807499998, 42.277565752000044],
              [-87.84692496099996, 42.03848385400005],
              [-87.74604783999996, 41.817324159000066],
              [-87.58802798299996, 41.613950112000055],
              [-87.35004156799994, 41.532454906000055],
              [-87.03022367399996, 41.59135333200004],
              [-86.77141863699995, 41.68921014000006],
              [-86.51666584599997, 41.81518954100005],
              [-86.41223131899994, 41.97398477400003],
              [-86.29809079699999, 42.180014037000035],
              [-86.12804763999998, 42.445983640000065],
              [-86.00558320699997, 42.65141657300006],
              [-85.85659114999999, 43.04632439000005],
              [-85.84500492099994, 43.21741730100007],
              [-86.03504616299995, 43.40045063700006],
              [-85.91772016199997, 43.686927799000046],
              [-85.72568643499994, 43.89427499900006],
              [-85.70752393799995, 44.146079014000065],
              [-85.57577670099994, 44.226791743000035],
              [-85.33539704999998, 44.25055543500008],
              [-85.15006930999994, 44.24758344700007],
              [-84.83610884999996, 47.577689332000034],
              [-90.81976554599999, 47.700655631000075],
              [-90.80257177799996, 47.694422805000045],
            ],
          ],
        },
        properties: {
          OBJECTID_1: 1,
          OBJECTID: 2,
          Years_Ago: 17000,
          SHAPE_Leng: 2261336.18634,
          Shape_Le_1: 24.4337768448,
          Shape_Area: 21.6098467975,
          filename: "17000.jpg",
        },
      }, ],
    },
    style: {
      color: "#4daf4a",
    }
  }
};

// Create the L.geoJSON LAYERS to be later added to each map!
const overlays = Object.entries(glacier_map_Data).reduce((acc_obj, [key, data]) => {

  // Define the geoJSON layer instance
  const L_geoJSON = L.geoJSON(data.shape, {
    style: data.style
  });

  // Add click listener to layer
  L_geoJSON.on({
    click() {
      EL_panel.innerHTML = `<h2>${data.label}</h2><p>${data.description}</p>`;
    }
  });

  // Create the return Object:
  acc_obj[key] = {
    label: data.label,
    L_geoJSON
  };

  // Return the accumulator (see: MDN: Array.prototype.reduce() for more info)
  return acc_obj;
}, {});

// console.log(overlays); // See it to understand it!

// Maps initializator
// Applays LeafLet to each map Element `EL`
const initMap = (EL) => {
  const id = EL.dataset.map; // gives back i.e: "glacier_1" 2, 3 etc...
  const data = glacier_map_Data[id];

  // Assign a LeafLet Map instance to a specific DOM element and set its view
  const L_map = L.map(EL).setView(data.center, data.zoom);
  L.tileLayer(L_basemapTile, L_basemapOptions).addTo(L_map);

  // Convert the
  const overlayMaps = Object.values(overlays).reduce((acc_obj, data) => {
    acc_obj[data.label] = data.L_geoJSON
    return acc_obj;
  }, {});

  // Add control layers to map:
  L.control.layers(null, overlayMaps).addTo(L_map);

  // Make specific one "Active" (checked!) and visible on map:
  L_map.addLayer(overlays[id].L_geoJSON);
};

// Loop map elements in DOM and assign
var ELS_map = document.querySelectorAll("[data-map]");
ELS_map.forEach(initMap);
/*Stylesheet by Will P. Campbell,2021*/

body {
  background-color: #ececec;
}

[data-map] {
  height: 650px;
  width: 60%;
  border: 5px solid black;
  margin: 20px;
}

h1 {
  font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
}

#panel {
  position: fixed;
  right: 0;
  top: 0;
  border: 5px outset black;
  background-color: lightblue;
  text-align: center;
  width: 25%;
  height: auto;
  padding: 20px;
}
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin="" />

WISCONSIN GLACIER TIME LAPSE

Glacier Information Panel

Use the checkbox and click on each glacier to learn more about them!


text:
Q: call function since product-variants.tpl Prestashop I'm creating a web in Prestashop and my problem is the next:
I has created a new table in db (mysql) called 'tallas' and I have the size's preferences of the users. Now, I need call this table since the page product-variants.tpl because I would like to put cheeked for default the option select by the customer.
I create this function in classes/Product.php
public function getTalla($id_customer){

   $result = Db::getInstance()->ExecuteS('
   SELECT `talla1`
   FROM `tallas`
   WHERE `cliente` = `$id_customer`');

   return $result;
}

ok, I would like to receive for parameters the user id (I don't know how to do that yet) and I would like to receive the value of talla1 and then I would like put cheeked the option selected by the customer here in the themes/asmart/templates/catalog/_partials/product-variants.tpl in the radio.

            <input class="input-color" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if}>
            {$group_attribute.name}

Sincerely I don't know any idea to how to do that, can someone help me?
UPDATE: The problem is solved!
The problem is solved. I do that:
in classes/Product.php
public function getTalla(){
       $variable = Context::getContext()->customer->id;
       $result = Db::getInstance()->ExecuteS('SELECT * FROM `tallas` WHERE `cliente` = `$variable`');

       return $result;
   }

in ProductController.php
$this->context->smarty->assign('images_ex',$this->product->getTalla());

in product-variants.tpl
{if $images_ex[0]['talla1'] == $group_attribute.name} checked="checked"{/if}

I hope this can help someone in the future.


text:
Q: golang reading long text from stdin I want to read a long text from os.Stdin, but I can't make it happen. Already read everything in the subject, tried codes that supposed to work. Every method cuts after 4096 characters, no matter what.
Eg. here's a working example. After the first run of the loop, it reads the first 4096 characters, and then waits for more processing each enter, until I end it with an EOF (Ctrl+D). Same thing for fmt.Scan, bufio.NewScanner, bufio ReadLine, ioutil.ReadAll. If I save it to a file, and read it, it works as expected. From stdin it doesn't.
I'm on Arch Linux, 32 bit, Go 1.7, tested in mate-terminal 1.14, tty 8.25, same thing in both of them. And the same thing happens on the hackerrank.com page, I don't know what technology they're using.
Please help!
EDIT:
My input is just a little bit longer than 4096 characters. I checked out the link that Amd shared, and I got the following: my input is only one line containing space separated integers. When I changed the spaces to newlines, it worked. But since the excercise format on hackerrate uses long space-separated lines, the problem is still up, with a refinement.

A: I was able to solve this thanks to Ian Lance Taylor:
https://groups.google.com/forum/#!topic/golang-nuts/ndh-1wdsWYs
So the 4096 characters is the limit of my system through N_TTY_BUF_SIZE kernel parameter. The same thing worked with cat and Python as well.
Anyway, on hackerrank.com I was able to solve the same exercise in Python, so I guess they have a wrong configuration for Go, I already asked them to find it out.


text:
Q: Mysql Workbench Error 1452 al insertar datos Estoy creando la siguiente bases de datos:

Aquí el codigo de ello:
create table CLIENTES
    (dni char(6)primary key,
    nombre varchar(20));

create table PRESTAMOS
    (id int(6),
    principal int(20),
    plazo_en_meses int(3),
    cliente varchar (20),
    fecha_comienzo date, foreign key(cliente) references CLIENTES (dni));

create table CUENTAS
    (numero int(15)primary key,
    saldo float(40),
    cliente varchar(20), foreign key(cliente) references CLIENTES(dni));

Al momento de insertar datos en clientes va bien, pero el problema es al insertar con cuentas y prestamos, da el siguiente error:

Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (`empresa`.`cuentas`, CONSTRAINT `cuentas_ibfk_1` FOREIGN KEY (`cliente`) REFERENCES `clientes` (`dni`))

Los datos los estoy insertado de la siguiente manera:
insert into CLIENTES values(1235,'Sebastian');

insert into CUENTAS values(1236,20000,'Sebastian');
insert into PRESTAMOS values(1235,1,4,'Sebastian',20-05-01);

A: Procura que tus llaves primarias y foráneas sean:

*

*Del mismo tipo de dato

*De la misma longitud

create table CLIENTES
    (dni varchar (20) primary key,
    nombre varchar(20)
);

create table PRESTAMOS(
    id int(6),
    principal int(20),
    plazo_en_meses int(3),
    cliente varchar (20),
    fecha_comienzo date,
    foreign key(cliente) references CLIENTES (dni)
);

create table CUENTAS(
    numero int(15)primary key,
    saldo float(40),
    cliente varchar(20),
    foreign key(cliente) references CLIENTES(dni)
);

Posterior en tus INSERT debes:

*

*Insertar la misma cantidad de valores en función del número de columnas que tengan

*Procura siempre revisar que los valores que ingresas estén en el espacio adecuado ya que cada columna
tiene un tipo de dato distinto por lo tanto si no se corresponden te dará error

*Los tipos de dato como date deben ir entre comillas

insert into CLIENTES values(1235,'Sebastian');
insert into PRESTAMOS values(1235,1,4, 1235, "2020-05-01");
insert into CUENTAS values(1236,20000, 1235);

Referencias

*

*tipos de dato en MySQL


text:
Q: Roots, coroots and weights I am confused by the relations between roots, coroots and weights in Lie algebras. Let $G$ be a Lie group, $T$ its maximal split torus and $\mathfrak{g}$ its Lie algebra. Here is what I have in mind (and I am always convinced by examples in $GL(n)$):

*

*a root $\alpha$ is an "eigenvalue" of the adjoint action of the torus: $ad(t) x = \alpha(t) x$ for all $t \in \mathfrak{t}:=Lie(T)$ and $x \in \mathfrak{g}$. Thus $\alpha \in \mathfrak{t}^\star$.

*a coroot $\alpha^\vee$ associated to $\alpha$ is defined, for all root $\beta$, by $\alpha^\vee(\beta) = 2(\alpha, \beta)/(\alpha, \alpha)$. It is therefore an element of $\mathfrak{t}^{\star \star} = \mathfrak{t}$.

*a weight is a Lie algebra "character", i.e. a morphism $\mathfrak{g} \to \mathbb{R}$, i.e. an element of $\mathfrak{g}^\star$.

The relation between weights and roots remains unclear. If one is given a set of simple roots $\Delta$, it can get by the coroot construction the set of corresponding simple soroots $\Delta^\vee$, basis of $\mathfrak{t}^{\star\star}=\mathfrak{t}$.
How can we construct from these sets/basis of weights or coweights? I saw some statements that $\{\varpi_\alpha \ : \ \alpha \in \Delta\}$ is a set of simple weights (and similarly with coweights), but I don't know what is $\varpi_{\alpha}$.
I think I am confusing both. Why do we consider (co)roots and (co)weights?


text:
Q: New Site Column Types in Sharepoint 2010 I'm looking for the definitive list of Site Column Types in SharePoint 2010.
For example Type="Text", Type="Boolean".
In SQL these would be the data types.
Thank you

A: Complete list found at the bottom of this article : http://msdn.microsoft.com/en-us/library/ms437580.aspx
Seems like Integer is now a valid type. Pretty cool!


text:
Q: C++ game and decorator pattern I'm porting a 2D platformer and I need a good way of getting some extensibility out of my level tiles. I'm not sure if Decorator is correct here, but nothing else comes to mind. Maybe I need something unique.
Anyway, say I have a basic Tile that has things like it's image, and whether the player can pass through it (background or foreground). Now I want to add properties to them like making some tiles act as ladders, or making some hurt or kill the player on contact. Maybe some can disappear. Some properties can be combined.
This sounds like decorator, but I really don't like how that requires my base class to implement dummy versions of everything, like isLadder(), isLethal(), etc. Is there a better way? I'm not going to be the guy who changes my design just so it looks like something out of the GoF book.
Sorry if this has been asked a million times before, I didn't quite find it in the related questions.

A: How you design your class methods can make a huge difference in how difficult Decorator is to implement - for instance, instead of isLadder() and isLethal() and so on, why not have methods based on the ways in which the player could interact with a tile (enter(from_dir), exit(to_dir)), etc? A lethal tile could override the enter() method to signal that the player should be killed; a ladder tile could override either enter() or exit() depending on the desired functionality.

A: Dav is right. It could be something like this:
class Tile
{
    public bool allowsPassThrough()
    {}

    // couldn't find a better name for this method
    public void passThrough(Player player)
    {}
}

class LethalTile extends Tile
{
    public void passThrough(Player player)
    {
        player.kill();
    }
}

A: I would have introduced something like a TileTraits class. Each tile can return its traits via the, well..., "getTraits()" method. TileTraits can be extended to support as many tile features as you want. Something like a:
class TileTraits
{
public:
   enum TileTrait{ Walkable  = 1,
                   Climbable = 1 << 1,
                   Lethal    = 1 << 2 };
private:
   TileTrait m_TraitSet;
};

class BaseTile
{
public:
   virtual TileTraits getTraits() const;
};

class LadderTile : public BaseTile
{
public:
   TileTraits getTraits() const {
      return TileTraits( TileTraits::Walkable | TileTraits::Climbable);
    }
};

A: Well, if it's about a bunch of is*() functions, you may go for something like isIt(what) function, returning oh no! by default implementation, which will be used as a fallback in derived classes.

A: Maybe you should look at component based objects.
Here is an example : http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/


text:
Q: Vue - Accessing Attributes in a Django Dictionary In Vue, using {{ game.data }} results in:
[ { "game": 1, "turn": 1, "player": 1, "word": "trend", "score": 18 }, { "game": 1, "turn": 2, "player": 2, "word": "test", "score": 12 } ]
But I want to access {{ game.data.player }}
My models.py
class Game(models.Model):
date = models.DateTimeField(auto_now_add=True)
def __str__(self):
    return str(self.id)

class Word(models.Model):
    game = models.ForeignKey(Game, related_name='word', on_delete=models.CASCADE)
    turn = models.IntegerField()
    player = models.ForeignKey(User, on_delete=models.CASCADE)
    word = models.CharField(max_length=255)
    score = models.IntegerField()

serializers.py
class GameSerializer(serializers.ModelSerializer):
data = serializers.SerializerMethodField(read_only=True)

class Meta:
    model = Game
    fields = ['id', 'date' ,'data']

 def get_data(self, obj):
    return WordSerializer(obj.word, many=True).data

Game.vue

Thanks in advance,

A: You can simply achieve that by iterating the game.data array in HTML template by using v-for directive.
Live Demo :

new Vue({
  el: '#app',
  data: {
    game: {}
  },
  mounted() {
    this.game = {
      data: [{
        "game": 1,
        "turn": 1,
        "player": 1,
        "word": "trend",
        "score": 18
      }, {
        "game": 1,
        "turn": 2,
        "player": 2,
        "word": "test",
        "score": 12
      }]
    }
  }
})

    {{ g.player }}


text:
Q: How to find out the memory footprint of my Android App? Well, the title says it.
It would also be handy to know how many memory is still available.
I am writing a memory hungry application that tends to crash randomly (in native Code),
and my suspicion is that it gets out-of-memory.

A: I think you'd struggle to find a more comprehensive answer than this on the subject:
How do I discover memory usage of my application in Android?

A: i agree with hackbod's reply. As far as my understanding goes, your app wont crash , rather it will be killed.
you may find this discussion interesting
Is there a need to check for NULL after allocating memory, when kernel uses overcommit memory.
I guess there is some call back to know lowmemory conditions(onLowMemory()), you can use it to identify low memory conditions, I havent tried it though.

A: Applications on Android generally don't crash due to low memory.  If you are using a lot of memory, you may cause most all other applications to be killed.  If you keep on using memory, you may cause the system to kill your app as well (not crashing it, just killing it), though you will probably get to the point of noticeable paging before that happens.
If you are dealing with native code, the more likely explanation is that you are corrupting memory somewhere.

A: You might want to catch the OutOfMemoryException and then call System.gc() to perform a manual garbage collection, then retry that piece of code that failed. You might be able to use native exceptions with JNI to detect when the C++ code fails due to lack of memory, or anticipate.

A: Check http://kohlerm.blogspot.com/2010/02/android-memory-usage-analysis-slides.html to find out which java objects use the most memory


text:
Q: How to send messages to particular users Ratchet PHP Websocket I'm trying to build a system where user can subscribe to a category on establishing connection to websocket server and then he will start receiving updates for that category. So far, I have worked with Ratchet and I am able to send message to all the connected clients but the problem is I don't want to send message to all the clients I just want to send the message to the clients who have subscribed the the particular category in which the messages was sent.
PHP Code
Chat.php
<?php
namespace MyApp;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;

class Chat implements MessageComponentInterface
{
    protected $clients;

    public function __construct()
    {
        $this->clients = new \SplObjectStorage;
    }

    public function onOpen(ConnectionInterface $conn)
    {
        $this->clients->attach($conn);
    }

    public function onMessage(ConnectionInterface $conn, $msg)
    {
        foreach ($this->clients as $client)
        {
            if($conn !== $client)
                $client->send($msg);
        }
    }

    public function onClose(ConnectionInterface $conn)
    {
        $this->clients->detach($conn);
    }

    public function onError(ConnectionInterface $conn, \Exception $e)
    {
        echo "An error has occurred: {$e->getMessage()}\n";
        $conn->close();
    }
}
?>

server.php
<?php
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use MyApp\Chat;

require dirname(__DIR__) . '/Ratchet/vendor/autoload.php';

$server = IoServer::factory(
  new HttpServer(
    new WsServer(
      new Chat()
    )
  ),
  8080
);

$server->run();
?>

Client side js code
<script type="text/javascript">
var conn = new WebSocket('ws://localhost:8080');

conn.onopen = function(e) {
  console.log("Connection established!");
};

conn.onmessage = function(e) {
  console.log(e.data);
};
</script>

A: ok, now I am sharing my experience. You Can Send Token and Insert This toke in onOpen (server.php) in the database. You can Insert Chat Token When User Login. Every Time When User Login New Token is generated and updated.
Now Use This Token To Find out user Id in onOpen connection.
var conn = new WebSocket('ws://172.16.23.26:8080?token=<?php echo !empty($_SESSION['user']['token']) ? $_SESSION['user']['token'] : ''; ?>');
    conn.onopen = function(e) {
        console.log("Connection established!");
    };

Now Server.php
  public function onOpen(ConnectionInterface $conn) {
    $this->clients->attach($conn);
    $querystring = $conn->httpRequest->getUri()->getQuery();
    parse_str($querystring,$queryarray);
   //Get UserID By Chat Token
    $objUser = new \users;
    $objUser->setLoginToken($queryarray['token']);
    $GetUserInfo = $objUser->getUserByToken();
    echo "New connection! ({$conn->resourceId})\n";
    //save Chat Connection
   // Insert the new connection with the user ID to Match to later if user ID in Table Then Update IT with a new connection

 }

Now your Connection is established, then send Message To particular users
Client-Side send USerID with received ID and Message
$("#conversation").on('click', '#ButtionID', function () {
         var userId      = $("#userId").val();
         var msg         = $("#msg").val();
         var receiverId  = $("#receiverId").val();
      if ( userId  != null &&  msg  != null ){
        var data = {
            userId: userId,
            msg: msg,
            receiverId: receiverId
        };
        conn.send(JSON.stringify(data));
        $("#msg").val("");
      }
    });

Server Side
public function onMessage(ConnectionInterface $from, $msg) {
      $numRecv = count($this->clients) - 1;
      echo sprintf('Connection %d sending message "%s" to %d other connection%s' . "\n",$from->resourceId, $msg, $numRecv, $numRecv == 1 ? '' : 's');
      $data = json_decode($msg, true);
      echo $data['userId'];
      echo $data['msg'];
      echo $data['receiverId'];
     // Save User ID receiver Id message in table
     //Now Get Chat Connection by user id By Table Which is saved onOpen function
        $UptGetChatConnection   = $objChatroom->getChatConnectionUserID($data['receiverId']);
    $ReciId = $UptGetChatConnection[0]['ConnectionID'];
    foreach ($this->clients as $client) {
        if ($from == $client) {
           $data['from']  = "Me";
           $data['fromname'] = 5;
        } else {
           $data['from']  = $user['name'];
           $data['fromname'] = 6;
        }
        echo $client->resourceId;
        echo $ReciId."\n";
        if($client->resourceId == $ReciId || $from == $client){
            $client->send(json_encode($data));
        }
    }
}

now the message has been sending by connection ID not broadcast only send particular
  users

A: Basically you want a syntax for sending data to the WebSocket, I reccomend using a JSON object to do this.  In your WebSocket class you need a local variable called subscriptions and a local variable called users like so.
<?php
namespace MyApp;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;

class Chat implements MessageComponentInterface
{
    protected $clients;
    private $subscriptions;
    private $users;

    public function __construct()
    {
        $this->clients = new \SplObjectStorage;
        $this->subscriptions = [];
        $this->users = [];
    }

    public function onOpen(ConnectionInterface $conn)
    {
        $this->clients->attach($conn);
        $this->users[$conn->resourceId] = $conn;
    }

    public function onMessage(ConnectionInterface $conn, $msg)
    {
        $data = json_decode($msg);
        switch ($data->command) {
            case "subscribe":
                $this->subscriptions[$conn->resourceId] = $data->channel;
                break;
            case "message":
                if (isset($this->subscriptions[$conn->resourceId])) {
                    $target = $this->subscriptions[$conn->resourceId];
                    foreach ($this->subscriptions as $id=>$channel) {
                        if ($channel == $target && $id != $conn->resourceId) {
                            $this->users[$id]->send($data->message);
                        }
                    }
                }
        }
    }

    public function onClose(ConnectionInterface $conn)
    {
        $this->clients->detach($conn);
        unset($this->users[$conn->resourceId]);
        unset($this->subscriptions[$conn->resourceId]);
    }

    public function onError(ConnectionInterface $conn, \Exception $e)
    {
        echo "An error has occurred: {$e->getMessage()}\n";
        $conn->close();
    }
}
?>

The javascript to go with that looks a bit like this
<script type="text/javascript">
var conn = new WebSocket('ws://localhost:8080');

conn.onopen = function(e) {
  console.log("Connection established!");
};

conn.onmessage = function(e) {
  console.log(e.data);
};

function subscribe(channel) {
    conn.send(JSON.stringify({command: "subscribe", channel: channel}));
}

function sendMessage(msg) {
    conn.send(JSON.stringify({command: "message", message: msg}));
}
</script>

Note: This code is untested I wrote it on the fly from my experience with Ratchet.  Good luck :)

A: // SOCKET VARIABLE DECLARATION
var mySocket;

// MESSAGE
const socketMessageListener = function(event) {
    var data = JSON.parse(event.data);
};

// OPEN SOCKET
const socketOpenListener = function(event) {
    console.log('Connected');
};

// CLOSE OR DISCONNECT SOCKET
const socketCloseListener = function(event) {
    if (mySocket) {
        console.error('Disconnected.');
    }
    mySocket = new WebSocket('ws://localhost:8080');
    mySocket.addEventListener('open', socketOpenListener);
    mySocket.addEventListener('message', socketMessageListener);
    mySocket.addEventListener('close', socketCloseListener);
};

// CALL THE LISTENER
socketCloseListener();

function sendMessage(data) {
    mySocket.send(JSON.stringify(data));
}

user3049006 i found this code in my research to keep the connection persistent if fail retry the connection again.


text:
Q: Python | cv2.imshow() loading arrays as BGR? I have recorded some data as npy file. And I tried to diplay the image (data[0]) to check if it makes sense with the following code
import numpy as np
import cv2

train_data = np.load('c:/data/train_data.npy')

for data in train_data:
    output = data[1]
    # only take the height, width and channels of the 4 dimensional array
    image = data[0][0, :, :, :]
    # image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    cv2.imshow('test', image)
    print('output {}'.format(output))
    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break

But if I display the images without the line image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) the images seem to be BGR based. If I comment this line into the code the images are displayed correctly.

My question: Does this observation imply that the image array is already in BGR format? Or does this imply that cv2.imshow() does by
  default interprete the array as BGR array?

A: Matplotlib and Numpy read images into RGB and processes them as RGB.   OpenCV reads images into BGR and processes them as BGR.  Either system recognizes a range of input types, has ways to convert between color spaces of almost any type, and offers support of a variety of image processing tasks.
This gives three different ways to load an image (plt.imread(), ndimage.imread() and cv2.imread()), two systems for processing the data (Numpy and CV2), and two ways to display the image (plt.imshow() and cv2.imshow()), and really, there is a third way to display the image using pyplot, if you want to treat the image as numerical data in 2-d plus another dimension for each color.
Here is some simple code to demonstrate some of this.
#!/usr/bin/python

import matplotlib.pyplot as plt
from scipy.ndimage import imread
import numpy as np
import cv2

img = imread('index.jpg')
print( "img data type: %s shape %s"%( type(img), str( img.shape) ) )

plt.imshow( img )
plt.title( 'pyplot as read' )
plt.savefig( 'index.plt.raw.jpg' )

cv2.imshow('cv2, read by numpy', img)
cv2.imwrite('index.cv2.raw.jpg',img)

img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

cv2.imshow('after conversion', img)
cv2.imwrite('index.cv2.bgr2rgb.jpg',img)

This generates the following line of text, and the following three example image files.
img data type: <type 'numpy.ndarray'> shape (225, 225, 3)

The correct image has red as the upper circle.  We read the image into a numpy array, using ndimage.imread(), and show it with Pyplot's imshow() and get the correct image.  We then show it with cv2.imshow() and we see that the red channel is interpreted as the blue channel and vice versa.  Then we convert the colorspace and we see that cv2.imshow() now interprets the result correctly.
plt.imshow(), as read by ndimage():

cv2.imshow(), the image as read by ndimage:

cv2.imshow(), after converting from RGB to BGR:


text:
Q: React typescript how to use useRef as prop I'm just play around with typescript and
I've got problem to use useRef in a custom element
passing it as prop
I've tried with
import React from "react";

export interface InputProps
  extends React.InputHTMLAttributes<HTMLInputElement> {
    ref: HTMLElement | null
  }

const Input: React.FC<InputProps> = ({ ...inputProps }) => {
  return (
    <input
      className="px-2 py-1 text-gray-700 text-2xl bg-white border-2 border-gray-200 hover:border-purple-300 focus:outline-none focus:bg-white rounded-l-lg shadow-md"
      {...inputProps}
    />
  );
};
export default Input;

import React, { useRef } from "react";

import Input from "./input";
import Button from "./button";

const Form: React.FC = () => {
  const todoRef = useRef<HTMLElement | null>(null);
  return (
    <form onSubmit={}>
      <Input type="text" id="todo" ref={todoRef}/>
      <Button type="submit">+</Button>
    </form>
  );
};

export default Form;

What's the right way, please?
UPDATE
I worked out with:
https://codesandbox.io/s/typescript-useref-example-e0hc4

A: You need to use React.forwardRef on the component you are passing the ref to, like so:
const Input = React.forwardRef<HTMLElement, InputProps>(({ ...inputProps }, ref) => {
  return (
    <input
      ref={ref}
      className="px-2 py-1 text-gray-700 text-2xl bg-white border-2 border-gray-200 hover:border-purple-300 focus:outline-none focus:bg-white rounded-l-lg shadow-md"
      {...inputProps}
    />
  );
});

Refs are treated differently than normal props. They are not included in the props object. To expose a ref inside a custom component you have to use forwardRef. Once the ref is exposed inside your component, you should assign it to one of the components in your return statement (usually the top level component, input in this case).

UPDATE:
If you're seeing the error React.HTMLElement is not assignable to type React.HTMLInputElement you should change the type of ref that you're creating to the appropriate one:
const todoRef = useRef<HTMLInputElement | null>(null)

and in the input component change the first line to:
const Input = React.forwardRef<HTMLInputElement, InputProps>(({ ...inputProps }, ref) => {

A: change to:
const Input: React.FC<InputProps> = React.forwardRef((inputProps, ref) => {
return(
    <input
      className="px-2 py-1 text-gray-700 text-2xl bg-white border-2 border-gray-200 hover:border-purple-300 focus:outline-none focus:bg-white rounded-l-lg shadow-md"
      ref={ref}
      {...inputProps}
    />
)
})
export default Input;

output here: https://codesandbox.io/s/typescript-useref-example-p3hh4

A: Try one of this:

*

*Use HTMLInputElement instead of HTMLElement

*<Input type="text" id="todo" ref={todoRef as any}/>

*Wrap the HTMLElement type into a ReactElement generic type


text:
Q: How to handle face id permission alert? I had written the following code snippet
if ([contextNew canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error])
{
    [contextNew evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:NSLocalizedString(@"",nil) reply:^(BOOL success, NSError *error)
    {
        if(success)
        {

        }
        else
        {

        }
    }
}

it comes in sucess block after verification of face.I want to handle face id permission alert.
I want to get the Yes or permission granted method for face id .
As we get something like AVAuthorizationStatus for camera

A: Not sure, will this solve your problem or not, but I've following options to detect LAAuthentication Error type (in Swift, you need to convert it into Objective-C)
laContext.evaluatePolicy(biometricsPolicy, localizedReason: localizedReason, reply: { (isSuccess, error) in
    if let laError = error {
       // handle error
       self.showLAError(laError: laError)
    } else if isSuccess {
      // handle success
    }
})

// function to detect an error type
func showLAError(laError: Error) -> Void {

    var message = ""

    switch laError {

    case LAError.appCancel:
        message = "Authentication was cancelled by application"

    case LAError.authenticationFailed:
        message = "The user failed to provide valid credentials"

    case LAError.invalidContext:
        message = "The context is invalid"

    case LAError.passcodeNotSet:
        message = "Passcode is not set on the device"

    case LAError.systemCancel:
        message = "Authentication was cancelled by the system"

    case LAError.touchIDLockout:
        message = "Too many failed attempts."

    case LAError.touchIDNotAvailable:
        message = "TouchID is not available on the device"

    case LAError.userCancel:
        message = "The user did cancel"

    case LAError.userFallback:
        message = "The user chose to use the fallback"

    default:

        if #available(iOS 11.0, *) {

            switch laError {

            case LAError.biometryNotAvailable:
                message = "Biometry is not available"

            case LAError.biometryNotEnrolled:
                message = "Authentication could not start, because biometry has no enrolled identities"

            case LAError.biometryLockout:
                message = "Biometry is locked. Use passcode."

            default:
                message = "Did not find error code on LAError object"
            }

        }
        message = "Did not find error code on LAError object"

    }

    //return message
    print("LAError message - \(message)")

}

Here is list of all types of LAError for Objective-C

Edit:
If you are trying with Simulator, then see here how to test Face-Id:

*

*Can we test Face ID in simulator?
Here is working Objective-C code. Try this and see:
LAContext *laContext = [[LAContext alloc] init];

NSError *error;

if ([laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {

    if (error != NULL) {
        // handle error
        //[self showError:error];
    } else {

        if (@available(iOS 11.0.1, *)) {
            if (laContext.biometryType == LABiometryTypeFaceID) {
                //localizedReason = "Unlock using Face ID"
                NSLog(@"FaceId support");
            } else if (laContext.biometryType == LABiometryTypeTouchID) {
                //localizedReason = "Unlock using Touch ID"
                NSLog(@"TouchId support");
            } else {
                //localizedReason = "Unlock using Application Passcode"
                NSLog(@"No Biometric support");
            }
        } else {
            // Fallback on earlier versions
        }

        [laContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"Test Reason" reply:^(BOOL success, NSError * _Nullable error) {

            if (error != NULL) {
                // handle error
            } else if (success) {
                // handle success response
            } else {
                // handle false response
            }
        }];
    }
}


text:
Q: Why isn't my scoped slot displaying anything? I'm trying to use Vue's scoped slots:
App.vue:
<template>

      <slot name="col" :col="2">

Some test

      </slot>

</template>

BGrid.vue
<template>

        <template slot="col" scope="props">

This is a column

        </template>

</template>

However, the slot is displayed on the page. No errors in the console:

What am I doing wrong?
Note: I'm using Vue 2.3.4

A: You've got the syntax flipped. You need to define a slot tag in the child component:

      <slot name="col" :col="2"></slot>

Then, in the parent component, use the template tag with the slot attribute to pass in the content to use for that slot:

    <template slot="col" scope="props">

This is a column

    </template>

Here's a fiddle.