Fable: Calling a native Javascript function that requires JQuery

I have F# experience, but am new to Fable (and Javascript, npm, wepback, etc.). In my app, I’m trying to call an external Javascript library called cardsJS in order to display playing cards. However, this library requires JQuery, so I’m not sure how to call it from Fable/F#.

To be specific, one of the Javascript functions exposed by the library is:

// Gets the ID of the card, e.g. "KS" for the king of spades.
cid: function (card) {
    var s = card.attr('src');
    return s.substring(s.length - 6, s.length - 4);
},

In cardsJS, a card is just an HTML img element, so I tried to import the cid function in my Fable code via:

type ICardsJS =
    abstract member cid : HTMLImageElement -> string

let iCardsJS : ICardsJS = importDefault "cardsJS/cards.js"

However, when I call iCardsJS.cid(card) this way, I get a Javascript runtime error:

Uncaught TypeError: card.attr is not a function
    at Object.cid (cards.js:30:26)

The problem here is that the library apparently expects a JQuery object, rather than the raw DOM element, so it can call the object’s attr function. So I guess my F# interface should actually look something like this instead:

type ICardsJS =
    abstract member cid : JQueryThing??? -> string

If I was writing in raw Javascript, I could wrap the DOM element as a JQuery object, like this: $(card). How can I accomplish the same thing in Fable? I’m sure I need to import JQuery into my F# code somehow, but I don’t know the right incantation. The only lead I’ve found so far is this issue, which suggests something like:

let jq : obj = importDefault "jquery"
let jqCard = jq $ card

But that doesn’t compile in Fable 3.

Stripe PaymentIntents PHP, setting price

Basically, the problem im having is between php and javascript, where my php function is createPayment() I can’t put javascript variable so I can’t enter the amount ($) of the order
I’m really stuck on what to do.

Maybe a post event to the server to create payment via javascript but I don’t know how to do that

Javascript:

document.getElementById("stripe").onclick = function(){
    const stripe = Stripe('public_key');
    const options = {
        clientSecret: "<?php include('payments.php'); $payment = createPayment(500); echo $payment->client_secret ?>",
        // Fully customizable with appearance API.
        appearance: {/*...*/},
    };

    // Set up Stripe.js and Elements to use in checkout form, passing the client secret obtained in step 2
    const elements = stripe.elements(options);

    // Create and mount the Payment Element
    const paymentElement = elements.create('payment');
    paymentElement.mount('#payment-element');   
}

Server side:

<?php
    require_once('vendor/autoload.php');

    function createPayment($amount){
        $stripe = new StripeStripeClient('sk_key');
        $intent = $stripe->paymentIntents->create(
            [
              'amount' => $amount,
              'currency' => 'usd',
              'automatic_payment_methods' => ['enabled' => true],
            ]
          );
        return $intent;
    };    
?>

How to use __filename in angular library?

I have two angular 13 projects – an application and a library. In both projects I need to use __filename. To do it in the application I use "@angular-builders/custom-webpack:browser" builder with the custom webpack config:

export default (config: webpack.Configuration, options: CustomWebpackBrowserSchema, targetOptions: TargetOptions) => {
  config.node = {
    __filename: true,
    __dirname: true
  };
  return config;
}

However, I can’t find a solution to use __filename in angular library. As I understand webpack is not used in library building.

Could anyone say, how to get __filename in the library, if it is possible.

How do I combine two user scripts into one script

I have two user scripts that be should be run in the console of the browser

Script #1 – waits for the class .cdn_download_item to appear on the page, after which a response comes out that “the class has been detected”.

Script #2 – this script should be used only after the appearance of the class .cdn_download_item, because it iterates over the spans of this class and outputs them.

If I run these scripts separately. Then everything works
Question – how do I combine these scripts into one script and get the result?

Script #1

document.addEventListener('DOMNodeInserted', function(event){
    if(document.querySelectorAll('.cdn_download_item'))
    {
        console.log('класс обнаружен');
    }
    else
    {
        console.log('не удалось обнаружить класс');
    }
}, true);

Script #2

var elements = Array.from(document.querySelectorAll('.cdn_download_item span:first-child'));
var linksArray = new Array();
for (element of elements) {
    linksArray.push(element.innerText);
}
linksArray;

I need something like this (see below)

document.addEventListener('DOMNodeInserted', function(event){
    if(document.querySelectorAll('.cdn_download_item'))
    {
        var elements = Array.from(document.querySelectorAll('.cdn_download_item span:first-child'));
        var linksArray = new Array();
        for (element of elements) 
        {
            linksArray.push(element.innerText);
        }
        linksArray;
    }
    else
    {
        //if the class has not been detected yet, then we are waiting for the class to appear
    }
}, true);

I tried to combine these scripts by myself like so (see below).
My code is not working correctly, the result should come out once and the array should consist of 76 elements, and now the result is output 76 times!!!

document.addEventListener('DOMNodeInserted', function(event){
    if(document.querySelectorAll('.cdn_download_item'))
    {
        var elements = Array.from(document.querySelectorAll('.cdn_download_item span:first-child'));
        var linksArray = new Array();
        for (element of elements) 
        {
            linksArray.push(element.innerText);
        }
        console.log(linksArray);
    }
}, true);

how to fix issue on tampermonkey script

i using a tampermonkey script but i have this error i dont know how to fix this issue .

the error displayed
the source

document.onkeypress = async function(e) {
    e = e || window.event;
    var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
    if (String.fromCharCode(charCode) === '=') {
        const {
            value: formValues
        } = await Swal.fire({
            title: 'Enter your credentials ',
            html: '<input id="swal-input1" class="swal2-input" placeholder="email"
            type = "text"
            value = "[email protected]" > ' +
            '<input id="swal-input2" class="swal2-input" placeholder="password"
            type = "password"
            value = "A23@" > ',
            focusConfirm: false,
            preConfirm: () => {
                return [
                    document.getElementById('swal-input1').value,
                    document.getElementById('swal-input2').value
                ][![enter image description here][1]][1]
            }
        })

React Native: Fade through a series of images using Animated & opacity

I’m currently trying to fade through a series of images. Basically, I always want to display one image at a time, then animate its opacity from 1 to 0 and that of the next image in the series from 0 to 1, and so on. Basically something like this, which I’ve already implemented for the web in ReactJS and CSS animations:

Fade animation in ReactJS

However, I seem to keep getting stuck on using React Native’s Animated library and refs. I’ve tried storing the opacity of all the images in an array which itself is contained in an useRef hook. Then, using, Animated, I’m trying to perform two parallel animations which change the opacity of the current image index and that of the next index. This is what I’ve come up with:

export default function StartImageSwitcher() {
  const images = Object.values(Images).map((img) => img.imageNoShadow);

  const [currentImage, setCurrentImage] = useState(0);
  const opacity = useRef<Animated.Value[]>([
    new Animated.Value(1),
    ...Array(images.length - 1).fill(new Animated.Value(0)),
  ]).current;

  useEffect(() => {
    let nextImage = currentImage + 1;
    if (nextImage >= images.length) nextImage = 0;

    Animated.parallel([
      Animated.timing(
        opacity[currentImage],
        {
          toValue: 0,
          duration: 2000,
          useNativeDriver: true,
        },
      ),
      Animated.timing(
        opacity[nextImage],
        {
          toValue: 1,
          duration: 2000,
          useNativeDriver: true,
        },
      ),
    ]).start(() => {
      setCurrentImage(nextImage);
    });
  }, [currentImage]);

  images.map((image, index) => console.log(index, opacity[index]));

  return (
    <View style={styles.imageWrapper}>
      {
      images.map((image, index) => (
        <Animated.Image style={{ ...styles.image, opacity: opacity[index] }} source={image} key={index} />
      ))
    }
    </View>
  );
}

However, this doesn’t seem to work at all. When mounted, it only shows the first image, then fades all images in and gets stuck there:

Image clutter using the above code in React Native

Anyone got an idea where I messed up? I feel like I’m not using the useRef() hook in combination with the Animated library like I’m supposed to.

Using arguments to send emoji discord.js

Hello im trying to send emoji using args.
This is code I have so far

client.on('messageCreate', message => {
    if (message.author.bot) return;
    if (message.content.indexOf(prefix) !== 0) return;

    const args = message.content.slice(prefix.length).trim().split(/ +/g);
    const command = args.shift().toLowerCase();
    
    if (command === 'f') {
        if (args[0] === 'agrona') {
            return message.channel.send(':agrona:970341615715627079');
        } else if (args[1] === 'aurora') {
            return message.channel.send(":Aurora:970341793042403449");
        } else if (args[2] === 'elizabeth') {
            return message.channel.send(":elizabeth:970341810469752862");
        } else if (args[3] === 'icy') {
            return message.channel.send(":icy:970341824633929728");
        } else if (args[4] === 'issa') {
            return message.channel.send(":issa:970341862680440882");
        }
        
        message.channel.send(`${args[0]} ${args[1]} ${args[2]} ${args[3]} ${args[4]}`);
    }
});

I event tried to define do it like this but it didnt work:

if (command === 'f') {
        if (args[0] === 'agrona') {
        const Emoji = message.guild.emojis.cache.find(emoji => emoji.name === 'agrona');
            return message.channel.send(`${Emoji});

But all I got was undefined response from bot.
Can anyone help me with this? Thanks.

Add export default to this code because it showing error in my app component

I have tried const DataList = () => { at the beginning and ending but it wasn’t working

Add export default to this code because it shows an error in my app component

    import { render } from '@testing-library/react'
            import React,{useState} from 'react'
            import ReactDOM from 'react-dom/client';
            const Thingy = ({...props}) => {
              const [userInput, setUserInput] = useState('');
              const [showResult, setShowResult] = useState(false);
              const handleChange = ev => (setUserInput(ev.target.value), setShowResult(false));
              const convertChar = ch => {
                const c = ch.toLowerCase();
               
                if ('0' <= c && c <= '9') return ch.toString();
                if (!('a' <= c && c <= 'z')) return ch;         
                return c.charCodeAt(0) - 'a'.charCodeAt(0) + 1;
              };
              const transformInput = () => userInput
                .split('')                    letters
                .map(c => convertChar(c))     
                .join(' '); 
        getResult = () => userInput
                .split('')                  
                .map(c => convertChar(c))  
                .filter(                    
                  c => (
                    typeof c !== 'string' &&    
                    !isNaN(c)                   
                  )
                )
                .reduce(                   
                  (total, itm) => total + itm, 0
                );
              return (
                <div>
                  <div>
                    <label htmlFor={'usrinp'}>Enter text: </label>
                    <input
                      id="usrinp"
                      value={userInput}
                      onChange={handleChange}
                    />
                  </div>
                  {
                    userInput.length > 0 &&
                    <p>Converted text to: {transformInput()}</p>
                  }
                  <button onClick={() => setShowResult(true)}>
                    Submit
                  </button>
                  {
                    showResult && <p>Result is: {getResult()}</p>
                  }
                </div>
              );
            };
            
            ReactDOM.render(
              <div>
                <h4>Transform User input text to numbers</h4>
                <Thingy />
              </div>,
              document.getElementById("rd")
            );

events.Swap is not triggered in web3 for a Uniswap Pool

  • Visual Studio Code 1.66.2
  • ganache v7.1.0 (@ganache/cli: 0.2.0, @ganache

I am new to Solidity and this is my first example I am trying out.
I am trying to get noticed when there is a swap event in the Uniswap Pool “ETH-APE” using:

uPair.events.Swap

The code seems to start where: Waiting for swaps...
I can see on Uniswap itself that there is regular swaps but the swap event seems to not trigger where the console.log should show: someone swapped now!

I have started this blockchain successfully with the command like this:
Notice: I have a real apikey from alchemy and a real mnemonic from ganache-cli
ganache-cli -f wss://eth-mainnet.alchemyapi.io/v2/myAPIkey --mnemonic "word1 word2 word3 etc" -p 7545

I have just followed some examples and are not sure exactly what I am doing:

  1. As I am a beginner I must also ask about ganache. As I have understand this is a “Fake and local Sandboxed” blockchain just existing on my computer?

  2. I think I understand that I start ganache-cli on my computer but are not sure if the uPair.events.Swap listen to my local blockchain which is not the REAL blockchain and this is because the swap event is not triggered. If that is the case then that is what I wonder what I am missing?
    (I am not even sure I need ganache to listen to this swap event?)

  3. I am not sure what the alchemyapi.io with myAPIkey is doing in the command to start the local ganache-cli where in the same command I use the mnemonic which has been generated from ganache?

// -- HANDLE INITIAL SETUP -- //
require("dotenv").config();
const Web3 = require('web3')
const IERC20 = require('@openzeppelin/contracts/build/contracts/ERC20.json')
const IUniswapV2Pair = require("@uniswap/v2-core/build/IUniswapV2Pair.json")
const IUniswapV2Factory = require("@uniswap/v2-core/build/IUniswapV2Factory.json")
const { ChainId, Token } = require("@uniswap/sdk")
let web3 = new Web3('ws://127.0.0.1:7545')
    

const main = async () => {
   
    const _eth_address = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
    const _apecoin_address = "0x4d224452801aced8b2f0aebe155379bb5d594381"; 
    const _uniswap_factory_address = "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f";
    const uFactory = new web3.eth.Contract(IUniswapV2Factory.abi, _uniswap_factory_address) // UNISWAP FACTORY CONTRACT

    const { token0Contract, token1Contract, token0, token1 } = await getTokenAndContract(_eth_address, _apecoin_address)
    let uPair = await getPairContract(uFactory, token0.address, token1.address)

    console.log("Waiting for swaps...");
    uPair.events.Swap({}, async () => {
        
        console.log("someone swapped now!");
    })
}
async function getPairAddress(_V2Factory, _token0, _token1) {
    const pairAddress = await _V2Factory.methods.getPair(_token0, _token1).call()
    return pairAddress
}
async function getPairContract(_V2Factory, _token0, _token1) {
    const pairAddress = await getPairAddress(_V2Factory, _token0, _token1)
    const pairContract = new web3.eth.Contract(IUniswapV2Pair.abi, pairAddress)
    return pairContract
}
async function getTokenAndContract(_token0Address, _token1Address) {
    const token0Contract = new web3.eth.Contract(IERC20.abi, _token0Address)
    const token1Contract = new web3.eth.Contract(IERC20.abi, _token1Address)

    const token0 = new Token(
        ChainId.MAINNET,
        _token0Address,
        18,
        await token0Contract.methods.symbol().call(),
        await token0Contract.methods.name().call()
    )

    const token1 = new Token(
        ChainId.MAINNET,
        _token1Address,
        18,
        await token1Contract.methods.symbol().call(),
        await token1Contract.methods.name().call()
    )
    return { token0Contract, token1Contract, token0, token1 }
}
main()


How do i print a receipt from my local app

so I have built a local patient manager app for a clinic using HTML, CSS, JavaScript, and PHP. but my question is can I print a receipt using these small printers? like take data such as the next appointment and the amount paid today etc., like send the data from the app to the printer and print it
I have tried searching but nothing useful

thanks.

How to replace occurences of a word in string by the same word concerving case

I’m trying to surround some words with HTML tags while concerving their case.

for example

let str = "foo key bar Key hello kEY world";
let regex = new RegExp("key", "ig");

the output I’m looking for is something like this

foo <span class="k">key</span> bar <span class="k">Key</span> hello <span class="k">kEY</span> world

I tryed using the replace function but it effects the case

str = str.replace(regex, '<span class="k">key</span>');

Output

foo <span class="k">key</span> bar <span class="k">key</span> hello <span class="k">key</span> world
<!-- all lower case :( -->

I tried this also

let matches = regex.exec(str);
if (matches != null)
    matches.forEach(match => str = str.replace(new RegExp(match, 'g'), '<span class="k">' + match + '</span>');

But some how case is still ignored. Output

foo <span class="k">key</span> bar Key hello kEY world
<!-- only lower case is matched :( -->

is there a way to make something like this

str.replace(regex, the_matched_regex + 'some text');

BTW I don’t know the possible cases nor the word in advance… I’m making a function to highlight matches of a key in a string ignoring case in search, concerving case in output.

function highlight(src, key) {
    /* some code */
    return result;
}

File.slice() can’t return a blob

I want to split a file to blob and upload them to server. I use File.slice() to split file.Then I save these blobs to an array.When i send these blobs to the server, server received files.But the browser prompt an error:
Failed to execute ‘append’ on ‘FormData’: parameter 2 is not of type ‘Blob’.
Here is my codes.

    //html
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="file" name="enfile" id="enfile">
    <button id="btn">Add</button>
    <script>
        // ./upload/BlobUpload.do
        var btn = document.querySelector('#btn');
        btn.onclick = function() {
            var src = document.querySelector('#enfile');
            var file = src.files[0];
            var chunk = 1024 * 100;
            var chunks = [];
            var start = 0;
            var j = 0;
            for (var i = 0; i < Math.ceil(file.size / chunk); i++) {
                var end = start + chunk;
                chunks[i++] = file.slice(start, end);
                start = end;
                j++;
            }
            var xhr = new XMLHttpRequest();
            xhr.open('post', './upload/BlobUpload.do', true);
            for (let i = 0; i < chunks.length; i++) {
                var fname = file.name;
                var size = file.size;
                var formData = new FormData();
                formData.append('regularName', fname);
                formData.append('size', size);
                formData.append('total', j);
                formData.append('offset', i * chunk);
                formData.append('current', i);
                formData.append('data', chunks[i], 'data');
                xhr.send(formData);
            }
        }

        var disableCache = function() {
            var current = window.location.href;
            if (current.indexOf('requestTime') == -1) {
                var timestamp = +new Date();
                window.location.href = current + '?requestTime=' + timestamp;
            }
        }
        window.addEventListener('load', disableCache);
    </script>
</body>

</html>

//servlet
package upload;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import org.apache.tomcat.util.http.fileupload.FileItem;
import org.apache.tomcat.util.http.fileupload.RequestContext;
import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload;
import org.apache.tomcat.util.http.fileupload.servlet.ServletRequestContext;
import utility.FileProperties;
/**
 * Servlet implementation class BlobUpload
 */
public class BlobUpload extends HttpServlet {
    private static final long serialVersionUID = 1L;
    
    int count = 0;
    int current = 0;
    int offset = 0;
    int size = 0;
    HttpSession session;
    long timestamp = 0;
    String regularName = "";
    int total = 0;
    FileProperties fileProperties;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public BlobUpload() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
     */
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        String temp = this.getServletContext().getRealPath("/temp/");
        String path = this.getServletContext().getRealPath("/attachment/");
        String parts = this.getServletContext().getRealPath("/cache/");
        File tempDir = new File(temp);
        if(!tempDir.exists()) {
            tempDir.mkdir();
        }
        File partsDir = new File(parts);
        if(!partsDir.exists()) {
            partsDir.mkdir();
        }
        DiskFileItemFactory dfifBlob = new DiskFileItemFactory();
        dfifBlob.setRepository(tempDir);
        dfifBlob.setSizeThreshold(1024 * 1024);
        RequestContext rcBlob = new ServletRequestContext(request);
        ServletFileUpload sfuBlob = new ServletFileUpload(dfifBlob);
        sfuBlob.setFileSizeMax(1073741824);
        sfuBlob.setSizeMax(1073741824);
        List<FileItem> blobPart = sfuBlob.parseRequest(rcBlob);
        session = request.getSession(true);
        if(session.getAttribute("newFile") == null || ((boolean)session.getAttribute("newFile")) == false) {
            session.setAttribute("newFile", true);
            timestamp = System.currentTimeMillis();
            for(FileItem currentBlob : blobPart) {
                if(currentBlob.isFormField()) {
                    String fieldName = currentBlob.getFieldName();
                    if(fieldName.equals("total")) {
                        total = Integer.parseInt(currentBlob.getString("UTF-8"));
                    }else if(fieldName.equals("current")) {
                        current = Integer.parseInt(currentBlob.getString("UTF-8"));
                    }else if(fieldName.equals("offset")) {
                        offset = Integer.parseInt(currentBlob.getString("UTF-8"));
                    }else if(fieldName.equals("size")) {
                        size = Integer.parseInt(currentBlob.getString("UTF-8"));
                    }else if(fieldName.equals("regularName")) {
                        regularName = currentBlob.getString("UTF-8");
                    }
                }else {
                    String cacheDir = parts + timestamp + "/";
                    File temporary = new File(cacheDir);
                    if(!temporary.exists()) {
                        temporary.mkdir();
                    }
                    File cache = new File(cacheDir + timestamp + "-" +count + ".bin");
                    cache.createNewFile();
                    if(currentBlob.getName() != null && !currentBlob.equals("")) {
                        InputStream input = currentBlob.getInputStream();
                        FileOutputStream  output = new FileOutputStream(cache);
                        byte[] buffer = new byte[1024];
                        int len = 0;
                        while((len = input.read(buffer)) > 0) {
                            output.write(buffer, 0, len);
                        }
                        output.close();
                        input.close();
                    }
                }
            }
            fileProperties = new FileProperties(timestamp, size, regularName, total);
            session.setAttribute("properties", fileProperties);
            session.setAttribute("fileOffset", offset);
            count++;
            session.setAttribute("count", count);
            if(count == total) {
                fileProperties.setClear(true);
                fileProperties.setFinish(true);
                session.removeAttribute("properties");
                session.setAttribute("properties", fileProperties);
            }
            
        }else {
            fileProperties = (FileProperties)session.getAttribute("filePropertie");
            timestamp = fileProperties.getTimestamp();
            count = (int)session.getAttribute("count");
            for(FileItem currentBlob : blobPart) {
                if(currentBlob.isFormField()) {
                    String fieldName = currentBlob.getFieldName();
                    if(fieldName.equals("total")) {
                        total = Integer.parseInt(currentBlob.getString("UTF-8"));
                    }else if(fieldName.equals("current")) {
                        current = Integer.parseInt(currentBlob.getString("UTF-8"));
                    }else if(fieldName.equals("offset")) {
                        offset = Integer.parseInt(currentBlob.getString("UTF-8"));
                    }else if(fieldName.equals("size")) {
                        size = Integer.parseInt(currentBlob.getString("UTF-8"));
                    }else if(fieldName.equals("regularName")) {
                        regularName = currentBlob.getString("UTF-8");
                    }
                }else {
                    String cacheDir = parts + timestamp + "/";
                    File cache = new File(cacheDir + timestamp + "-" +count + ".bin");
                    cache.createNewFile();
                    if(currentBlob.getName() != null && !currentBlob.equals("")) {
                        InputStream input = currentBlob.getInputStream();
                        FileOutputStream  output = new FileOutputStream(cache);
                        byte[] buffer = new byte[1024];
                        int len = 0;
                        while((len = input.read(buffer)) > 0) {
                            output.write(buffer, 0, len);
                        }
                        output.close();
                        input.close();
                    }
                }
            }
            session.setAttribute("fileOffset", offset);
            count++;
            session.setAttribute("count", count);
            if(count == total) {
                fileProperties.setClear(true);
                fileProperties.setFinish(true);
                session.removeAttribute("properties");
                session.setAttribute("properties", fileProperties);
            }
        }
        fileProperties = (FileProperties)session.getAttribute("properties");
        if(fileProperties.isFinish()) {
            File preCombine = new File(parts + fileProperties.getTimestamp() + "/");
            File[] combining = preCombine.listFiles(new FileFilter() {

                @Override
                public boolean accept(File pathname) {
                    // TODO Auto-generated method stub
                    return pathname.getName().endsWith(".bin");
                }});
            String export = path + fileProperties.getRegularName();
            File combined = new File(export);
            if(!combined.exists()) {
                combined.createNewFile();
            }
            for(File processing : combining) {
                FileInputStream processingInput = new FileInputStream(processing);
                FileOutputStream processingOutput = new FileOutputStream(combined,true);
                byte[] processingBuffer = new byte[1024];
                int len = 0;
                while((len = processingInput.read(processingBuffer)) > 0) {
                    processingOutput.write(processingBuffer, 0, len);
                }
                processingOutput.close();
                processingInput.close();
            }
            File[] del = preCombine.listFiles();
            int j = 0;
            for(int i = 0; i < del.length; i++) {
                if(del[i].exists()) {
                    del[i].delete();
                }
            }
            preCombine.delete();
            session.removeAttribute("newFile");
            session.removeAttribute("count");
            session.removeAttribute("properties");
        }
    }

}

Why the browser prompt the error.File is a blob.
enter image description here

node.js send data in async from function to function

I’m going to create a node repl that works within a node.

The run function is a function that returns the output value when the code to be put in the repl is passed over to the factor.

Is there a way to transfer data from a write function to a run function while the run function is running?

const repl = require('repl');
const { Readable, Writable } = require('stream');

const readable = new Readable({
    read(size) {
        return true;
    }
});
const writable = new Writable({
    write(chunk, encoding, callback) {
        const value = chunk.toString();
        if (value === "") {
            // todo : send data to function run
        } else {
            // todo : stack data for function run
        }
        console.log(chunk);
        callback();
    }
});

repl.start({
    prompt: "",
    input: readable,
    output: writable
});

async function run(code) {
    readable.push(code);
    // todo 
}

run("setTimeout(() => {console.log('test')}, 1000);n");

exports.run = run;

grid-time visualization of scheduled processes

The data ETL software environment we use at work runs some 20 scheduled processes. I would like to be able to visualize a time-based grid with these processes to quickly check what is running now() and what is scheduled later in the day, week, etc..

I am looking for some open source code to display this in a web page in some simple grid timeline fashion. These schedules are configured in some json-like files which I could easily convert to true json, yaml or anything else that could be fed to this visualization component. I have taken a look in github.com but did not find something that fits my needs. Can anyone provide me with some hints or pointers to something existing?

Much appreciated.

connect speech to text API to Java script

I am trying to convert Arabic speech to text and one of the APIs I want to use is IBM Watson .. any one have an idea of how to connect API to Java script or web app ?? cause I’ve been searching and I didn’t get anything ..
thank you in advance