Combination QQuickFramebufferObject+texturing+GridView doesn’t show items when you scroll to them

qt
Question: What I'm doing, in short:Deriving class MyItem from QQuickFramebufferObject. Drawing a simple textured triangle MyItem. The texture is taken from a QML item. Wrapping MyItem in a MyItemWrapper.qml component. On Component.onCompleted:, I make a delay and then call myItem.update() I have a scrollable (with the mouse wheel) GridView of MyItemWrapper items The items that are initially in the viewport show fine. But when I scroll down, the items that come into the viewport don't show at all. They only show when I hover them, since I've added a test MouseArea.onEntered that calls myItem.update(). I've observed this with 2 different systems with different GPUs. I've tried enabling OpenGL debug logging for this testcase, but it prints no errors. I've tried setting cacheBuffer: Number.MAX_SAFE_INTEGER on the GridView, to no avail. Any…
Read More

setState/use State in external function react

Uncategorized
Question: Considering this pseudocode: component.js ... import {someFunc} from "./common_functions.js" export default class MyComp extends Component { constructor(props) { super(props); this.someFunc = someFunc.bind(this); this.state = {...}; } _anotherFunc = () = > { .... this.someFunc(); } render() { ... } } common_functions.js export function someFunc() { if(this.state.whatever) {...} this.setState{...} } How would I bind the function someFunc() to the context of the Component? I use it in various Components, so it makes sense to collect them in one file. Right now, I get the error "Cannot read whatever of undefined". The context of this is unknown... Answer: You can't setState outside of the component because it is component's local state. If you need to update state which is shared, create a store (redux store). In your case, you can define…
Read More

memcache extension missing – how to install? MAMP 4.2

Uncategorized
Question: It's great now that MAMP has a memcached server and I see that it has a memcached extension. We use the memcache extension and whilst I was able to easily configure this with PHP 5.x as there were a ton of guides I cannot seem to get this to work with PHP 7.0.20 on MAMP Pro 4.2. Does anyone know how to get MAMP Pro 4.2 to use the memcache extension and not the memcached extension? Answer: Read more
Read More

`npm link` works even when I do not `npm link ` in the desired directory

Uncategorized
Question: I read the npm documentation on npmjs.com for linking local packages and it says I need to do it in two steps:Navigate to the local package dir and run npm link Navigate to the package in which I intened to use this package and run npm link For example, if I want to use packageB as a dependency in packageA, I need to go to packageB's directory, run npm link, then do a npm link packageB in packageA's directory. However, in practice, when I just to npm link in packageB's directory and then require('packageB') inside packageA, it works, and any changes in packageB are instantly reflected in packageA. Can anyone tell me how this is happening? Answer: In fact when you do 'npm link', it create a link to…
Read More

How to fill JavaScript localStorage to its max capacity quickly?

javascript
Question: I have an application that uses localStorage frequently. Sometimes I reach localStorage max capacity and I catch the exception and clean some old data. try { localStorage.setItem(myKey, myData); }catch(error){ // empty some old data in localStorage and re-insert myKey and myData } Everything is fine except that I cannot test it easily. I am looking for a way to fill my localStorage to its max capacity quickly so I can test the code in different conditions and browsers. Answer: Most browser have 5mb - 10mb localStorage, for example, chrome has 5mb. Use a for loop to test the limits of your localStorage, and catch once it is exceeding the limit. Then output the result. Try this one: https://jsfiddle.net/dalinhuang/6aeb3fcr/ if (localStorage && !localStorage.getItem('size')) { var i = 0; try {…
Read More

Is it possible in bash to finish command piped through gzip gracefully?

Uncategorized
Question: I have startup script which calls command that produces a lot of output. To preserve space I gzipped its output:#!/bin/bash my_command 2>&1 | tee >(gzip --stdout > "1.log.gz") Sadly, when I press Ctrl+C, gzip stops abruptly and compressed log gets damaged. Is there a way to finish command gracefully to get valid gz? Answer: I was unable to reproduce your problem, using "yes" as a substitute for your program -- that is yes 2>&1 | tee >(gzip --stdout > "1.log.gz") created perfectly valid gz file every time, so wondering if there is something else going on. However you can isolate the two parts of the command by using named pipes, like this; # create a named pipe mknod mypipe p # start a background job that reads from the…
Read More