Skip to content

Instantly share code, notes, and snippets.

@apsun
apsun / duplicity-backup.md
Last active May 27, 2024 11:22
Backup files using duplicity to Backblaze B2

duplicity -> Backblaze B2

Daily systemd timer to backup the contents of my filesystem to Backblaze B2. As-written, it will keep up to a year's worth of backups, performing one full backup every month. This script was tested with duplicity 2.1.0.

Configure the script

Create a B2 bucket and an application key with read/write permissions to that bucket. Configure object lock with a sufficiently long period (I use 3x the full backup period) to ensure that ransomware won't be able to nuke your backups. Also ensure the 'list all bucket names' option is enabled (unless you want to use the

@ytyubox
ytyubox / README.md
Last active December 21, 2021 08:31
UIControlSubscription.swift
@r4dian
r4dian / Unfollow.js
Created October 16, 2017 11:13
Unfollow everything & everyone on Facebook.
// Manual set-up
// click: ▼ at top-right
// Newsfeed preferences
// "Unfollow people to hide their posts" (also includes all Pages, which are not real "people")
// Scroll to the bottom of that so they are all listed
// Open console (f12, or whatever the fuck on MacOS) and paste these two lines:
var e = document.querySelectorAll("._5u3n");
e.forEach(function(elem){ elem.click() });
@Ravi61
Ravi61 / CustomDateCoding.swift
Created July 13, 2017 15:16
Custom Date Encoding/Decoding
// Custom Date Decoding
jsonDecoder.dateDecodingStrategy = .custom({ (decoder) -> Date in
let data = try decoder.singleValueContainer().decode(String.self)
//perform your operation on obtained string
let disturbance = "01-07-1977"
let formatter = DateFormatter()
formatter.dateFormat = "dd-MM-yyyy"
if data == "First disturbance in force" {
return formatter.date(from: disturbance) ?? Date()
} else {
@erikras
erikras / SearchBox.js
Last active September 23, 2020 03:03
A search box that replaces a query parameter in the url
import React, { Component, PropTypes } from 'react'
import { withRouter } from 'react-router'
import queryString from 'query-string'
@withRouter
export default class SearchBox extends Component {
static propTypes = {
router: PropTypes.object.isRequired
}
@Leask
Leask / invertTree.js
Created June 12, 2015 18:28
[Invert Binary Tree] Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off. https://leetcode.com/problems/invert-binary-tree/#.VXqvIdRFNy8.twitter
/**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/
/**
* @param {TreeNode} root
* @return {TreeNode}
@matthewmueller
matthewmueller / osx-for-hackers.sh
Last active April 21, 2024 03:30
OSX for Hackers (Mavericks/Yosemite)
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
@DarkBlade12
DarkBlade12 / ReflectionUtils.java
Last active August 8, 2019 23:49
These are utils which make dealing with reflection much easier.
package com.darkblade12.particledemo.particle;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
@t-io
t-io / osx_install.sh
Last active October 22, 2023 13:04
Install most of my Apps with homebrew & cask
#!/bin/sh
echo Install all AppStore Apps at first!
# no solution to automate AppStore installs
read -p "Press any key to continue... " -n1 -s
echo '\n'
echo Install and Set San Francisco as System Font
ruby -e "$(curl -fsSL https://raw.github.com/wellsriley/YosemiteSanFranciscoFont/master/install)"
echo Install Homebrew, Postgres, wget and cask
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@DarkBlade12
DarkBlade12 / ParticleEffect.java
Last active December 23, 2023 16:20
This is a little library which allows you to display all possible particle effects in Minecraft with your plugin.
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit;