Skip to content

Instantly share code, notes, and snippets.

@adamlacombe
adamlacombe / multiple-xlsx-to-single-csv.sh
Created Dec 17, 2020
Convert multiple xlsx files to csv files then merge multiple csv files into one
View multiple-xlsx-to-single-csv.sh
#!/bin/bash
# https://stackoverflow.com/a/21651707/9238321
for i in *.xlsx; do libreoffice --headless --convert-to csv "$i" ; done
# https://unix.stackexchange.com/a/558965
awk '(NR == 1) || (FNR > 1)' *.csv > all.csv
@troyhunt
troyhunt / rick-roll-content-scraper.js
Created Aug 19, 2020
A Cloudflare worker to redirect image requests from dickhead content scraper's site to a Rick Roll
View rick-roll-content-scraper.js
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
async function fetchAndApply(request) {
let response = await fetch(request)
let referer = request.headers.get('Referer')
let contentType = response.headers.get('Content-Type') || ''
if (referer && contentType.startsWith('image/')) {
@mbleigh
mbleigh / README.md
Last active Jan 20, 2023
Firebase Hosting Fetch All Files
View README.md

Fetch All Files from Firebase Hosting

This script fetches all of the files from the currently deployed version of a Firebase Hosting site. You must be signed in via the Firebase CLI and have "Site Viewer" permission on the site in question to be able to properly run the script.

Running via NPX

npx https://gist.github.com/mbleigh/9c8680cf319ace2f506f57380da66e7d <site_name>
View limitmem.sh
#!/bin/sh
# strict mode: error if commands fail or if unset variables are used
set -eu
if [ "$#" -lt 2 ]
then
echo Usage: `basename $0` "<limit> <command>..."
echo or: `basename $0` "<memlimit> -s <swaplimit> <command>..."
exit 1
@jsprpalm
jsprpalm / viewer.html
Created May 23, 2019
Pinch zoom implementation for PDF.js viewer
View viewer.html
<!-- Goes into viewer.html just before ending </body> -->
<script>
let pinchZoomEnabled = false;
function enablePinchZoom(pdfViewer) {
let startX = 0, startY = 0;
let initialPinchDistance = 0;
let pinchScale = 1;
const viewer = document.getElementById("viewer");
const container = document.getElementById("viewerContainer");
const reset = () => { startX = startY = initialPinchDistance = 0; pinchScale = 1; };
@snaptopixel
snaptopixel / decorator.ts
Created Jan 29, 2019
Stencil custom decorator example
View decorator.ts
/*
* @Component()
* class ThemedComponent {
* @Inject() theme: ITheme;
* }
*/
const theme = {foo: 'bar'};
export function Inject() {
@vdbelt
vdbelt / cloudflare-purge-cache-service-worker.js
Created Aug 21, 2018
A CloudFlare service worker that proxies purge cache requests. Example: https://example.com/__purge_cache?zone=XX
View cloudflare-purge-cache-service-worker.js
addEventListener('fetch', event => {
event.respondWith(purgeCache(event.request))
})
async function purgeCache(request) {
const url = new URL(request.url)
@sparrc
sparrc / install-ffmpeg.sh
Last active Jan 27, 2023
Installs ffmpeg with libaom and libx265 enabled for av1 and hevc encoding (tested on Ubuntu 16.04)
View install-ffmpeg.sh
#!/usr/bin/env bash
# Installs ffmpeg from source (HEAD) with libaom and libx265, as well as a few
# other common libraries
# binary will be at ~/bin/ffmpeg
sudo apt update && sudo apt upgrade -y
mkdir -p ~/ffmpeg_sources ~/bin
export PATH="$HOME/bin:$PATH"
@gerarldlee
gerarldlee / Installing Kali Linux as a Windows 10 Subsystem for Linux
Created Jan 21, 2018
Installing Kali Linux as a Windows 10 Subsystem for Linux
View Installing Kali Linux as a Windows 10 Subsystem for Linux
Installing Kali Linux as a Windows 10 Subsystem for Linux
Powershell (Admin)
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
lxrun /install
git clone https://github.com/RoliSoft/WSL-Distribution-Switcher.git
cd WSL-Distribution-Switcher
python get-prebuilt.py kalilinux/kali-linux-docker
@SanderTheDragon
SanderTheDragon / postman-deb.sh
Last active Jan 18, 2023
A shellscript to create a Postman .deb file, for simple installation on Debian-based Linux distro's. Also creates a .desktop file.
View postman-deb.sh
#!/bin/sh
# SPDX-FileCopyrightText: 2017-2022 SanderTheDragon <sanderthedragon@zoho.com>
#
# SPDX-License-Identifier: MIT
curlExists=$(command -v curl)
echo "Testing Postman version"