Skip to content

Instantly share code, notes, and snippets.

@bre7
bre7 / aws-sdk-js-v3.md
Created February 10, 2021 19:46
aws-sdk-js-v3 S3 simple how-to guide

Just a really simple guide on using S3 aws-sdk-js-v3 / @aws-sdk/client-s3 Assuming @aws-sdk/client-s3 is installed:

How to stream file from S3 to Express

import { S3 } from "@aws-sdk/client-s3"

express.get(`/file/:id`, async (req, res) => {
  const s3 = new S3({
@bre7
bre7 / readme.md
Last active March 22, 2024 23:07
VirtualBox - Creating virtual machine from physical machine (Windows 10)

Creating virtual machine from physical hard drive partition

  1. Use Disk2Vhd and create a VHD for the partition you want to convert. (If using VirtualBox, disable Vhdx option)

  2. Open Windows 10's native Disk Management tool (Run > diskmgmt.msc). Attach VHD (Action > Attach VHD).

  3. Convert to MBR Disk using AOMEI Partition Assistant Demo (if there's another way please post a comment)

  4. Detach VHD

@bre7
bre7 / readme.md
Last active February 1, 2020 03:55
Protect PDFs in Windows using CLI
@bre7
bre7 / google.analytics.color.fixer.user.css
Last active February 11, 2019 14:45
Google Analytics Color Fixer
/* ==UserStyle==
@name Google Analytics color fixer
@namespace github.com/openstyles/stylus
@version 1.0.0
@description Swaps the default blue-based palette with a proper one. Thanks to https://learnui.design/tools/data-color-picker.html for the idea & color selection
@author You
@updateURL https://gist.githubusercontent.com/bre7/a0fb9886e8b4251cc1f69274fd0af96f/raw/google.analytics.color.fixer.user.css
@preprocessor stylus
==/UserStyle== */
@bre7
bre7 / README.md
Created November 8, 2018 01:54 — forked from hubgit/README.md
Remove metadata from a PDF file, using exiftool and qpdf. Note that embedded objects may still contain metadata.

Anonymising PDFs

PDF metadata

Metadata in PDF files can be stored in at least two places:

  • the Info Dictionary, a limited set of key/value pairs
  • XMP packets, which contain RDF statements expressed as XML

PDF files

@bre7
bre7 / TwitterListsInMenubar.user.js
Created October 20, 2018 02:42
Add Twitter List icon to tabbar (next to Profile icon)
// ==UserScript==
// @name Lists in tabbar
// @version 1.0
// @description Show Lists icon next to the user avatar
// @author You
// @match https://twitter.com/*
// @grant none
// ==/UserScript==
function ready(fn) {
@bre7
bre7 / compress_pdf.md
Created July 5, 2018 19:35 — forked from ahmed-musallam/compress_pdf.md
How to compress PDF with ghostscript

How to compress PDF using ghostscript

As a developer, it bothers me when someone sends me a large pdf file compared to the number of pages. Recently, I recieved a 12MB scanned document for just one letter-sized page... so I got to googlin, like I usually do, and found ghostscript!

to learn more abot ghostscript (gs): https://www.ghostscript.com/

What we are interested in, is the gs command line tool, which provides many options for manipulating PDF, but we are interested in compressign those large PDF's into small yet legible documents.

credit goes to this answer on askubuntu forum: https://askubuntu.com/questions/3382/reduce-filesize-of-a-scanned-pdf/3387#3387?newreg=bceddef8bc334e5b88bbfd17a6e7c4f9

@bre7
bre7 / prefix.js
Created June 23, 2018 03:45
Javascript vendor prefixer
// Source: Another gist, will update if I can get the link
// Replace # with the first letter of the function
["#","webkit#","moz#","ms#","o#"].reduce(function(p, v) { return window[v + p] || p; }, "#FUNCTION_NAME");
// E.g. requestAnimationFrame (vendor prefix not needed anymore)
["r","webkitR","mozR","msR","oR"].reduce(function(p, v) { return window[v + p] || p; }, "equestAnimationFrame");
@bre7
bre7 / upload-github-release-asset.sh
Created April 11, 2018 21:18 — forked from stefanbuck/upload-github-release-asset.sh
Script to upload a release asset using the GitHub API v3.
#!/usr/bin/env bash
#
# Author: Stefan Buck
# License: MIT
# https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447
#
#
# This script accepts the following parameters:
#
# * owner
@bre7
bre7 / FileMiddlewareWithCache.swift
Created April 6, 2018 03:12
Vapor 3 Middleware to serve files from the public folder and respect Cache-Control headers
import Vapor
/// Services files from the public folder.
public final class FileMiddlewareWithCache: Middleware, Service {
/// The public directory.
/// note: does _not_ end with a slash
let publicDirectory: String
public var webTypes = [MediaType]()