react import type defined in another file
Problem: wanted to use a type defined in another file. Received following message: Named import from module ‘../mod.js’ ‘MyType’ is a type, but not a value.In order to import it, please use ‘import type’
Solution:
golang redirect os.Stdout
Problem: want to redirect os.Stdout and access it’s contents from a string variable
Solution: this answer proved very useful:
async await in mocha tests
Problem: use async-await in mocha tests. Had an async test, and received this error: Error: Resolution method is overspecified. Specify a callback or return a Promise; not both.
Solution: good example here:
Also, I had to require babel-polyfill in my test instruction:
./node_modules/mocha/bin/mocha –compilers js:babel-core/register –require babel-polyfill test
react is changing an uncontrolled input of type text to be controlled
Problem: received following message in dev tools: MyClass is changing an uncontrolled input of type text to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component
Solution: make sure the property is specified in the initial state. Most likely your initial state does not include it. More info here
python selenium webdriver set cookie
Problem: use provided cookies with selenium python bindings
Solution: found here:
selenium webdriver click select option
Problem: select a specific option in a select dropdown
Solution: found here:
golang include sha information in your binary
Problem: you want to include the git SHA in your binary
Solution: Assuming the following code:
- you can run the binary like this: go run -ldflags “-X main.appVersion=$(git rev-parse HEAD)” main.go
- you can build it like this: go build -ldflags “-X main.appVersion=$(git rev-parse HEAD)” main.go
osx remove zombie processes
Problem: zombie process appeared in ps
Solution: find it’s parent process,and kill it
ps -xo pid,ppid,stat,command | grep your_zombie_process_name kill -9 ppid_of_zombie_process
Found this useful information here
xvfb run something with custom screen size
Problem: ran selenium integration tests. They pass locally, but fail that some element is not visible. Took a browser screenshot, turned out that the browser window was very small, and the element was not in view.
Solution: run xvfb-run with custom args: <pre>xvfb-run –server-args=”-screen 0, 1920x1080x24” npm run test</pre>. Solution found here
selenium webdriver javascript save screenshot
Problem: obtaining a screenshot from selenium webdriver Solution: The string that comes back as a result of takeScreenshot is a base64 png image, so we decode it before writing it to disk: