Skip to content

Instantly share code, notes, and snippets.

View progressbar_test.bash
#!/bin/bash -xe
progressbar() {
secs="${1:-10}"
while true
do
printf .
sleep "$secs"
done
}
View gist:065815f6380c0ddb3532ad3b49c67c68
# hlsearch on (H) or off (h):
~H
# Last Search Pattern:
~MSle0~/$
# Last Substitute Search Pattern:
~MSle0&$
# Last Substitute String:
$\r
View websocket.test.js
test("Can receive broadcast connection", async (done) => {
jest.setTimeout(500); // timeout quickly if done() isn't called.
let postResult = null;
// Need to set up message handler *before* making POST request.
ws.addEventListener("message", async (event) => {
try {
// When message arrives, we know POST request was sent. So, verify its result.
const resp = await postResult;
expect(resp.status).toBe(200);
View gist:803b6d1cea928268a0e5f68cb0ee5523
$ emulator -accel-check
accel:
0
KVM (version 12) is installed and usable.
accel
View gist:4cc570a88077ecc2ad4b5f80842c1219
Running transaction check
Transaction check succeeded.
Running transaction test
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Transaction test error:
file /usr/share/doc/gnutls/AUTHORS from install of gnutls-3.6.14-1.fc31.i686 conflicts with file from package gnutls-3.6.13-1.fc31.x86_64
file /usr/share/doc/gnutls/NEWS from install of gnutls-3.6.14-1.fc31.i686 conflicts with file from package gnutls-3.6.13-1.fc31.x86_64
file /usr/share/locale/ms/LC_MESSAGES/gnutls.mo from install of gnutls-3.6.14-1.fc31.i686 conflicts with file from package gnutls-3.6.13-1.fc31.x86_64
file /usr/share/man/man5/cert8.db.5.gz from install of nss-3.53.0-1.fc31.i686 conflicts with file from package nss-3.52.0-2.fc31.x86_64
View gist:1e0f788152a0b2259d7692ae5d9befd5
$ emulator @Pixel_2_API_28
Fontconfig warning: "/usr/share/fontconfig/conf.avail/05-reset-dirs-sample.conf", line 6: unknown element "reset-dirs"
host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
E0616 09:32:44.729029599 5363 socket_utils_common_posix.cc:201] check for SO_REUSEPORT: {"created":"@1592314364.728946614","description":"SO_REUSEPORT unavailable on compiling system","file":"/mnt/tmpfs/src/android/emu-master-dev/external/grpc/src/core/lib/iomgr/socket_utils_common_posix.cc","file_line":169}
Your emulator is out of date, please update by launching Android Studio:
- Start Android Studio
- Select menu "Tools > Android > SDK Manager"
- Click "SDK Tools" tab
View error handling.js
class AuthError extends Error {
constructor(message) {
super(message);
// Error.captureStackTrace(this, AuthError);
}
}
function f(o) {
try {
const [_, token] = o.authorization.split('Bearer ');
View asyncwrap.js
// Utilities for express.
/**
* Wraps request handler and calls next() on error.
* @param {Function} reqHandler express request handler. It doesn't have to return Promise.
*/
function asyncWrap(reqHandler) {
async function handlerWrap(req, res, next) {
try {
// reqHandler might not return Promise. So, can't do reqHandler().catch();
View Dockerfile
FROM mhart/alpine-node:12.2 as builder
# Do crazy stuff
FROM mhart/alpine-node:12.2 as app
WORKDIR /app
RUN apk add --no-cache tini
# Can I use a single COPY?
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package*.json ./
View array_as_default_arg.bash
#!/bin/bash
REPOS=(foo bar)
git_up() {
if (( $# > 0 ))
then
repos=$@
else
repos=${REPOS[@]}
You can’t perform that action at this time.