Skip to content

Instantly share code, notes, and snippets.

@cagartner
cagartner / deploy.sh
Last active April 20, 2024 09:20
Laravel Push deploy Github actions example
#!/bin/sh
set -e
vendor/bin/phpunit
(git push) || true
git checkout production
git merge master
@recursivecodes
recursivecodes / backup.sh
Last active May 12, 2023 04:04
backup.sh
#!/usr/bin/env bash
source ~/.zshrc
PROFILE_NAME=DEFAULT
BACKUP_NAME=[your_manual_backup_name]
TMP_BACKUP_NAME=$(date +%Y-%m-%d_%H-%M-%S)
echo "Running at ${TMP_BACKUP_NAME}."
echo "Getting previous backup..."
@loveshizuka
loveshizuka / _vultr-snapshot.md
Created December 18, 2017 23:04
Automatic snapshots using Vultr API

Automated Snapshots / Backups via Vultr API

A more customizable alternative to Vultr's backup feature using Vultr API v1. Tested on Ubuntu 16.04. Run this php script on a Vultr instance to create a snapshot of itself and rotate out the oldest snapshot(s). Use the $backup_tag field to uniquely id a set of snapshots.

  1. Set $api_key to your Vultr API key.
  2. Set $num_of_backups to specify how many snapshots to keep.
  3. Set chmod +x vultr-snapshot.php.
  4. Add vultr-snapshot.php to your cron tab.
  5. Epic winning at life.
@andyrbell
andyrbell / scanner.sh
Last active April 5, 2024 09:01
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@matthiassb
matthiassb / auth-duo.py
Created July 31, 2016 03:31
PAM LDAP Authentication with two-factor authentication with DUO in python
import duo_client
import ldap
auth_api = duo_client.Auth(
ikey='<ikey>',
skey='<skey>',
host='<host>',
)
LDAP_SERVER = 'ldap://10.1.0.143'
@jpillora
jpillora / tinc-install.sh
Last active March 2, 2021 09:56
Install and run tinc-1.1pre11 on Raspberry Pi 2 (Raspberrian)
# install tinc
apt-get update && echo "===> update deps" &&
apt-get install -y make libssl-dev zlib1g-dev liblzo2-dev libreadline-dev libncurses5-dev && echo "===> got deps" &&
curl http://www.tinc-vpn.org/packages/tinc-1.1pre11.tar.gz | tar xzvf - && echo "===> got tinc src" &&
cd tinc-1.1pre11 &&
./configure && echo "===> configured tinc" &&
make &&
make install && echo "===> installed tinc" &&
tinc --version # tinc version 1.1pre11 (built Nov 12 2015 16:25:28, protocol 17.4)
@ahknight
ahknight / fix_timemachine_backup.sh
Last active August 9, 2023 20:25
When Time Machine asks you to delete your backups and start over, ignore it. Run this and then start a backup again.
#!/bin/bash -x
# Generally based on ideas found at:
# http://www.garth.org/archives/2011,08,27,169,fix-time-machine-sparsebundle-nas-based-backup-errors.html
#
# Reduced the ideas there down to their essentials.
# 1. Unlock the image.
# 2. Reset the saved failure in the backup metadata.
# 3. Verify/fix the filesystem.
@egoist
egoist / Gravatar.php
Created November 23, 2014 05:47
Gravatar Library using V2EX CDN
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// Remove the very first line to use class outside of codeigniter
/*
* Gravatar library for use with codeigniter <V2EX driven>
*
* @author 0x142857 <0x142857@gmail.com>
* @link http://0x142857.com
* @package Codeigniter
* @subpackage Gravatar
*
@snakevil
snakevil / openwrt-barrierbreaker-rc3-handbook.md
Last active July 26, 2021 13:42
OpenWrt BarrierBreaker 14.07-rc3 手记

OpenWrt BarrierBreaker 14.07-rc3 手记

1 外置存储 - ExtRoot

1.1 USB HDD 分区

安装依赖和工具包:
@lanceliao
lanceliao / dnsmasq-gfwlist.py
Last active August 18, 2023 11:26
将gfwlist转换成带ipset的dnsmasq规则,适用于OpenWrt智能上网
#!/usr/bin/env python
#coding=utf-8
#
# Generate a list of dnsmasq rules with ipset for gfwlist
#
# Copyright (C) 2014 http://www.shuyz.com
# Ref https://code.google.com/p/autoproxy-gfwlist/wiki/Rules
import urllib2
import re