This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##/etc/pve/qemu-server/100.conf | |
##Network and disks not included in this example | |
##Set halt_poll_ns | |
#set_halt_poll 0 | |
##CPU pinning | |
#cpu_taskset 1-7 | |
#assign_interrupts --sleep=10s 1-7 --all | |
agent: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { camelCase } from 'change-case' | |
// $: cheerio object | |
const tableToJson = ($, table) => { | |
const fields = $(table) | |
.find('thead tr th') | |
.map((_, el) => $(el).text().trim()) | |
.get() | |
const rows = $(table) | |
.find('tbody tr') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as crypto from 'crypto' | |
import iconv from 'iconv' | |
import ms from 'ms' | |
export const waitFor = (ms = 500): Promise<void> => new Promise((r) => setTimeout(r, ms)) | |
export const cleanText = (text: string): string => text.trim().replace(/[\r\n\t®]/gi, '') | |
export const cleanPrice = (price: string): number => parseInt(price.replace(/[\$\.]/g, '')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'winston-daily-rotate-file' | |
import stringify from 'json-stringify-safe' | |
import path from 'path' | |
import winston from 'winston' | |
import config from '@/config' | |
const dailyRotateTransport = new winston.transports.DailyRotateFile({ | |
filename: path.join(config.logBase, `${config.appName}-%DATE%.log`), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NextFunction, Request, Response } from 'express' | |
export class AppError extends Error { | |
status: number | |
slug: string | |
constructor(message: string, status: number, errSlug?: string) { | |
super(message) | |
this.name = this.constructor.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import amqplib, { Channel, ConsumeMessage, Replies } from 'amqplib' | |
import isFunction from 'lodash/isFunction' | |
import config from '../config' | |
import { logger } from './logger' | |
const { user, password, host } = config.amqplib | |
const url = user && password ? `amqp://${user}:${password}@${host}` : `amqp://${host}` | |
export const open = amqplib.connect(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Redis, { RedisOptions } from 'ioredis' | |
import ms from 'ms' | |
import config from '../config' | |
import { logger } from './logger' // winston, pino, ... | |
export const toSeconds = (time: string | number): number => | |
typeof time === 'number' ? time : ms(time) / 1000 | |
export interface CustomRedis extends Redis.Redis { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res | |
cd android && ./gradlew assembleRelease; cd .. | |
cp android/app/build/outputs/apk/release/app-release.apk ~/Desktop |
Remove the owner password from an encrypted PDF using Ghostscript
Note: you still need to know the password for opening the file
brew install ghostscript # on macOS
gs -q -dNOPAUSE -dBATCH -dPrinted=true -dShowAnnots=false -sDEVICE=pdfwrite -sPDFPassword=YOUR_PDF_PASSWORD -sOutputFile=unlocked.pdf -f locked.pdf