Monday 31 July 2023

onChange prop and custom Event dispatch in React

I'm testing new version of my library tagger where there is custom Event dispatch on input element:

this._input.dispatchEvent(new Event('change', { bubbles: true }));

The problem is that onChange prop on that input is not triggered when custom event is triggered.

const App = () => {
    const [tags, setTags] = useState(null)
    const inputRef = useRef(null)

    // Write the Tagger code inside a useEffect hook
    // It will run when the component is initially rendered
    useEffect(() => {
        // Define the Tagger options
        const taggerOptions = {
            allow_spaces: true,
        }

        inputRef.current.addEventListener('change', (e) => {
            console.log(e);
        });

        // Initialize Tagger
        tagger(inputRef.current, taggerOptions)
    }, []);

    const onChange = (e) => {
        setTags(e.target.value)
    };

    return (
        <div className="app">
            <input type="text" ref={inputRef} onChange={onChange} defaultValue="charles, louis, michel" />

            {tags && <pre>{tags}</pre>}
        </div>
    )
}

in the above code, console.log is executed but setTags is not.

Is there a way to make custom change events on input be triggered on default event onChange={}?

If this is not possible I'm fine with an explanation why.

Is this documented somewhere that only native events can be used?

This is a CodePen demo where this can be tested.



from onChange prop and custom Event dispatch in React

How to create a datepicker textfield using Vuetify 3?

I'm using Vuetify 3 and want to have a textfield acting as a datepicker. You can see an example in the Vuetify 2 docs https://v2.vuetifyjs.com/en/components/date-pickers/#dialog-and-menu

The Vuetify 3 docs don't have such an example yet https://vuetifyjs.com/en/components/date-pickers/

I started to prototype an example Playground

<template>
  <v-app>
    <v-container>
      <v-menu v-model="isMenuOpen" :close-on-content-click="false">
        <template v-slot:activator="{ props }">
          <v-text-field
            label="Selected date"
            :model-value="selectedDate"
            readonly
            v-bind="props"
          ></v-text-field>
        </template>
        <v-date-picker v-model="selectedDate"></v-date-picker>
      </v-menu>
    </v-container>
  </v-app>
</template>

<script setup>
  import { ref } from 'vue'

  const isMenuOpen = ref(false)
  const selectedDate = ref()
</script>

How can I remove all the redundant things from the datepicker? I only want to modify the ISO date, nothing else.



from How to create a datepicker textfield using Vuetify 3?

ReactJS - webpack 5 bundle.js is not generating in dist folder

I have to upgrade reactjs project from react 15 to 18+ with supporting node 16+

I made the changes in package.json and webpacl.common.js as below but while running it with using npm run start than it's showing error that bundle.js not found on browser. package.json

{
  "name": "new-client-widget",
  "version": "0.1.0",
  "main": "app.js",
  "scripts": {
    "start": "webpack-dev-server --config webpack.dev.js",
    "build": "NODE_ENV='production' webpack --config webpack.prod.js",
    "test": "jest --no-cache --watch"
  },
  "devDependencies": {
    "@babel/cli": "^7.14.8",
    "@babel/core": "^7.14.8",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/preset-react": "^7.14.5",
    "@open-wc/webpack-import-meta-loader": "^0.4.7",
    "babel-loader": "^8.2.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-react": "^6.24.1",
    "compression-webpack-plugin": "^0.4.0",
    "css-loader": "^6.8.1",
    "empty-folder": "^2.0.1",
    "extract-text-webpack-plugin": "^2.1.0",
    "identity-obj-proxy": "^3.0.0",
    "ify-loader": "^1.1.0",
    "jest": "^29.6.1",
    "jest-enzyme": "^4.2.0",
    "jest-html-reporter": "^2.8.0",
    "node-sass": "^9.0.0",
    "react-test-renderer": "^18.2.0",
    "redux-devtools-extension": "^2.13.2",
    "sass-loader": "^6.0.5",
    "style-loader": "^0.17.0",
    "svg-url-loader": "^8.0.0",
    "webpack": "^5.88.2",
    "webpack-bundle-analyzer": "^4.9.0",
    "webpack-cli": "^5.1.4",
    "webpack-dev-server": "^4.15.1",
    "webpack-merge": "^4.1.1",
    "webpack-shell-plugin-next": "^2.3.1"
  },
  "dependencies": {
    "@babel/preset-env": "^7.22.9",
    "@babel/preset-react": "^7.22.5",
    "ajv": "^6.11.0",
    "bootstrap": "^3.3.7",
    "chartiq": "file:CIQ_Packages/chartiq-8.9.1.tgz",
    "crypto-js": "^3.1.9-1",
    "enzyme": "^3.11.0",
    "enzyme-adapter-react-16": "^1.15.7",
    "faye": "^1.2.4",
    "file-loader": "^0.11.2",
    "html-webpack-plugin": "^5.5.3",
    "js-cookie": "^2.2.0",
    "material-ui": "^0.15.0",
    "moment": "^2.18.1",
    "prop-types": "^15.5.10",
    "react": "^18.2.0",
    "react-bootstrap": "^0.31.2",
    "react-data-grid": "^3.0.11",
    "react-data-grid-addons": "^3.0.11",
    "react-dom": "^18.2.0",
    "react-paginate": "^5.0.0",
    "react-plotly.js": "^2.1.0",
    "react-redux": "^5.0.5",
    "react-router-dom": "^4.2.2",
    "react-select": "^2.4.4",
    "react-tabs": "^2.1.1",
    "react-tooltip": "^3.5.0",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0",
    "remove": "^0.1.5",
    "short-uuid": "^2.3.4",
    "superagent": "^3.8.1",
    "url-loader": "^4.1.1"
  }
}

webpack.common.js

var path = require("path");
var webpack = require("webpack");

module.exports = {
  mode: "development",
  entry: {
    bundle: path.join(__dirname, "src", "js/main.js"),
  },
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bundle.js",
    publicPath: "/dist",
  },
  devServer: {
    host: "0.0.0.0",
    port: 8080,
  },
  resolve: {
    extensions: [".js", ".jsx", ".json"],
  },
  stats: {
    colors: true,
    reasons: true,
    chunks: true,
  },
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader",
          options: {
            presets: ["@babel/preset-react", "@babel/preset-env"],
          },
        },
      },
      {
        test: /\.jsx$/,
        use: "ify-loader",
      },
      {
        test: /\.svg$/,
        use: "svg-url-loader",
      },
      {
        test: /\.scss$/,
        use: "sass-loader",
      },

      {
        test: /\.css$/,
        use: "style-loader!css-loader",
      },
      {
        test: /\.png$/,
        use: "url-loader?limit=100000",
      },
      {
        test: /\.jpg$/,
        use: "file-loader",
      },
      {
        test: /\.html$/,
        use: "file-loader?name=client_widget/[name].[ext]",
      },
      {
        test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
        use: "file-loader?name=client_widget/fonts/[name].[ext]",
      },
      {
        test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
        use: "file-loader?name=client_widget/fonts/[name].[ext]",
      },
      {
        test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
        use: "file-loader?name=client_widget/fonts/[name].[ext]",
      },
    ],
  },
  plugins: [
    new webpack.IgnorePlugin({
      resourceRegExp: /\.\/native/,
      contextRegExp: /\/pg\//,
    }),
  ],
};

can anyone please suggest what I'm missing



from ReactJS - webpack 5 bundle.js is not generating in dist folder

Running Ray on top of AWS Batch multi-node?

I am interested in running Ray on AWS Batch multi-node. This is a pattern that hasn't been done before on Ray, and thus, there's no documentation on it. But, I'd really like to try it since Ray can be installed on-premise as well.

I stood up the AWS Batch multi-node gang-scheduled closer and ran the following commands:

  1. For the head node:
subprocess.Popen(f"ray start --head --node-ip-address {current.parallel.main_ip} --port {master_port} --block", shell=True).wait()
  1. For the worker nodes:
import ray
node_ip_address = ray._private.services.get_node_ip_address()
subprocess.Popen(f"ray start --node-ip-address {node_ip_address} --address {current.parallel.main_ip}:{master_port} --block", shell=True).wait()

The head node seems to be working, but there's some issue with the worker nodes not syncing with the head node.

I get the following output in stderr:

[2023-07-28 09:25:55,500 I 427 427] global_state_accessor.cc:356: This node has an IP address of 10.14.52.21, but we cannot find a local Raylet with the same address. This can happen when you connect to the Ray cluster with a different IP address or when connecting to a container.

Any insight on how I can get Ray working on AWS Batch multi-node would be much appreciated!



from Running Ray on top of AWS Batch multi-node?

Augmented reality (AR) into the three.js editor shows an empty scene

I am running the Three.JS open-source web editor (the source code is here) for my project, and modified it so it works as a standalone. I have configured the editor to satisfy my needs but now I wish to implement augmented reality. For that I'm adding an ARButton using the following code:

window.editor.renderer.xr.enabled = true;
const arButton = ARButton.createButton(window.editor.renderer);
document.body.appendChild(arButton);

Where window.editor.renderer is the project renderer. The problem is that when I click START AR, I'm sent on an empty AR playground even though I have added objects.

So I thought: maybe I'm not using the right renderer instance?

WebGLRenderer instances are created multiple times across the editor source code, but by testing each of them I believe the only one which truly matters is the instance created in Sidebar.Project.Renderer.js. I added, at the bottom of the createRenderer function, this line:

window.editor.renderer = currentRenderer;

Again, however, when I click START AR an empty scene pops-up. I also tried it on my phone (I usually use the WebXR API Emulator by Mozilla) and it's the same.

I don't understand and on top of that I can't find a minimal reproductible example. Every small test I do outside of the Three.JS editor works flawlessly.

Some screenshots: screenshot of the editor scene screenshot of the scene, empty



from Augmented reality (AR) into the three.js editor shows an empty scene

Sunday 30 July 2023

R/Python: Extracting Information from Google Maps

I am working with the R and Python languages.

Suppose I search for the following Canadian Postal Code (M5V 3L9) on Google Maps:

https://www.google.com/maps/place/Toronto,+ON+M5V+3L9/@43.642566,-79.3875851,18z/data=!4m6!3m5!1s0x882b34d436f9c825:0x9e9c6195e38030f2!8m2!3d43.6429129!4d-79.3853443!16s%2Fg%2F1tvq4rqd?entry=ttu

When I search for this, I can see that the "perimeter" of this Postal Code is highlighted in red:

enter image description here

My Question: (Using Selenium via R/Python) From an HTML/CSS/XML perspective - I am trying to get a list of all coordinates that make up the boundary of this perimeter.

I have been trying to explore the source code that is generated from this website to try and see if there is something I can do to see where the source code of this perimeter (e.g. in JSON) is being stored - but so far, I can't find anything:

enter image description here

I was hoping that perhaps there might be something which would allow me to use Selenium to repeatedly click around this perimeter and extract the longitude/latitude points - but so far, I can not find anything.

Can someone please show me how to do this?

Thanks!

Note: Generic Selenium Code:

library(RSelenium)
library(wdman)
library(netstat)

selenium()
seleium_object <- selenium(retcommand = T, check = F)

remote_driver <- rsDriver(browser = "chrome", chromever = "114.0.5735.90", verbose = F, port = free_port())

remDr<- remote_driver$client


remDr$navigate("https://www.google.com/maps/place/Toronto,+ON+M5V+3L9/@43.642566,-79.3875851,18z/data=!4m6!3m5!1s0x882b34d436f9c825:0x9e9c6195e38030f2!8m2!3d43.6429129!4d-79.3853443!16s%2Fg%2F1tvq4rqd?entry=ttu")   

element <- remDr$findElement(using = "class", value = "leaflet-popup-content")
content <- element$getElementText()[[1]]


from R/Python: Extracting Information from Google Maps

Animate text as the user scrolls over a sticky positioned div

I am trying to animate four headings as the user scrolls. First I create a sticky positioned div, then the user scrolls over the headings toggling the class .active one at a time, leaving the last one visible and continuing scrolling to the last div.

The problem I am having is that once the .sticky div becomes sticky the browser no longer detects further scrolling until the div becomes non-sticky again.

--- UPDATE

I have changed the code to transition sequentially and works better, but I would like to start the animations only when the .sticky div becomes sticky, but I tried that and the scroll animation stops working completely. Also, I would like to keep all headings on the same block but If I do position: absolute on them it breaks the animations too.

const headings = Array.from(document.querySelectorAll('.animated-text'));
const sticky = document.querySelector('.sticky');

let currentActive = null;

window.addEventListener('scroll', () => {
  const viewportHeight = window.innerHeight;
  headings.forEach((heading, index) => {
    const headingRect = heading.getBoundingClientRect();

    if (headingRect.top <= viewportHeight / 2) {
      if (currentActive) {
        currentActive.classList.remove('active');
      }
      heading.classList.add('active');
      currentActive = heading;
    }
  });
});
body {
  margin: 0
}

section {
  position: relative;
}

.sticky {
  padding-bottom: 150px;
  background: #2d232c;
  position: sticky;
  top: 0;
  overflow: hidden;
  height: auto;
  color: white;
}

.animated-text {
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: opacity 1s ease, height 1s ease, transform 1s ease;
  transform: translateY(0);
}

.animated-text.active {
  height: auto;
  opacity: 1;
  transform: translateY(-20px);
}

.hero, .end {
  height: 100px;
  background: white;
}
<section class='hero'>
  <p>Start</p>
</section>

<section class='sticky'>
  <div class='text-animations'>
    <h1 class='animated-text active'>Intro</h1>
    <h2 class='animated-text'>First</h2>
    <h2 class='animated-text'>Second</h2>
    <h2 class='animated-text'>Third</h2>
  </div>
  <p class='intro_content'>
     Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam
  </p>  
</section>

<section class='end'>
  <p>End<p>
</section>


from Animate text as the user scrolls over a sticky positioned div

Saturday 29 July 2023

How is unsafeWindow implemented by user script extensions?

Today I came across a situation where I need to make an extension to monkey-patch some objects in a web page.

However I found little to none documentation on how it can actually be achieved, I've tried using the userScripts API (currently exclusive to Firefox) but the window object is contextually isolated from the window on the HTML DOM of the page.

I know that this is possible because user script managers like GreaseMonkey implement an unsafeWindow object which gives the script direct access to objects in the unisolated context of the web page, thus making monkey-patching very easy.

So I would like to know how this is actually achieved. I've attempted to study the source code of an user script manager called ViolentMonkey, I found that it defines unsafeWindow in src/injected/web/gm-api-wrapper.js:53 as a reference to the global object but I could not locate where this in turn is defined in the source code.

I know that this is not implemented by simply injecting a <script> element in the page because none is visible in the page's DOM upon my inspection.

I'm very curious about the implementation of this cool mechanism, I'm pretty sure I missed something obvious so I need your help to remove my blind-folds!



from How is unsafeWindow implemented by user script extensions?

Can you have a progress bar for sorting a list?

I have a list containing ~50k elements of a custom data type (the latter is probably not important for my question) I'm sorting the list using pythons builtin list.sort() method.

myList: List[Foo] = ...
myList.sort(key=Foo.x)

Since the sorting takes a couple of minutes, I would like to have a progress bar for the sorting process. I haven't found any solutions online.

Is this even possible? I'm aware sorting algorithms may be complex and it might not be possible to measure the sorting progress at all. However, it would be fine for my usecase to have a "rough" measurement, like 25%, 50%, 75%...



from Can you have a progress bar for sorting a list?

How to do image pre-processing for depth from focus/defocus using Laplacian using python and opencv?

I have been trying to replicate same results given in the following git repos,

  1. https://github.com/cw1204772/depth_from_focus/tree/master
  2. https://github.com/sangminwoo/Depth_from_Focus/tree/master
  3. https://github.com/iSarmad/Depth-From-Defocus-Matlab/tree/master

I have cloned these repos, but for some reason, I can not generate same depth map as given in the results (in readme) of those repos. Only different thing is my python environment. I am using latest python libs. but I do not get any errors using latest lib. so I am guessing it is fine. Only 1 weird thing is that when I am using these images/datasets https://github.com/cw1204772/depth_from_focus/tree/master/data/keyboard (I am guessing it is pre-processed) I get expected results. but if I used different images such as https://github.com/iSarmad/Depth-From-Defocus-Matlab/tree/master/PA1_dataset2_keyboard. I do not get correct depth map.

What I have tried,

  1. tried changes Laplacian and gaussian kernel size
  2. tried sharpening input images
  3. tried normalizing images
  4. tried resizing PA1_dataset2_keyboard image to the same as https://github.com/cw1204772/depth_from_focus/tree/master/data/keyboard -> 640x360

I have spent 1 week playing with this repos. but I could not get proper depth map. Please help me with this issue. I think I am making some silly error.

my all-in-focus image looks ok, but depth map is looking like following, ![![enter image description here

Thank you very much in advanced.



from How to do image pre-processing for depth from focus/defocus using Laplacian using python and opencv?

How do I convert and display a UTC DateTime to the browsers local time?

I need to show a UTC date time in the users browser as the users(browser) local time.

Ex. 04:52 UTC -> 09:52 PST (if browser/user is in Los Angeles)

as PST is -7 hours from UTC

I have no requirement, it can be done in Javascript, typescript, or using Luxon, which I currently use across my project.



from How do I convert and display a UTC DateTime to the browsers local time?

Friday 28 July 2023

Browser extension for getting data from the next layer page

let's say I have a page (twitch just for example), where I want to display the number of subscribers next to the streamer nickname:

enter image description here

This information is located on "the next" page after clicking the streamer tile:

enter image description here

There is no API, I can get this data only by accessing the tree:

enter image description here

Is there any way to access this data from the next page and display on the previous?

I want to use chrome and js, but any other solutions are accepted if they make it possible.



from Browser extension for getting data from the next layer page

"AttributeError: 'NoneType' object has no attribute 'find'" when converting with OpenTimelineIO

I have video projects that I want to convert from Final Cut Pro to KdenLive. I found the OpenTimelineIO project and it would solve all my problems. I installed with

$ python3 -m pip install opentimelineio
...
$ $ python3 -m pip show opentimelineio
Name: OpenTimelineIO
Version: 0.15.0

I tried the sample code provided:

import opentimelineio as otio

timeline = otio.adapters.read_from_file("/path/to/file.fcpxml")
for clip in timeline.find_clips():
  print(clip.name, clip.duration())

and get the error:

  File "~/Library/Python/3.8/lib/python/site-packages/opentimelineio_contrib/adapters/fcpx_xml.py", line 998, in _format_id_for_clip
    resource = self._compound_clip_by_id(
AttributeError: 'NoneType' object has no attribute 'find'

The offending lines are:

        if resource is None:
            resource = self._compound_clip_by_id(
                clip.get("ref")
            ).find("sequence")

so I monkey-patched the source code around that line to show information about the error:

        if resource is None:
            print("Clip: ", clip)
            print("Clip dir: ", dir(clip))
            tmp_ = clip.get("ref")
            print("Clip.get('href'): ", tmp_)
            tmp2_ = self._compound_clip_by_id(
                clip.get("ref")
            )
            print("Compound clip by id: ", tmp2_)
            resource = self._compound_clip_by_id(
                clip.get("ref")
            ).find("sequence")

and I get:

Clip:  <Element 'title' at 0x1092c3c20>
Clip dir:  ['__class__', '__copy__', '__deepcopy__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'attrib', 'clear', 'extend', 'find', 'findall', 'findtext', 'get', 'getchildren', 'getiterator', 'insert', 'items', 'iter', 'iterfind', 'itertext', 'keys', 'makeelement', 'remove', 'set', 'tag', 'tail', 'text']
Clip.get('href'):  r2
Compound clip by id:  None

The offending clip in the Final Cut Pro XML is the first in the project, a seemingly innocent title:

                        <title ref="r2" offset="0s" name="Atletismo Emocional - Basic Title" start="8996800/2500s" duration="56200/2500s">
                            <param name="Position" key="9999/999166631/999166633/1/100/101" value="1.24609 219.013"/>
                            <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/3001383869/401" value="1 (Center)"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/3001383870/401" value="1 (Center)"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/3001383871/401" value="1 (Center)"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/3001392281/401" value="1 (Center)"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/3001484853/401" value="1 (Center)"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                            <text>
                                <text-style ref="ts1">Atletismo Emocional
</text-style>
                                <text-style ref="ts2">para crianças</text-style>
                                <text-style ref="ts3">

</text-style>
                                <text-style ref="ts4">
</text-style>
                                <text-style ref="ts3">Nº4: Se tens uma emoção, é porque
alguma coisa é importante para ti.</text-style>
                            </text>
                            <text-style-def id="ts1">
                                <text-style font="Helvetica" fontSize="160" fontFace="Regular" fontColor="1 0.999974 0.999991 1" alignment="center"/>
                            </text-style-def>
                            <text-style-def id="ts2">
                                <text-style font="Helvetica" fontSize="100" fontFace="Regular" fontColor="1 0.999974 0.999991 1" alignment="center"/>
                            </text-style-def>
                            <text-style-def id="ts3">
                                <text-style font="Helvetica" fontSize="80" fontFace="Regular" fontColor="1 0.999974 0.999991 1" alignment="center"/>
                            </text-style-def>
                            <text-style-def id="ts4">
                                <text-style font="Helvetica" fontSize="110" fontFace="Regular" fontColor="1 0.999974 0.999991 1" alignment="center"/>
                            </text-style-def>
                            <asset-clip ref="r3" lane="-1" offset="1295588471/360000s" name="GinjaGenerico2" duration="16476588/720000s" format="r4" audioRole="dialogue">
                                <adjust-volume>
                                    <param name="amount">
                                        <fadeIn type="easeIn" duration="200428/720000s"/>
                                        <fadeOut type="easeIn" duration="1080077/720000s"/>
                                    </param>
                                </adjust-volume>
                            </asset-clip>
                        </title>

If I delete this clip, I get a similar error with other clips too:

                            <ref-clip ref="r14" lane="2" offset="49400/2500s" name="wave" start="55602547/2400000s" duration="5200/2500s" useAudioSubroles="1">
                                <conform-rate srcFrameRate="23.98"/>
                                <timeMap>
                                    <timept time="28799771/1280000s" value="28799771/8000s" interp="smooth2"/>
                                    <timept time="27088061/960000s" value="27088061/6000s" interp="smooth2"/>
                                </timeMap>
                                <adjust-transform position="0.222208 0.124992" scale="1.01973 1.01973"/>
                            </ref-clip>

How can I fix the XML or the OpenTimelineIO code to convert this project? Should I submit a bug report to the GitHub repo?



from "AttributeError: 'NoneType' object has no attribute 'find'" when converting with OpenTimelineIO

Thursday 27 July 2023

Why does iframe-resizer not work in this case?

I took a look at this library: iframe-resizer

And tried to use it with this code:

iFrameResize({
  log: true
}, '#myIframe')
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.gallery-container {
  position: relative;
  width: 100%;
  height: 90vh;
  background-color: yellow;
  overflow: hidden;
}

.scrollable-area {
  width: 100%;
  height: 100%;
  overflow-x: auto;
}

.gallery-items {
  display: flex;
  min-width: 100%;
  height: 100%;
}

.gallery-item {
  flex: 0 0 auto;
  height: 100%;
  display: flex;
}

.gallery-item img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

#myIframe {
  background-color: blue;
  width: auto;
  overflow: hidden;
  height: 90vh;
}
<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/iframe-resizer@4.3.6/js/iframeResizer.min.js"></script>

<div class="gallery-container">
  <div class="scrollable-area">
    <div class="gallery-items">

      <div class="gallery-item">
        <iframe id="myIframe" frameborder="0" scrolling="no" src="https://player.vimeo.com/video/584985260" allow="fullscreen"></iframe>
      </div>

      <div class="gallery-item">
        <img src="https://upload.wikimedia.org/wikipedia/commons/1/16/Appearance_of_sky_for_weather_forecast%2C_Dhaka%2C_Bangladesh.JPG">
      </div>
      <div class="gallery-item">
        <img src="https://upload.wikimedia.org/wikipedia/commons/d/da/Sky_landscape.jpg">
      </div>

      <div class="gallery-item">
        <img src="https://upload.wikimedia.org/wikipedia/commons/1/16/Appearance_of_sky_for_weather_forecast%2C_Dhaka%2C_Bangladesh.JPG">
      </div>
    </div>
  </div>
</div>

Regarding the logic of this library, I think the height of the video should adjust to the container. But it doesn't work. Why?



from Why does iframe-resizer not work in this case?

Photoshop Script Returning Error 8800 when exporting video

I am having an issue with exporting video on photoshop as .mp4 and its throwing this error after trying to save.

enter image description here

I don't see an Issue anywhere on my code as to why it would be giving me this error. Here is my code the export and input folder paths are the same. it seems to grab the png files from the input folder fine.

var inputF = Folder('D:/START/');
var sav = Folder('D:/START/');
var alpha = 'F';

if (app.documents.length) {
var doc = activeDocument;
doc.activeLayer = doc.layers.getByName("Design");
var al = doc.activeLayer;
if (al.kind == LayerKind.SMARTOBJECT) {
    if (inputF.exists) {
        var img = inputF.getFiles(/\.(png|jpg)$/i);
        if (img.length > 0) {
            if (sav.exists) {
                for (i = 0; i < img.length; i++) {
                    var imgF = img[i];
                    var imgNm = imgF.displayName.split('.').slice(0, -1).join('.');
                    if (imgNm[imgNm.length - 1] == 'C') {
                        executeAction(stringIDToTypeID('placedLayerEditContents'), new ActionDescriptor(), DialogModes.NO);
                        executeAction(stringIDToTypeID('placedLayerEditContents'), new ActionDescriptor(), DialogModes.NO);
                        var layers = activeDocument.layers;
                        if (layers) {
                            activeDocument.activeLayer = layers[0];
                            replaceeWithImage(imgF);
                            activeDocument.close(SaveOptions.SAVECHANGES);
                            activeDocument.close(SaveOptions.SAVECHANGES);
                            savVideo(sav, imgNm + '-' + alpha + '.mp4');

                        } else {
                            activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                            alert("No Smart Object Layer Found Inside The Smart Object Layer");
                            break;
                        }
                    }
                }
                alert("Images processed successfully!");
                $.sleep(4000);
                doc.close(SaveOptions.DONOTSAVECHANGES);
            }
        }
    }
} else {
    alert("Select The Smart Object Layer Befor Running the script", "Smart Object Layer")
}
} else {
alert("Open a Template First", "Template")
}

function savVideo(outPath, fileName) {
var desc1 = new ActionDescriptor();
var desc2 = new ActionDescriptor();
desc2.putPath(stringIDToTypeID("directory"), new File(outPath));
desc2.putString(charIDToTypeID('Nm  '), fileName);
desc2.putString(stringIDToTypeID("ameFormatName"), "H.264");
desc2.putString(stringIDToTypeID("amePresetName"), "2_Medium Quality.epr");
desc2.putBoolean(stringIDToTypeID("useDocumentSize"), true);
desc2.putBoolean(stringIDToTypeID("useDocumentFrameRate"), true);
desc2.putEnumerated(stringIDToTypeID("pixelAspectRatio"), stringIDToTypeID("pixelAspectRatio"), charIDToTypeID('Dcmn'));
desc2.putEnumerated(stringIDToTypeID("fieldOrder"), stringIDToTypeID("videoField"), stringIDToTypeID("preset"));
desc2.putBoolean(stringIDToTypeID("manage"), true);
desc2.putBoolean(stringIDToTypeID("allFrames"), true);
desc2.putEnumerated(stringIDToTypeID("renderAlpha"), stringIDToTypeID("alphaRendering"), charIDToTypeID('None'));
desc2.putInteger(charIDToTypeID('Qlty'), 1);
desc2.putInteger(stringIDToTypeID("Z3DPrefHighQualityErrorThreshold"), 5);
desc1.putObject(charIDToTypeID('Usng'), stringIDToTypeID("videoExport"), desc2);
executeAction(charIDToTypeID('Expr'), desc1, DialogModes.NO);
};

function replaceeWithImage(filePath) {
try {
    var desc1 = new ActionDescriptor();
    desc1.putPath(charIDToTypeID('null'), new File(filePath));
    executeAction(stringIDToTypeID('placedLayerReplaceContents'), desc1, DialogModes.NO);
    return true;
} catch (e) {
    return false;
}
};


from Photoshop Script Returning Error 8800 when exporting video

Entering numbers from the numpad using pynput (or any other library)

I am trying to enter Alt-codes of symbols using the pynput library (Imitation of pressing "Alt" and entering code on the numpad)

from pynput.keyboard import Key, Controller

keyb = Controller()

def alt_codes(start, finish):  
    for i in range(start, finish + 1):
        keyb.press(Key.alt)
        time.sleep(0.01)
        for j in str(i):
            keyb.press(j)
            time.sleep(0.01)
            keyb.release(j)
            time.sleep(0.01)
        keyb.release(Key.alt)
        time.sleep(0.01)
        keyb.press(Key.space)
        time.sleep(0.01)
        keyb.release(Key.space)

But if I just try to simulate pressing the numbers 0 to 9, it doesn't work, because it simulates pressing the keys that are above the letters, and to enter the Alt code, you need to simulate the numbers from the Numpad. How can I simulate pressing numbers on a numpad? UPD: You can use any other library if needed.



from Entering numbers from the numpad using pynput (or any other library)

d3js Heatmap - month calendar

enter image description here

I'm trying to create a d3.js heatmap month calendar. That only shows 1 month - and is toggled by chevrons left/right. I want to increase the temperature of the day if there is a "booking" for a medical professional.

So the data to overlay onto the month calendar may look something like this to showcase the schedule for that person.

How do I generate just the current month and style it, populate it as planned. The versions I've seen are very similar to github year calendars.

I've been able to get the current month and the number of days in the month. I've created an array for those number of days - but I have not worked out how to fix the x, y spread. I've tried return week(new Date(d+"-Jul-2023")) * cellSize; but its not taken affect.

Jsfiddle https://jsfiddle.net/c0mgvzrf/6/

    <html>
        <head>
            <title>Heatmap d3</title>
            <script src="https://d3js.org/d3.v4.min.js" charset="utf-8"></script>
            <style>
                
            </style>
        </head>
        <body>
    
    
    
        <script>
    
            var data = [
    {"date":"2023-07-20","value":"19"},
    {"date":"2023-07-21","value":"18"},
    {"date":"2023-07-22","value":"25"},
    {"date":"2023-07-23","value":"28"},
    {"date":"2023-07-24","value":"18"},
    {"date":"2023-07-25","value":"25"},
    {"date":"2023-07-26","value":"28"}
                ]
          
         
    
                
    
    var width = 900,
        height = 405,
        cellSize = 25; // cell size
        week_days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
        month = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
        
        var day = d3.timeFormat("%w"),
            week = d3.timeFormat("%U"),
            format = d3.timeFormat("%Y%m%d");
            parseDate = d3.timeFormat("%Y%m%d").parse;
                
        var color = d3.scaleLinear().range(["white", '#002b53'])
            .domain([0, 1])
            
        var svg = d3.select("body").append("svg")
            .attr("height", height)
          .attr("width", width)
            .attr("class", "calendar")
          .append("g")
            .attr("transform", "translate(10, 10)");
    
    var leg = svg.append("g")
                  .attr("class", "leg")
                  .attr("transform", "translate(10, 10)");
                  
    var chart = svg.append("g")
                  .attr("class", "chart")
                  .attr("transform", "translate(-500, 30)");
    //
    const d = new Date();
    let name = month[d.getMonth()];
    console.log("name", name);
      
    
    let pickedYear = 2023;
    let pickedMonth = 7;//July
      
    const daysInMonth = (year, month) => new Date(year, month, 0).getDate();
    
    console.log("daysInMonth", daysInMonth(pickedYear, pickedMonth));
    
    let dz = 1;
    console.log("xx", d3.timeDays(new Date(pickedYear+"-"+pickedMonth+"-1"), new Date(pickedYear+"-"+pickedMonth+"-31")) )
    
    console.log("ccccc",  new Date(pickedYear+"-"+pickedMonth+"-"+daysInMonth)  )
    
    //
    
    
    var rect = chart.selectAll(".day")
        .data(function(d) { return d3.timeDays(new Date("2023-07-1"), new Date("2023-07-31")); })
      .enter()
        .append("rect")
        .attr("class", "day")
        .attr("width", cellSize)
        .attr("height", cellSize)
        .attr("x", function(d) { return week(d) * cellSize; })
        .attr("y", function(d) { return day(d) * cellSize; })
        .attr("fill",'red')
        .attr("stroke",'black')
        .datum(format);
    
    var legend = leg.selectAll(".legend")
          .data(week_days)
        .enter().append("g")
          .attr("class", "legend")
          .attr("transform", function(d, i) { return "translate(" + (((i+1) * 40)+8) + ",0)"; });
    
    legend.append("text")
       .attr("class", function(d,i){ return week_days[i] })
       .style("text-anchor", "end")
       .attr("dy", "-.25em")
       .text(function(d,i){ return week_days[i] });
    
    /*
    d3.csv("data.csv", function(error, csv) {
    
      csv.forEach(function(d) {
        d.Comparison_Type = parseInt(d.Comparison_Type);
      });
    
     var Comparison_Type_Max = d3.max(csv, function(d) { return d.Comparison_Type; });
     
      var data = d3.nest()
        .key(function(d) { return d.Date; })
        .rollup(function(d) { return  Math.sqrt(d[0].Comparison_Type / Comparison_Type_Max); })
        .map(csv);
        
      rect.filter(function(d) { return d in data; })
          .attr("fill", function(d) { return color(data[d]); })
          .attr("data-title", function(d) { return "value : "+Math.round(data[d]*100)});   
        $("rect").tooltip({container: 'body', html: true, placement:'top'}); 
    });
    */
    
    
    
        </script>
    
    
    
        </body>
    </html>


from d3js Heatmap - month calendar

Wednesday 26 July 2023

XGBoost's requires int or float when I actually have int and float

I have the following data:

x_train is np.ndarray, y_train is np.ndarray and model is xgboost.sklearn.XGBClassifier. The types are:

print(type(x_train))
print(x_train.dtype)

>> <class 'numpy.ndarray'>
>> float64

print(type(y_train))
print(y_train.dtype)

>> <class 'numpy.ndarray'>
>> float64

print(type(model))

>> xgboost.sklearn.XGBClassifier

I am using Databricks Runtime 12.2 LTS ML which corresponds to xgboost==1.7.2.

Getting the following error:

model.fit(x_train, y_train)

>> XGBoostError: [09:28:22] ../src/data/data.cc:254: All feature_types must be one of {int, float, i, q, c}.

y_train is actually a vector or 1s and 0s, I have also tried with casting it to np.int32 or np.int64. Then, I tried casting it to builtins.int and builtins.float, as such:

x_train = np.array(x_train, dtype=float)
y_train = np.array(y_train, dtype=int)
print(x_train.dtype)
print(y_train.dtype)

>>float64
>>int64

Same error as before.

I have checked this post but this does not help me as my types are different. I would prefer not to have to convert from numpy dtypes since these have worked in the past and my config files are set in such as way ..

Other relevant packages: sklearn==0.0.post7 and scikit-learn==1.0.2. You can reproduce the error as follows:

import numpy as np
import xgboost as xgb

params = {'base_score': 0.5,
 'booster': 'gbtree',
 'callbacks': 'null',
 'colsample_bylevel': 1,
 'colsample_bynode': 1,
 'colsample_bytree': 1,
 'early_stopping_rounds': 'null',
 'enable_categorical': False,
 'eval_metric': 'aucpr',
 'feature_types': 'null',
 'gamma': 7,
 'gpu_id': -1,
 'grow_policy': 'lossguide',
 'importance_type': 'null',
 'interaction_constraints': '',
 'learning_rate': 0.05610004032698376,
 'max_bin': 256,
 'max_cat_threshold': 64,
 'max_cat_to_onehot': 4,
 'max_delta_step': 0,
 'max_depth': 2,
 'max_leaves': 0,
 'min_child_weight': 1,
 'monotone_constraints': (),
 'n_estimators': 1275,
 'n_jobs': 4,
 'num_parallel_tree': 1,
 'objective': 'binary:logistic',
 'predictor': 'auto',
 'random_state': 0,
 'reg_alpha': 0,
 'reg_lambda': 60,
 'sampling_method': 'uniform',
 'scale_pos_weight': 11.507905606798213,
 'subsample': 1,
 'tree_method': 'hist',
 'use_label_encoder': False,
 'validate_parameters': 1,
 'verbosity': 0}

model = xgb.XGBClassifier(**params)
x = np.random.normal(0,1,(100,10)).astype(np.float64)
y = np.random.uniform(0,1,100).astype(np.int64)
model.fit(x,y)
 



from XGBoost's requires int or float when I actually have int and float

Tuesday 25 July 2023

Javascript, video trailer playback issue with hoover on flip cards' front side

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
  <link rel="stylesheet" 
  href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>

<main>
  <h1>TM</h1>
  <p>Game cards.</p>
  <p><a href="https://github.com/murattasci06"><i class="fab fa-github"></i></a></p>
</main>
<ul>
  <li class="card" onmouseenter="showTrailer('https://www.youtube.com/watch?v=rt-2cxAiPJk')">
    <div class="card__flipper">
      <div class="card__front">
        <img src="https://gecbunlari.com/wp-content/uploads/2021/12/Spiderman-No-Way-Home.jpg" alt="Spiderman">
        <p class="card__name"><span>Marvels</span><br>Spiderman</p>
        <p class="card__num">1</p>
      </div>
      <div class="card__back">
        <svg height="180" width="180">
          <circle cx="90" cy="90" r="55" stroke="#514d9b" stroke-width="35"  />
        </svg>
        <span>113.2</span>
      </div>
    </div>
  </li>
 
  <li class="card">
    <div class="card__flipper">
       <div class="card__front">
         <p class="card__name"><span>Aaron</span><br>Rodgers</p>
        <p class="card__num">12</p>
      </div>
      <div class="card__back">
        <svg height="180" width="180">
          <circle cx="90" cy="90" r="55" stroke="#35a541" stroke-width="35"  />
        </svg>
        <span>112.2</span>
      </div>
    </div>
  </li>
  <li class="card">
    <div class="card__flipper">
       <div class="card__front">
        <p class="card__name"><span>Ben</span><br>Roethlisberger</p>
        <p class="card__num">7</p>
      </div>
      <div class="card__back">
        <svg height="180" width="180">
          <circle cx="90" cy="90" r="55" stroke="#bdb235" stroke-width="35"  />
        </svg>
        <span>103.3</span>
      </div>
    </div>
  </li>
  <li class="card">
    <div class="card__flipper">
       <div class="card__front">
        <p class="card__name"><span>Peyton</span><br>Manning</p>
        <p class="card__num">18</p>
      </div>
      <div class="card__back">
        <svg height="180" width="180">
          <circle cx="90" cy="90" r="55" stroke="#db6623" stroke-width="35"  />
        </svg>
        <span>101.5</span>
      </div>
    </div>
  </li>
  <li class="card">
    <div class="card__flipper">
       <div class="card__front">
        <p class="card__name"><span>Tom</span><br>Brady</p>
        <p class="card__num">Eric</p>
      </div>
      <div class="card__back">
        <svg height="180" width="180">
          <circle cx="90" cy="90" r="55" stroke="#3e5eb3" stroke-width="35"  />
        </svg>
        <span>97.4</span>
      </div>
    </div>
  </li>
  <li class="card">
    <div class="card__flipper">
       <div class="card__front">
        <p class="card__name"><span>Drew</span><br>Brees</p>
        <p class="card__num">9</p>
      </div>
      <div class="card__back">
        <svg height="180" width="180">
          <circle cx="90" cy="90" r="55" stroke="#aa9e5c" stroke-width="35"  />
        </svg>
        <span>97.0</span>
      </div>
    </div>
  </li>
</ul>

<style>
* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-flow: column wrap;
  background: #1f1f1f;
  color: white;
  font-family: "Lato";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

ul {
  margin: 0;
  padding: 0;
  list-style-type: none;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 15px;
  text-align: center;
  overflow-x: hidden;
}

.card {
  float: left;
  position: relative;
  width: calc(33.33% - 30px + 9.999px);
  height: 340px;
  margin: 0 30px 30px 0;
  perspective: 1000;
}
.card:first-child .card__front {
  background:#5271C2;
}

.card__front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card:first-child .card__num {
  text-shadow: 1px 1px rgba(52, 78, 147, 0.8) , 2px 2px rgba(52, 79, 148, 0.802) , 3px 3px rgba(53, 79, 148, 0.804) , 4px 4px rgba(53, 80, 149, 0.806) , 5px 5px rgba(54, 80, 150, 0.808) , 6px 6px rgba(54, 81, 150, 0.81) , 7px 7px rgba(55, 81, 151, 0.812) , 8px 8px rgba(55, 82, 152, 0.814) , 9px 9px rgba(55, 82, 152, 0.816) , 10px 10px rgba(56, 83, 153, 0.818) , 11px 11px rgba(56, 83, 154, 0.82) , 12px 12px rgba(57, 83, 154, 0.822) , 13px 13px rgba(57, 84, 155, 0.824) , 14px 14px rgba(57, 84, 156, 0.826) , 15px 15px rgba(58, 85, 156, 0.828) , 16px 16px rgba(58, 85, 157, 0.83) , 17px 17px rgba(59, 86, 157, 0.832) , 18px 18px rgba(59, 86, 158, 0.834) , 19px 19px rgba(59, 87, 159, 0.836) , 20px 20px rgba(60, 87, 159, 0.838) , 21px 21px rgba(60, 88, 160, 0.84) , 22px 22px rgba(61, 88, 160, 0.842) , 23px 23px rgba(61, 88, 161, 0.844) , 24px 24px rgba(61, 89, 162, 0.846) , 25px 25px rgba(62, 89, 162, 0.848) , 26px 26px rgba(62, 90, 163, 0.85) , 27px 27px rgba(62, 90, 163, 0.852) , 28px 28px rgba(63, 90, 164, 0.854) , 29px 29px rgba(63, 91, 164, 0.856) , 30px 30px rgba(63, 91, 165, 0.858) , 31px 31px rgba(64, 92, 165, 0.86) , 32px 32px rgba(64, 92, 166, 0.862) , 33px 33px rgba(64, 92, 166, 0.864) , 34px 34px rgba(65, 93, 167, 0.866) , 35px 35px rgba(65, 93, 167, 0.868) , 36px 36px rgba(65, 94, 168, 0.87) , 37px 37px rgba(66, 94, 169, 0.872) , 38px 38px rgba(66, 94, 169, 0.874) , 39px 39px rgba(66, 95, 170, 0.876) , 40px 40px rgba(67, 95, 170, 0.878) , 41px 41px rgba(67, 96, 171, 0.88) , 42px 42px rgba(67, 96, 171, 0.882) , 43px 43px rgba(68, 96, 171, 0.884) , 44px 44px rgba(68, 97, 172, 0.886) , 45px 45px rgba(68, 97, 172, 0.888) , 46px 46px rgba(69, 97, 173, 0.89) , 47px 47px rgba(69, 98, 173, 0.892) , 48px 48px rgba(69, 98, 174, 0.894) , 49px 49px rgba(69, 98, 174, 0.896) , 50px 50px rgba(70, 99, 175, 0.898) , 51px 51px rgba(70, 99, 175, 0.9) , 52px 52px rgba(70, 99, 176, 0.902) , 53px 53px rgba(71, 100, 176, 0.904) , 54px 54px rgba(71, 100, 177, 0.906) , 55px 55px rgba(71, 100, 177, 0.908) , 56px 56px rgba(71, 101, 177, 0.91) , 57px 57px rgba(72, 101, 178, 0.912) , 58px 58px rgba(72, 101, 178, 0.914) , 59px 59px rgba(72, 102, 179, 0.916) , 60px 60px rgba(73, 102, 179, 0.918) , 61px 61px rgba(73, 102, 180, 0.92) , 62px 62px rgba(73, 103, 180, 0.922) , 63px 63px rgba(73, 103, 180, 0.924) , 64px 64px rgba(74, 103, 181, 0.926) , 65px 65px rgba(74, 103, 181, 0.928) , 66px 66px rgba(74, 104, 182, 0.93) , 67px 67px rgba(74, 104, 182, 0.932) , 68px 68px rgba(75, 104, 182, 0.934) , 69px 69px rgba(75, 105, 183, 0.936) , 70px 70px rgba(75, 105, 183, 0.938) , 71px 71px rgba(75, 105, 184, 0.94) , 72px 72px rgba(76, 106, 184, 0.942) , 73px 73px rgba(76, 106, 184, 0.944) , 74px 74px rgba(76, 106, 185, 0.946) , 75px 75px rgba(76, 106, 185, 0.948) , 76px 76px rgba(77, 107, 185, 0.95) , 77px 77px rgba(77, 107, 186, 0.952) , 78px 78px rgba(77, 107, 186, 0.954) , 79px 79px rgba(77, 107, 187, 0.956) , 80px 80px rgba(77, 108, 187, 0.958) , 81px 81px rgba(78, 108, 187, 0.96) , 82px 82px rgba(78, 108, 188, 0.962) , 83px 83px rgba(78, 109, 188, 0.964) , 84px 84px rgba(78, 109, 188, 0.966) , 85px 85px rgba(79, 109, 189, 0.968) , 86px 86px rgba(79, 109, 189, 0.97) , 87px 87px rgba(79, 110, 189, 0.972) , 88px 88px rgba(79, 110, 190, 0.974) , 89px 89px rgba(80, 110, 190, 0.976) , 90px 90px rgba(80, 110, 190, 0.978) , 91px 91px rgba(80, 111, 191, 0.98) , 92px 92px rgba(80, 111, 191, 0.982) , 93px 93px rgba(80, 111, 191, 0.984) , 94px 94px rgba(81, 111, 192, 0.986) , 95px 95px rgba(81, 112, 192, 0.988) , 96px 96px rgba(81, 112, 192, 0.99) , 97px 97px rgba(81, 112, 193, 0.992) , 98px 98px rgba(81, 112, 193, 0.994) , 99px 99px rgba(82, 113, 193, 0.996) , 100px 100px rgba(82, 113, 194, 0.998);
}
.card:nth-child(2) .card__front {
  background:#35a541;
}
.card:nth-child(2) .card__num {
  text-shadow: 1px 1px rgba(34, 107, 42, 0.8) , 2px 2px rgba(34, 108, 42, 0.802) , 3px 3px rgba(35, 109, 43, 0.804) , 4px 4px rgba(35, 110, 43, 0.806) , 5px 5px rgba(35, 110, 43, 0.808) , 6px 6px rgba(35, 111, 44, 0.81) , 7px 7px rgba(36, 112, 44, 0.812) , 8px 8px rgba(36, 113, 44, 0.814) , 9px 9px rgba(36, 114, 45, 0.816) , 10px 10px rgba(36, 114, 45, 0.818) , 11px 11px rgba(37, 115, 45, 0.82) , 12px 12px rgba(37, 116, 46, 0.822) , 13px 13px rgba(37, 117, 46, 0.824) , 14px 14px rgba(37, 118, 46, 0.826) , 15px 15px rgba(38, 118, 47, 0.828) , 16px 16px rgba(38, 119, 47, 0.83) , 17px 17px rgba(38, 120, 47, 0.832) , 18px 18px rgba(38, 121, 47, 0.834) , 19px 19px rgba(39, 121, 48, 0.836) , 20px 20px rgba(39, 122, 48, 0.838) , 21px 21px rgba(39, 123, 48, 0.84) , 22px 22px rgba(39, 124, 49, 0.842) , 23px 23px rgba(40, 124, 49, 0.844) , 24px 24px rgba(40, 125, 49, 0.846) , 25px 25px rgba(40, 126, 49, 0.848) , 26px 26px rgba(40, 126, 50, 0.85) , 27px 27px rgba(41, 127, 50, 0.852) , 28px 28px rgba(41, 128, 50, 0.854) , 29px 29px rgba(41, 128, 50, 0.856) , 30px 30px rgba(41, 129, 51, 0.858) , 31px 31px rgba(41, 130, 51, 0.86) , 32px 32px rgba(42, 130, 51, 0.862) , 33px 33px rgba(42, 131, 52, 0.864) , 34px 34px rgba(42, 132, 52, 0.866) , 35px 35px rgba(42, 132, 52, 0.868) , 36px 36px rgba(42, 133, 52, 0.87) , 37px 37px rgba(43, 134, 53, 0.872) , 38px 38px rgba(43, 134, 53, 0.874) , 39px 39px rgba(43, 135, 53, 0.876) , 40px 40px rgba(43, 135, 53, 0.878) , 41px 41px rgba(44, 136, 54, 0.88) , 42px 42px rgba(44, 137, 54, 0.882) , 43px 43px rgba(44, 137, 54, 0.884) , 44px 44px rgba(44, 138, 54, 0.886) , 45px 45px rgba(44, 138, 54, 0.888) , 46px 46px rgba(44, 139, 55, 0.89) , 47px 47px rgba(45, 140, 55, 0.892) , 48px 48px rgba(45, 140, 55, 0.894) , 49px 49px rgba(45, 141, 55, 0.896) , 50px 50px rgba(45, 141, 56, 0.898) , 51px 51px rgba(45, 142, 56, 0.9) , 52px 52px rgba(46, 142, 56, 0.902) , 53px 53px rgba(46, 143, 56, 0.904) , 54px 54px rgba(46, 143, 56, 0.906) , 55px 55px rgba(46, 144, 57, 0.908) , 56px 56px rgba(46, 145, 57, 0.91) , 57px 57px rgba(46, 145, 57, 0.912) , 58px 58px rgba(47, 146, 57, 0.914) , 59px 59px rgba(47, 146, 58, 0.916) , 60px 60px rgba(47, 147, 58, 0.918) , 61px 61px rgba(47, 147, 58, 0.92) , 62px 62px rgba(47, 148, 58, 0.922) , 63px 63px rgba(47, 148, 58, 0.924) , 64px 64px rgba(48, 149, 59, 0.926) , 65px 65px rgba(48, 149, 59, 0.928) , 66px 66px rgba(48, 150, 59, 0.93) , 67px 67px rgba(48, 150, 59, 0.932) , 68px 68px rgba(48, 151, 59, 0.934) , 69px 69px rgba(48, 151, 60, 0.936) , 70px 70px rgba(49, 152, 60, 0.938) , 71px 71px rgba(49, 152, 60, 0.94) , 72px 72px rgba(49, 153, 60, 0.942) , 73px 73px rgba(49, 153, 60, 0.944) , 74px 74px rgba(49, 154, 60, 0.946) , 75px 75px rgba(49, 154, 61, 0.948) , 76px 76px rgba(50, 154, 61, 0.95) , 77px 77px rgba(50, 155, 61, 0.952) , 78px 78px rgba(50, 155, 61, 0.954) , 79px 79px rgba(50, 156, 61, 0.956) , 80px 80px rgba(50, 156, 62, 0.958) , 81px 81px rgba(50, 157, 62, 0.96) , 82px 82px rgba(50, 157, 62, 0.962) , 83px 83px rgba(51, 158, 62, 0.964) , 84px 84px rgba(51, 158, 62, 0.966) , 85px 85px rgba(51, 158, 62, 0.968) , 86px 86px rgba(51, 159, 63, 0.97) , 87px 87px rgba(51, 159, 63, 0.972) , 88px 88px rgba(51, 160, 63, 0.974) , 89px 89px rgba(51, 160, 63, 0.976) , 90px 90px rgba(52, 161, 63, 0.978) , 91px 91px rgba(52, 161, 63, 0.98) , 92px 92px rgba(52, 161, 64, 0.982) , 93px 93px rgba(52, 162, 64, 0.984) , 94px 94px rgba(52, 162, 64, 0.986) , 95px 95px rgba(52, 163, 64, 0.988) , 96px 96px rgba(52, 163, 64, 0.99) , 97px 97px rgba(52, 163, 64, 0.992) , 98px 98px rgba(53, 164, 65, 0.994) , 99px 99px rgba(53, 164, 65, 0.996) , 100px 100px rgba(53, 165, 65, 0.998);
}
.card:nth-child(3) {
  margin-right: 0;
}
.card:nth-child(3) .card__front {
  background: #bdb235;
}
.card:nth-child(3) .card__num {
  text-shadow: 1px 1px rgba(129, 122, 36, 0.8) , 2px 2px rgba(130, 123, 36, 0.802) , 3px 3px rgba(131, 124, 37, 0.804) , 4px 4px rgba(132, 124, 37, 0.806) , 5px 5px rgba(133, 125, 37, 0.808) , 6px 6px rgba(133, 126, 37, 0.81) , 7px 7px rgba(134, 127, 37, 0.812) , 8px 8px rgba(135, 128, 38, 0.814) , 9px 9px rgba(136, 128, 38, 0.816) , 10px 10px rgba(137, 129, 38, 0.818) , 11px 11px rgba(138, 130, 38, 0.82) , 12px 12px rgba(138, 131, 39, 0.822) , 13px 13px rgba(139, 132, 39, 0.824) , 14px 14px rgba(140, 132, 39, 0.826) , 15px 15px rgba(141, 133, 39, 0.828) , 16px 16px rgba(142, 134, 40, 0.83) , 17px 17px rgba(142, 134, 40, 0.832) , 18px 18px rgba(143, 135, 40, 0.834) , 19px 19px rgba(144, 136, 40, 0.836) , 20px 20px rgba(145, 137, 40, 0.838) , 21px 21px rgba(145, 137, 41, 0.84) , 22px 22px rgba(146, 138, 41, 0.842) , 23px 23px rgba(147, 139, 41, 0.844) , 24px 24px rgba(148, 139, 41, 0.846) , 25px 25px rgba(148, 140, 41, 0.848) , 26px 26px rgba(149, 141, 42, 0.85) , 27px 27px rgba(150, 141, 42, 0.852) , 28px 28px rgba(150, 142, 42, 0.854) , 29px 29px rgba(151, 143, 42, 0.856) , 30px 30px rgba(152, 143, 42, 0.858) , 31px 31px rgba(152, 144, 43, 0.86) , 32px 32px rgba(153, 145, 43, 0.862) , 33px 33px rgba(154, 145, 43, 0.864) , 34px 34px rgba(154, 146, 43, 0.866) , 35px 35px rgba(155, 146, 43, 0.868) , 36px 36px rgba(156, 147, 44, 0.87) , 37px 37px rgba(156, 148, 44, 0.872) , 38px 38px rgba(157, 148, 44, 0.874) , 39px 39px rgba(158, 149, 44, 0.876) , 40px 40px rgba(158, 149, 44, 0.878) , 41px 41px rgba(159, 150, 45, 0.88) , 42px 42px rgba(160, 151, 45, 0.882) , 43px 43px rgba(160, 151, 45, 0.884) , 44px 44px rgba(161, 152, 45, 0.886) , 45px 45px rgba(161, 152, 45, 0.888) , 46px 46px rgba(162, 153, 45, 0.89) , 47px 47px rgba(163, 153, 46, 0.892) , 48px 48px rgba(163, 154, 46, 0.894) , 49px 49px rgba(164, 155, 46, 0.896) , 50px 50px rgba(164, 155, 46, 0.898) , 51px 51px rgba(165, 156, 46, 0.9) , 52px 52px rgba(166, 156, 46, 0.902) , 53px 53px rgba(166, 157, 47, 0.904) , 54px 54px rgba(167, 157, 47, 0.906) , 55px 55px rgba(167, 158, 47, 0.908) , 56px 56px rgba(168, 158, 47, 0.91) , 57px 57px rgba(168, 159, 47, 0.912) , 58px 58px rgba(169, 159, 47, 0.914) , 59px 59px rgba(169, 160, 47, 0.916) , 60px 60px rgba(170, 160, 48, 0.918) , 61px 61px rgba(171, 161, 48, 0.92) , 62px 62px rgba(171, 161, 48, 0.922) , 63px 63px rgba(172, 162, 48, 0.924) , 64px 64px rgba(172, 162, 48, 0.926) , 65px 65px rgba(173, 163, 48, 0.928) , 66px 66px rgba(173, 163, 49, 0.93) , 67px 67px rgba(174, 164, 49, 0.932) , 68px 68px rgba(174, 164, 49, 0.934) , 69px 69px rgba(175, 165, 49, 0.936) , 70px 70px rgba(175, 165, 49, 0.938) , 71px 71px rgba(176, 166, 49, 0.94) , 72px 72px rgba(176, 166, 49, 0.942) , 73px 73px rgba(177, 166, 50, 0.944) , 74px 74px rgba(177, 167, 50, 0.946) , 75px 75px rgba(178, 167, 50, 0.948) , 76px 76px rgba(178, 168, 50, 0.95) , 77px 77px rgba(179, 168, 50, 0.952) , 78px 78px rgba(179, 169, 50, 0.954) , 79px 79px rgba(180, 169, 50, 0.956) , 80px 80px rgba(180, 170, 50, 0.958) , 81px 81px rgba(180, 170, 51, 0.96) , 82px 82px rgba(181, 170, 51, 0.962) , 83px 83px rgba(181, 171, 51, 0.964) , 84px 84px rgba(182, 171, 51, 0.966) , 85px 85px rgba(182, 172, 51, 0.968) , 86px 86px rgba(183, 172, 51, 0.97) , 87px 87px rgba(183, 173, 51, 0.972) , 88px 88px rgba(184, 173, 51, 0.974) , 89px 89px rgba(184, 173, 52, 0.976) , 90px 90px rgba(184, 174, 52, 0.978) , 91px 91px rgba(185, 174, 52, 0.98) , 92px 92px rgba(185, 175, 52, 0.982) , 93px 93px rgba(186, 175, 52, 0.984) , 94px 94px rgba(186, 175, 52, 0.986) , 95px 95px rgba(187, 176, 52, 0.988) , 96px 96px rgba(187, 176, 52, 0.99) , 97px 97px rgba(187, 176, 53, 0.992) , 98px 98px rgba(188, 177, 53, 0.994) , 99px 99px rgba(188, 177, 53, 0.996) , 100px 100px rgba(189, 178, 53, 0.998);
}
.card:nth-child(4) .card__front {
  background: #db6623;
}
.card:nth-child(4) .card__num {
  text-shadow: 1px 1px rgba(153, 71, 24, 0.8) , 2px 2px rgba(154, 71, 24, 0.802) , 3px 3px rgba(155, 72, 24, 0.804) , 4px 4px rgba(156, 72, 24, 0.806) , 5px 5px rgba(157, 73, 25, 0.808) , 6px 6px rgba(158, 73, 25, 0.81) , 7px 7px rgba(159, 74, 25, 0.812) , 8px 8px rgba(160, 74, 25, 0.814) , 9px 9px rgba(161, 75, 25, 0.816) , 10px 10px rgba(162, 75, 25, 0.818) , 11px 11px rgba(162, 75, 26, 0.82) , 12px 12px rgba(163, 76, 26, 0.822) , 13px 13px rgba(164, 76, 26, 0.824) , 14px 14px rgba(165, 77, 26, 0.826) , 15px 15px rgba(166, 77, 26, 0.828) , 16px 16px rgba(167, 77, 26, 0.83) , 17px 17px rgba(168, 78, 26, 0.832) , 18px 18px rgba(169, 78, 27, 0.834) , 19px 19px rgba(169, 79, 27, 0.836) , 20px 20px rgba(170, 79, 27, 0.838) , 21px 21px rgba(171, 79, 27, 0.84) , 22px 22px rgba(172, 80, 27, 0.842) , 23px 23px rgba(173, 80, 27, 0.844) , 24px 24px rgba(173, 81, 27, 0.846) , 25px 25px rgba(174, 81, 28, 0.848) , 26px 26px rgba(175, 81, 28, 0.85) , 27px 27px rgba(176, 82, 28, 0.852) , 28px 28px rgba(177, 82, 28, 0.854) , 29px 29px rgba(177, 82, 28, 0.856) , 30px 30px rgba(178, 83, 28, 0.858) , 31px 31px rgba(179, 83, 28, 0.86) , 32px 32px rgba(180, 83, 28, 0.862) , 33px 33px rgba(180, 84, 29, 0.864) , 34px 34px rgba(181, 84, 29, 0.866) , 35px 35px rgba(182, 85, 29, 0.868) , 36px 36px rgba(182, 85, 29, 0.87) , 37px 37px rgba(183, 85, 29, 0.872) , 38px 38px rgba(184, 86, 29, 0.874) , 39px 39px rgba(185, 86, 29, 0.876) , 40px 40px rgba(185, 86, 29, 0.878) , 41px 41px rgba(186, 87, 30, 0.88) , 42px 42px rgba(187, 87, 30, 0.882) , 43px 43px rgba(187, 87, 30, 0.884) , 44px 44px rgba(188, 87, 30, 0.886) , 45px 45px rgba(189, 88, 30, 0.888) , 46px 46px rgba(189, 88, 30, 0.89) , 47px 47px rgba(190, 88, 30, 0.892) , 48px 48px rgba(191, 89, 30, 0.894) , 49px 49px rgba(191, 89, 30, 0.896) , 50px 50px rgba(192, 89, 30, 0.898) , 51px 51px rgba(193, 90, 31, 0.9) , 52px 52px rgba(193, 90, 31, 0.902) , 53px 53px rgba(194, 90, 31, 0.904) , 54px 54px rgba(194, 90, 31, 0.906) , 55px 55px rgba(195, 91, 31, 0.908) , 56px 56px rgba(196, 91, 31, 0.91) , 57px 57px rgba(196, 91, 31, 0.912) , 58px 58px rgba(197, 92, 31, 0.914) , 59px 59px rgba(198, 92, 31, 0.916) , 60px 60px rgba(198, 92, 32, 0.918) , 61px 61px rgba(199, 92, 32, 0.92) , 62px 62px rgba(199, 93, 32, 0.922) , 63px 63px rgba(200, 93, 32, 0.924) , 64px 64px rgba(200, 93, 32, 0.926) , 65px 65px rgba(201, 94, 32, 0.928) , 66px 66px rgba(202, 94, 32, 0.93) , 67px 67px rgba(202, 94, 32, 0.932) , 68px 68px rgba(203, 94, 32, 0.934) , 69px 69px rgba(203, 95, 32, 0.936) , 70px 70px rgba(204, 95, 32, 0.938) , 71px 71px rgba(204, 95, 33, 0.94) , 72px 72px rgba(205, 95, 33, 0.942) , 73px 73px rgba(205, 96, 33, 0.944) , 74px 74px rgba(206, 96, 33, 0.946) , 75px 75px rgba(206, 96, 33, 0.948) , 76px 76px rgba(207, 96, 33, 0.95) , 77px 77px rgba(208, 97, 33, 0.952) , 78px 78px rgba(208, 97, 33, 0.954) , 79px 79px rgba(209, 97, 33, 0.956) , 80px 80px rgba(209, 97, 33, 0.958) , 81px 81px rgba(210, 98, 33, 0.96) , 82px 82px rgba(210, 98, 34, 0.962) , 83px 83px rgba(211, 98, 34, 0.964) , 84px 84px rgba(211, 98, 34, 0.966) , 85px 85px rgba(212, 99, 34, 0.968) , 86px 86px rgba(212, 99, 34, 0.97) , 87px 87px rgba(213, 99, 34, 0.972) , 88px 88px rgba(213, 99, 34, 0.974) , 89px 89px rgba(214, 99, 34, 0.976) , 90px 90px rgba(214, 100, 34, 0.978) , 91px 91px rgba(214, 100, 34, 0.98) , 92px 92px rgba(215, 100, 34, 0.982) , 93px 93px rgba(215, 100, 34, 0.984) , 94px 94px rgba(216, 101, 34, 0.986) , 95px 95px rgba(216, 101, 35, 0.988) , 96px 96px rgba(217, 101, 35, 0.99) , 97px 97px rgba(217, 101, 35, 0.992) , 98px 98px rgba(218, 101, 35, 0.994) , 99px 99px rgba(218, 102, 35, 0.996) , 100px 100px rgba(219, 102, 35, 0.998);
}
.card:nth-child(5) .card__front {
  background: #3e5eb3;
}
.card:nth-child(5) .card__num {
  text-shadow: 1px 1px rgba(42, 64, 122, 0.8) , 2px 2px rgba(42, 64, 123, 0.802) , 3px 3px rgba(43, 65, 124, 0.804) , 4px 4px rgba(43, 65, 125, 0.806) , 5px 5px rgba(43, 66, 125, 0.808) , 6px 6px rgba(43, 66, 126, 0.81) , 7px 7px rgba(44, 67, 127, 0.812) , 8px 8px rgba(44, 67, 128, 0.814) , 9px 9px rgba(44, 67, 129, 0.816) , 10px 10px rgba(45, 68, 129, 0.818) , 11px 11px rgba(45, 68, 130, 0.82) , 12px 12px rgba(45, 69, 131, 0.822) , 13px 13px rgba(45, 69, 132, 0.824) , 14px 14px rgba(46, 69, 132, 0.826) , 15px 15px rgba(46, 70, 133, 0.828) , 16px 16px rgba(46, 70, 134, 0.83) , 17px 17px rgba(46, 71, 135, 0.832) , 18px 18px rgba(47, 71, 135, 0.834) , 19px 19px rgba(47, 71, 136, 0.836) , 20px 20px rgba(47, 72, 137, 0.838) , 21px 21px rgba(47, 72, 138, 0.84) , 22px 22px rgba(48, 73, 138, 0.842) , 23px 23px rgba(48, 73, 139, 0.844) , 24px 24px rgba(48, 73, 140, 0.846) , 25px 25px rgba(48, 74, 140, 0.848) , 26px 26px rgba(49, 74, 141, 0.85) , 27px 27px rgba(49, 74, 142, 0.852) , 28px 28px rgba(49, 75, 142, 0.854) , 29px 29px rgba(49, 75, 143, 0.856) , 30px 30px rgba(50, 75, 144, 0.858) , 31px 31px rgba(50, 76, 144, 0.86) , 32px 32px rgba(50, 76, 145, 0.862) , 33px 33px rgba(50, 76, 146, 0.864) , 34px 34px rgba(50, 77, 146, 0.866) , 35px 35px rgba(51, 77, 147, 0.868) , 36px 36px rgba(51, 77, 147, 0.87) , 37px 37px rgba(51, 78, 148, 0.872) , 38px 38px rgba(51, 78, 149, 0.874) , 39px 39px rgba(52, 78, 149, 0.876) , 40px 40px rgba(52, 79, 150, 0.878) , 41px 41px rgba(52, 79, 151, 0.88) , 42px 42px rgba(52, 79, 151, 0.882) , 43px 43px rgba(52, 80, 152, 0.884) , 44px 44px rgba(53, 80, 152, 0.886) , 45px 45px rgba(53, 80, 153, 0.888) , 46px 46px rgba(53, 81, 153, 0.89) , 47px 47px rgba(53, 81, 154, 0.892) , 48px 48px rgba(53, 81, 155, 0.894) , 49px 49px rgba(54, 81, 155, 0.896) , 50px 50px rgba(54, 82, 156, 0.898) , 51px 51px rgba(54, 82, 156, 0.9) , 52px 52px rgba(54, 82, 157, 0.902) , 53px 53px rgba(54, 83, 157, 0.904) , 54px 54px rgba(55, 83, 158, 0.906) , 55px 55px rgba(55, 83, 158, 0.908) , 56px 56px rgba(55, 83, 159, 0.91) , 57px 57px rgba(55, 84, 159, 0.912) , 58px 58px rgba(55, 84, 160, 0.914) , 59px 59px rgba(55, 84, 160, 0.916) , 60px 60px rgba(56, 85, 161, 0.918) , 61px 61px rgba(56, 85, 161, 0.92) , 62px 62px rgba(56, 85, 162, 0.922) , 63px 63px rgba(56, 85, 162, 0.924) , 64px 64px rgba(56, 86, 163, 0.926) , 65px 65px rgba(57, 86, 163, 0.928) , 66px 66px rgba(57, 86, 164, 0.93) , 67px 67px rgba(57, 86, 164, 0.932) , 68px 68px rgba(57, 87, 165, 0.934) , 69px 69px rgba(57, 87, 165, 0.936) , 70px 70px rgba(57, 87, 166, 0.938) , 71px 71px rgba(58, 87, 166, 0.94) , 72px 72px rgba(58, 88, 167, 0.942) , 73px 73px rgba(58, 88, 167, 0.944) , 74px 74px rgba(58, 88, 168, 0.946) , 75px 75px rgba(58, 88, 168, 0.948) , 76px 76px rgba(58, 89, 169, 0.95) , 77px 77px rgba(59, 89, 169, 0.952) , 78px 78px rgba(59, 89, 170, 0.954) , 79px 79px rgba(59, 89, 170, 0.956) , 80px 80px rgba(59, 89, 170, 0.958) , 81px 81px rgba(59, 90, 171, 0.96) , 82px 82px rgba(59, 90, 171, 0.962) , 83px 83px rgba(59, 90, 172, 0.964) , 84px 84px rgba(60, 90, 172, 0.966) , 85px 85px rgba(60, 91, 173, 0.968) , 86px 86px rgba(60, 91, 173, 0.97) , 87px 87px rgba(60, 91, 173, 0.972) , 88px 88px rgba(60, 91, 174, 0.974) , 89px 89px rgba(60, 92, 174, 0.976) , 90px 90px rgba(60, 92, 175, 0.978) , 91px 91px rgba(61, 92, 175, 0.98) , 92px 92px rgba(61, 92, 175, 0.982) , 93px 93px rgba(61, 92, 176, 0.984) , 94px 94px rgba(61, 93, 176, 0.986) , 95px 95px rgba(61, 93, 177, 0.988) , 96px 96px rgba(61, 93, 177, 0.99) , 97px 97px rgba(61, 93, 177, 0.992) , 98px 98px rgba(62, 93, 178, 0.994) , 99px 99px rgba(62, 94, 178, 0.996) , 100px 100px rgba(62, 94, 179, 0.998);
}
.card:nth-child(6) .card__front {
  background: #aa9e5c;
}
.card:nth-child(6) .card__num {
  text-shadow: 1px 1px rgba(122, 113, 64, 0.8);
}
.card:last-child {
  margin-right: 0;
}
.card__flipper {
  cursor: pointer;
  transform-style: preserve-3d;
  transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}
.card__front, .card__back {
  position: absolute;
  backface-visibility: hidden;
  top: 0;
  left: 0;
  width: 100%;
  height: 340px;
}
.card__front {
  transform: rotateY(0);
  z-index: 2;
  overflow: hidden;
}
.card__back {
  transform: rotateY(180deg) scale(1.1);
  background: #141414;
  display: flex;
  flex-flow: column wrap;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.card__back span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.card__name {
  font-size: 32px;
  line-height: 0.9;
  font-weight: 700;
}
.card__name span {
  font-size: 14px;
}
.card__num {
  font-size: 100px;
  margin: 0 8px 0 0;
  font-weight: 700;
}
@media (max-width: 700px) {
  .card__num {
    font-size: 70px;
  }
}
@media (max-width: 700px) {
  .card {
    width: 100%;
    height: 290px;
    margin-right: 0;
    float: none;
  }
  .card .card__front,
  .card .card__back {
    height: 290px;
  }
}

/* Demo */
main {
  text-align: center;
}
main h1, main p {
  margin: 0 0 12px 0;
}
main h1 {
  margin-top: 12px;
  font-weight: 300;
}

.fa-github {
  color: white; 
  font-size: 30px;
}


</style>

<script>
var Flipper = (function() {
  var card = $('.card');
  var flipper = card.find('.card__flipper');
  var win = $(window);
  
  var flip = function() {
    var thisCard = $(this);
    var thisFlipper = thisCard.find('.card__flipper');
    var offset = thisCard.offset();
    var xc = win.width() / 2;
    var yc = win.height() / 2;
    var docScroll = $(document).scrollTop();
    var cardW = thisCard.outerWidth() / 2;
    var cardH = thisCard.height() / 2;

    var transX = xc - offset.left - cardW;
    var transY = docScroll + yc - offset.top - cardH;
//     if (offset.top > card.height()) transY = docScroll - offset.top + cardH;
    if (win.width() <= 700) transY = 0;
    
    if (card.hasClass('active')) unflip();
        
    thisCard.css({'z-index': '3'}).addClass('active');
    
    thisFlipper.css({
      'transform': 'translate3d(' + transX + 'px,' + transY + 'px, 0) rotateY(180deg) scale(1)',
      '-webkit-transform': 'translate3d(' + transX + 'px,' + transY + 'px, 0) rotateY(180deg) scale(1)',
      '-ms-transform': 'translate3d(' + transX + 'px,' + transY + 'px, 0) rotateY(180deg) scale(1)'
    }).addClass('active');
    
    return false;
  };
  
  var unflip = function(e) {
    card.css({'z-index': '1'}).removeClass('active');
    flipper.css({
      'transform': 'none',
      '-webkit-transform': 'none',
      '-ms-transform': 'none'
    }).removeClass('active');
  };
  
  var bindActions = function() {
    card.on('click', flip);
    win.on('click', unflip);
  }
  
  var init = function() {
    bindActions();
  };
  
  return {
    init: init
  };
  
}());
Flipper.init();  
</script>

<!-- HOOVER FOR TRAILER -->
<script>
let timeoutId;
  let isHovering = false;

  function showTrailer(videoUrl) {
    isHovering = true;
    timeoutId = setTimeout(() => {
      if (isHovering) {
        let cardBack = document.querySelector(".card__back");
        cardBack.innerHTML = `
          <iframe width="180" height="180" src="${videoUrl}?autoplay=1" frameborder="0" allowfullscreen></iframe>
          <span>113.2</span>
        `;
        cardBack.style.backgroundColor = "#514d9b";
        cardBack.style.transform = "rotateY(180deg)";
      }
    }, 4000);
  }

  function hideTrailer() {
    isHovering = false;
    clearTimeout(timeoutId);

    let cardBack = document.querySelector(".card__back");
    cardBack.innerHTML = `<span>113.2</span>`;
    cardBack.style.backgroundColor = "#fff";
    cardBack.style.transform = "rotateY(0)";
  }
</script>

Hello friends, I have 6 revolving cards that are opened when the left mouse button is clicked. For these six cards, I want to play the trailer of the movie when I wait 4 seconds with the mouse on the front of the card. If the mouse is not on the card, the front of the card will be shown again, but with the code I added (HOOVER FOR TRAILER) it is trying to do something on the back of the card and I didn't get what I wanted. How can I do what I want?

Desired behavior: enter image description here

Undesired behavior for backend: enter image description here

Original backend: enter image description here



from Javascript, video trailer playback issue with hoover on flip cards' front side

How to invoke Github Copilot programmatically?

I am currently exploring GitHub Copilot and I am interested in using it programmatically, i.e., invoking it from code. As I understand, GitHub Copilot is an IDE plugin, which makes me wonder how it can be automated or controlled programmatically.

Does GitHub Copilot provide any API access or is there a way to interact with it programmatically?



from How to invoke Github Copilot programmatically?

Error trying to add JavaScript to Azure B2C Local Signup Page

I have the following arbitrary JavaScript snippet on an HTML page stored in Azure Storage (using a screenshot to try to demonstrate, as far as I can see, that the syntax is correct): enter image description here

The page loads, it is styled correctly and everything else you would expect, proving that it is configured correctly, CORS is set etc. But the JavaScript does not run. Instead I get this error:

unified:5 Uncaught SyntaxError: Unexpected token '&'
at br (unified?local=signup&[omitted_for_brevity])
at at (unified?local=signup&[omitted_for_brevity])
at i.fn.init.append (unified?local=signup&[omitted_for_brevity])
at unified?local=signup&[omitted_for_brevity]

This is presumably being caused by this: enter image description here

Extra script caused by some kind of parse or encoding error on the original script tag.

If I load the file from storage container directly, it loads and the JavaScript fires with no problems. This tells me the HTML file is fine, so either:

  • how I am loading it does not play nicely with B2C
  • I have not configured something on the B2C side to allow JavaScript
  • Something else

I have configured everything that I can see on the User Flow:

  • Enable JavaScript enforcing page layout is set to On
  • Path to custom HTML is set
  • CORS is configured for the custom HTML

Has anyone seen this problem before or can see what I may have done wrong in how this is configured?

Edit: Am roughly following this guide: https://learn.microsoft.com/en-us/azure/active-directory-b2c/javascript-and-page-layout?pivots=b2c-user-flow



from Error trying to add JavaScript to Azure B2C Local Signup Page

Loading data drawn to HTML canvas from API into p5js

I have a project where there are two canvases that need to be combined, one inside p5 and one outside. The first is a p5js sketch (created via createCanvas that is essentially a drawing application) and the second is auto-created via an API call to a map service (our use case is to basically annotate a map).

For reference, the API looks for a div with a particular ID and then appends the new canvas element.

What we'd like to do is stitch together the two images into a savable image for the user. The bottom layer would be coming from the map API canvas and the top layer would be the user-drawn annotations.

The issue we're facing is that the automatically-created canvas is coming in as a webgl context, so we don't seem to be able to use any of the basic methods for getting canvas data in a 2d context.

Is there an easy way to do this that I'm overlooking, or do I need to start figuring out how to parse out webgl data into a graphics object's pixels array?

The picture below is what we have so far - the drawing works, the map is loaded fine, now we just need to save them as a full image for the user.

screenshot



from Loading data drawn to HTML canvas from API into p5js

Break up async mocha test into multiple tests

To provide better test reporting, I am trying to break up some tests which contain a lot of steps to smaller steps. https://github.com/rocket-pool/rocketpool/blob/master/test/deposit/deposit-pool-tests.js

For example,

it(printTitle('staker', 'deposits 10 eth'), async () => {
        // Deposit
        await deposit({
            from: staker,
            value: '10'.ether,
        });

        // Get current rETH exchange rate
        let exchangeRate1 = await getRethExchangeRate();

        // Update network ETH total to 130% to alter rETH exchange rate
        let totalBalance = '13'.ether;
        let rethSupply = await getRethTotalSupply();
        await submitBalances(1, totalBalance, 0, rethSupply, {from: trustedNode});

        // Get & check updated rETH exchange rate
        let exchangeRate2 = await getRethExchangeRate();
        assertBN.notEqual(exchangeRate1, exchangeRate2, 'rETH exchange rate has not changed');

        // Deposit again with updated rETH exchange rate
        await deposit({
            from: staker,
            value: '10'.ether,
        });
    });

I would like to break this up into 5 it steps.

1. The staker deposits 10 ETH
2. The rETH exchange rate is retreived
3. The network ETH total is updated to 130% to alter rETH exchange rate
4. The rETH exchange rate is checked
5. The staker can deposit again with the updated rETH exchange rate

The problem is when I do this, the results of step 3 do not make it to step 4, and thus it fails. How can I properly use promises to accomplish this? Here is what I am trying using mocha-cakes, getting an error that exchangeRate1 is equal to exchangeRate2

 Scenario('Staker can make a deposit before and after updating the rETH exchange rate',  () => { 
          let exchangeRate1;

            // Accounts
            const [
                owner,
                node,
                trustedNode,
                staker,
                random,
            ] = accounts;

                // Setup
            before(async () => {
                // Register node
                await registerNode({from: node});

                // Register trusted node
                await registerNode({from: trustedNode});
                await setNodeTrusted(trustedNode, 'saas_1', 'node@home.com', owner);
            });

            when('the staker deposits 10 ETH', async () => {
                await deposit({
                    from: staker,
                    value: '10'.ether,
                });
            });
    
            then('the staker should have successfully deposited 10 ETH', () => {
                // Add any additional checks you might need here
            });
    
            when('the rETH exchange rate is obtained', async () => {
                exchangeRate1 = await getRethExchangeRate();
            });
    
            then('the initial rETH exchange rate should be obtained', () => {
                // Add any additional checks you might need here
            });
    
            when('the network ETH total is updated to alter the rETH exchange rate', async () => {
                let totalBalance = '13'.ether;
                let rethSupply = await getRethTotalSupply();
                await submitBalances(1, totalBalance, 0, rethSupply, { from: trustedNode });
    
                // Delay to allow time for the update to take effect, if necessary
                await new Promise((resolve) => setTimeout(resolve, 1000));
            });
    
            then('the rETH exchange rate should be updated', async () => {
                let exchangeRate2 = await getRethExchangeRate();
                assertBN.notEqual(exchangeRate1, exchangeRate2, 'rETH exchange rate has not changed');
            });
    
            when('the staker deposits 10 ETH again with the updated rETH exchange rate', async () => {
                await deposit({
                    from: staker,
                    value: '10'.ether,
                });
            });
    
            then('the staker should have successfully deposited 10 ETH again', () => {
                // Add any additional checks you might need here
            });
          });
    });


from Break up async mocha test into multiple tests

Timeout a C++ function from Python

I have python-cpp bindings implemented (using boost-python) such that calling foop() from Python runs a C++ function fooc(). I would like to set a timeout from Python such that foop returns after t seconds. The solutions here work fine for Python functions, but not with foop b/c I'm unable to interrupt the C++ code -- example below for calling run_for_timeout(foop). Is there a way to do this from Python (i.e. without implementing the timer functionality in C++)?

import signal

class CallbackValueError(ValueError):
    """Raise for improper data values with callback functions and their utils."""
    pass

class TimeoutError(RuntimeError):
    pass

def run_for_timeout(func, args=(), kwargs=None, timeout=5):
    """Run a function until it times-out.

    Note that ``timeout`` = 0 does not imply no timeout, but rather there is
    no time for the function to run and this function raises an error

    Parameters
    ----------
    func : function
    args : tuple
    kwargs : dict | None
    timeout : int
        (seconds)

    Returns
    -------
    result : object | None
        Return object from function, or None if it timed out

    Raises
    ------
    CallbackValueError

    """
    if timeout <= 0:
        raise CallbackValueError("{}s is a nonsensical value for the "
                                 "timeout function".format(timeout))

    def handler(signum, frame):
        raise TimeoutError()

    # Set the timeout handler
    signal.signal(signal.SIGALRM, handler)
    signal.alarm(timeout)

    if kwargs is None:
        kwargs = {}

    try:
        result = func(*args, **kwargs)
    except TimeoutError as e:
        result = None
    finally:
        # Function returned before timeout, so cancel the timer
        signal.alarm(0)

    return result


from Timeout a C++ function from Python

`AttributeError: 'Tensor' object has no attribute 'numpy'` tracking intermediate values in custom call method

Basically I have a custom call method that computes some interesting intermediate values that are important enough to track when training, but not important enough to provide as an additional return value. My model looks something like

class MyModel(tf.keras.Model):
    def __init__(self, *args, **kwargs):
        self.intermediate_values: List[numpy.ndarray] = []
        super().__init__(*args, **kwargs)


    def call(self, inputs, training=False):

        # Do some linear algebra with inputs and different layers etc.

        intermediate_tensor = some_intermediate_result

        if training and some_other_condition:
            self.intermediate_values.append(intermediate_tensor.numpy())

        # Do some more stuff with intermediate_tensor and different layers etc.

        return final_result

This of course throws AttributeError: 'Tensor' object has no attribute 'numpy' since, as I understand it, evaluating to numpy is only applicable to "eager tensors" and here intermediate_tensor is technically a node in the model call graph(?or whatever the correct nomenclature is).

Directly storing a copy of intermediate_tensor also of course doesn't solve the problem since its still not an eager tensor.

A callback won't work since this in right in the middle of the call method.

Maybe a custom metric class that gets set/managed entirely internally in the MyModel class?

I just can't seem to figure out how to actually extract the values for later analysis when the graph is executed.



from `AttributeError: 'Tensor' object has no attribute 'numpy'` tracking intermediate values in custom call method

Monday 24 July 2023

What is causing `tzlocal` to throw `Please use a timezone in the form of Continent/City. tzlocal() does not support non-zoneinfo timezones like UTC`?

Please use a timezone in the form of Continent/City. tzlocal() does not support non-zoneinfo timezones like UTC

This was raised by requests.raise_for_status()

My settings.py:

USE_TZ = True
TIME_ZONE = 'UTC'

What is causing tzlocal to throw this? I couldn't find this error in other places. It usually complains about specific timezones but not UTC



from What is causing `tzlocal` to throw `Please use a timezone in the form of Continent/City. tzlocal() does not support non-zoneinfo timezones like UTC`?

how to color a map after user selection in Dash using GeoJSON

I have a Dash app where I show a world map and expect user to select certain countries. After each selection, a callback function is triggered and I'd like to color each country selected. As a toy example, I am showing a US map with a state selection option. Here you can click on a state and it is printed on the screen. My question is that how I can color each state selected in red.

I have attached another callback to change the color, however, it is changing the color of the whole map rather than the ones that are selected. I have used the example shared at this post.

import random, json
import dash
from dash import dcc, html, Dash, callback, Output, Input, State
import dash_leaflet as dl
import geopandas as gpd
from dash import dash_table
from dash_extensions.javascript import assign

#https://gist.github.com/incubated-geek-cc/5da3adbb2a1602abd8cf18d91016d451?short_path=2de7e44
us_states_gdf = gpd.read_file("us_states.geojson")
us_states_geojson = json.loads(us_states_gdf.to_json())
# Color the feature saved in the hideout prop in a particular way (grey).
style_handle = assign("""function(feature, context){
    const match = context.props.hideout &&  context.props.hideout.properties.name === feature.properties.name;
    if(match) return {color:'#126'};
}""")

app = Dash(__name__)
app.layout = html.Div([
    dl.Map([
        dl.TileLayer(url="http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png"),
        dl.GeoJSON(data=us_states_geojson, id="state-layer",
                   options=dict(style=style_handle), hideout=dict(click_feature=None))],
        style={'width': '100%', 'height': '250px'},
        id="map",
        center=[39.8283, -98.5795],
    ),
    html.Div(id='state-container', children=[]),  #
    dash_table.DataTable(id='state-table', columns=[{"name": i, "id": i} for i in ["state"]], data=[])
])
# Update the feature saved on the hideout prop on click.
app.clientside_callback("function(feature){return feature}",
                        Output("state-layer", "hideout"),
                        [Input("state-layer", "click_feature")])

app.clientside_callback(
    """
    function(clickFeature, currentData) {
        if(!clickFeature){
            return window.dash_clientside.no_update
        }

        const state = clickFeature.properties.NAME
        const currentStates = currentData.map(item => item.state)

        let newData = []
        if(!currentStates.includes(state)){
            newData = [...currentData, {"state": state}]
        }else{
            newData = currentData
        }

        const stateText = `Clicked: ${state}`
        return [newData, stateText]
    }
    """,
    Output("state-table", "data"),
    Output("state-container", "children"),
    Input("state-layer", "click_feature"),
    State("state-table", "data"),
)

if __name__ == '__main__':
    app.run_server(debug=True)



from how to color a map after user selection in Dash using GeoJSON

Save data in sessionStorage to show a div after reload page

I've a group of divs that I show after I click an option from a select. The data option is saved after reload to keep the option selected. That works correctly but the problem is onreload, I want to save the value div to show it but I don't know how to do that: look:

This is my div group:

<center>
    <div>
        <div class="opc" id="cerDiv" style="display:none;">
            <div class="divTag" style="width: 350px;">
                <p>
                    <span class="spanrojo">|</span>
                    <span class="spangris">Certificaciones</span>
                    <span class="spanrojo">|</span>
                </p>
                <form method="post" onsubmit="return captchaValidar(this)" action="@Url.Action("Pdf", "Home")">
                    <label for="solicitud">Solicitud: </label>
                    <input type="text" id="solicitud" minlength="5" maxlength="7" name="solicitud" placeholder="Ingrese la solicitud..." required
                           title="Sólo letras y números. Cantidad mínima de caracteres: 5. Cantidad máxima de caracteres: 7"
                           onkeypress="return validarCertificadosYSolicitudes(event)" autofocus>
                    <input class="buscar" type="submit" id="btn" value="Buscar" />

                    @if (ViewBag.Alert != null)
                    {
                        <div class="alert">
                            <span class="closebtn">&times;</span>
                            <strong>Providus informa: </strong>
                            <p>@ViewBag.Alert</p>
                        </div>
                    }
                </form>
            </div>
        </div>

        <div class="opc" id="cuoDiv" style="display:none;" >
            <div style="width: 350px; ">
                <p>
                    <span class="spanrojo">|</span>
                    <span class="spangris">Cuotas</span>
                    <span class="spanrojo">|</span>
                </p>
            </div>
            <div class="divTag" style="width: 350px;">
                <form id="frmCU" method="post" action="@Url.Action("DetalleCuota", "Cuotas")">
                    <label for="titulo">Título: </label>
                    <input type="number" id="titulo" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" name="titulo" maxlength="6" placeholder="Ingrese su título..." required
                           title="Sólo letras y números. Cantidad mínima de caracteres: 4. Cantidad máxima de caracteres: 5"
                           onkeypress="return cuotasYTitulos(event)" autofocus>
                    <input class="buscar" type="submit" id="btn" value="Buscar" />
                    @if (ViewBag.Alert != null)
                    {
                        <div class="alert">
                            <span class="closebtn">&times;</span>
                            <strong>Providus informa: </strong>
                            <p id="textoAlerta">@ViewBag.Alert</p>
                        </div>
                    }
                </form>
            </div>
        </div>
    </div>
</center>

And this is my select options:

            <select id="sort-item" class="term">
                <option data-sort="0">Elija una opción</option>
                @foreach (var nivel in Model)
                {
                    if (nivel.nivel == 0 || nivel.nivel == 1 || nivel.nivel == 2 || nivel.nivel == 7)
                    {
                        <option value="cerDiv" data-sort="1">Certificados</option>
                        <option value="cuoDiv" data-sort="2">Cuotas</option>
                    } 
                }
            </select>

I have a this in my js file:

let selItems = JSON.parse(sessionStorage.getItem("SelItem")) || [];
var div_status = JSON.parse(sessionStorage.getItem("div_status")) || [];

$(function () {
    if (selItems) {
        selItems.forEach(obj => {
            const [k, v] = Object.entries(obj)[0]
            $("#" + k).val(v)
        })
    }
    $('.term').on("change", function () {
        selItems = $('.term').map(function () {
            return {
                [this.id]: this.value
            }
        }).get();
        console.log(selItems)
        sessionStorage.setItem("SelItem", JSON.stringify(selItems));
        saveDiv(this.value);
    });
});

function saveDiv(div) {
    div_status[div] = true;
    sessionStorage.setItem("div_status", JSON.stringify(div_status));
}

window.onload = function () {
    console.log(div_status);
    Object.values(div_status).forEach(function (div) {
        monstrarDiv(document.querySelector("#" + div))
    });
}

function mostrarDiv(target) {
    var opciones = document.getElementsByClassName('opc');
    var tagt = document.getElementById(target);
    var esVisible = tagt.style.display == 'block';

    //hide all
    for (var i = 0; i < opciones.length; i++) {
        opciones[i].style.display = 'none';
    }

    //toggle actual
    tagt.style.display = esVisible ? 'none' : 'block';

    return false;
}

I'm trying change the code but nothing works because I don't know how to call the value to show a div.



from Save data in sessionStorage to show a div after reload page