Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
"""
This script is used to backup and restore RocksDB database instances
Example:
$ python3 backup.py backup ./my_live_db ./backup/
$ python3 backup.py restore ./backup ./my_live_db
"""
@jdmcd
jdmcd / AutoContentDecode.swift
Last active April 28, 2020 16:44
A collection of helpers for Vapor 4
// An extension to replicate the same functionality from Vapor 3 with automatic content decoding:
import Foundation
import Vapor
/// A basic, closure-based `Responder`.
struct ContentBasicResponder<C: Content>: Responder {
/// The stored responder closure.
private let closure: (Request, C) throws -> EventLoopFuture<Response>
@JohnCoates
JohnCoates / Readme.md
Last active September 27, 2021 20:24
HEVC HLS Creation
@preble
preble / WeakSet.swift
Last active July 13, 2023 06:45
A pure Swift weak set.
//
// Created by Adam Preble on 2/19/15.
//
/// Weak, unordered collection of objects.
public struct WeakSet<T where T: AnyObject, T: Hashable> {
typealias Element = T
/// Maps Element hashValues to arrays of Entry objects.
/// Invalid Entry instances are culled as a side effect of add() and remove()
@n1k0
n1k0 / longest-request.md
Last active December 12, 2015 08:29
Find the longest request when loading a given url using CasperJS

Find longest request using CasperJS

This gist is based on this one.

// longest-request.js
var casper = require("casper").create();
var utils = require("utils");
var url = casper.cli.get(0);
var times = [];
package Mojolicious::Lite::MyKeywords;
use Mojo::Base -base;
use Mojo::Util 'monkey_patch';
sub import {
my $caller = caller;
# Export "get_post" keyword (reuse "any" keyword to make "under" work)
monkey_patch $caller, 'get_post', sub {
package Mojolicious::Plugin::Pipeline::CSSCompressor;
use Mojo::Base 'Mojolicious::Plugin';
use CSS::Compressor 'css_compress';
sub register {
my ($self, $app) = @_;
# Register "css_compressor" filter
$app->filter(css_compressor => sub { css_compress shift });
@diegok
diegok / mojo_ua_gzip.pl
Created October 10, 2011 01:09
Mojo::UserAgent with gzip support
#!/usr/bin/env perl
use 5.12.0;
use Mojo::UserAgent;
use Compress::Zlib;
my $ua = Mojo::UserAgent->new;
$ua->on( start => sub {
my ( $ua, $tx ) = @_;