npx create-react-app@next --scripts-version=@next --template=cra-template@next my-js-app
npx create-react-app@next --scripts-version=@next --template=typescript@next my-ts-app
This is a collection of basic "recipes", many using twurl (the Swiss Army Knife for the Twitter API!) and jq to query the Twitter API and format the results. Also, some scripts to test or automate common actions.
# REF: http://www.quora.com/How-do-I-create-and-update-embedded-documents-with-MongoEngine | |
class Comment(EmbeddedDocument): | |
content = StringField() | |
name = StringField(max_length=120) | |
class Post(Document): | |
title = StringField(max_length=120, required=True) | |
author = StringField(required=True) |
Spawning multiple ffmpeg processes with xargs:
On standard NVIDIA GPUs (Not the Quadros and Tesla lines), NVENC encodes are limited to two simultaneous sessions. The sample below illustrates how to pass a list of AVI files to ffmpeg and encode them to HEVC on two encode sessions:
$ find Videos/ -type f -name \*.avi -print | sed 's/.avi$//' |\
xargs -n 1 -I@ -P 2 ffmpeg -i "@.avi" -c:a aac -c:v hevc_nvenc "@.mp4"
This will find all files with the ending .avi
in the directory Videos/
and transcode them into HEVC/H265+AAC files with the ending .mp4. The noteworthy part here is the -P 2
to xargs, which starts up to two processes in parallel.
fn main () | |
{ | |
let martini_emoji = '\u{1F378}'; | |
println!("{}", martini_emoji); | |
} |
Here is how to add Cypress E2E tests to a Create React App bootstrapped application. Assumes the *nix command line, you may need to adapt this for a Windows command line (or use WSL or Git Bash).
Install Cypress and the Testing Library utilities for it (to match the helpers CRA installs):
$ npm i {,@testing-library/}cypress
i
is short for install, and the braces {}
are expanded by brace expansion to cypress @testing-library/cypress
.
Using perf:
$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg
NOTE: See @GabrielMajeri's comments below about the
-g
option.
See https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline
A newline in a text file is a terminator, not a separator. This means each line should have a newline at the end of it, including the last line of the file.
Many editors automatically add the newline at the end of the file. Some do not. If you can configure your editor to ensure there is always a newline at the end of every line, please do so.
Because many editors do add this newline, if you commit a text file without it, when someone else edits the file, their editor will (correctly) add the newline. This causes a spurious diff in the file. Spurious
# An example to get the remaining rate limit using the Github GraphQL API. | |
import requests | |
headers = {"Authorization": "Bearer YOUR API KEY"} | |
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section. | |
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers) | |
if request.status_code == 200: |