Skip to content

Instantly share code, notes, and snippets.

@maddiesch
maddiesch / minecraft_backup.sh
Created April 3, 2014 17:30
This shell script is run daily by cron to create backups of a minecraft server.
screen -R MC -X stuff "say Performing backup $(printf '\r')"
screen -R MC -X stuff "save-off $(printf '\r')"
screen -R MC -X stuff "save-all $(printf '\r')"
sleep 3
# Backup
cd /<path to backups folder>
# Delete file older than 5 days
@maddiesch
maddiesch / Makefile
Last active July 17, 2023 15:04
Golang Makefile for SAM project
GOLANG := go
GOLANG_TEST_FLAGS ?= -v
GOLANG_TEST_RUN ?= .
GOLANG_TEST_PATH ?= ./...
GO_LAMBDA_ENV ?= GOOS=linux GOARCH=arm64
GO_LAMBDA_BUILD_FLAGS ?= -ldflags="-s -w" -tags "lambda.norpc"
GO_LAMBDA_BUILD ?= ${GO_LAMBDA_ENV} ${GOLANG} build ${GO_LAMBDA_BUILD_FLAGS}
GO_FILES := $(shell find . -type f -name '*.go' ! -name '*_test.go')
GO_TEST_FILES := $(shell find . -type f -name '*_test.go')

Keybase proof

I hereby claim:

  • I am maddiesch on github.
  • I am maddiesch (https://keybase.io/maddiesch) on keybase.
  • I have a public key ASB_3FY7wHHMvDrCf_E5f9jEMUZfFScfUUEJNRMqDxf6YQo

To claim this, I am signing this object:

@maddiesch
maddiesch / gist:4727403
Last active November 12, 2022 15:25
Create an animated UIImage from .gif data.
+ (UIImage *)imageFromGifData:(NSData *)data {
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFTypeRef)data, NULL);
if (!source) {
return nil;
}
CFDictionaryRef dict = CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
NSDictionary *metadata = (__bridge NSDictionary *)dict;
CGFloat offset = 0.0;
if (metadata[@"{GIF}"]) {
NSDictionary *meta = metadata[@"{GIF}"];
function __git_prompt () {
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return
fi
echo -n "%{$fg[cyan]%}($(git_current_branch))"
echo -n "%{$fg[green]%}[$(git rev-parse HEAD 2> /dev/null | head -c 6)]"
echo -n "%{$fg[cyan]%} $(parse_git_dirty)$(git_remote_status)"
echo -n "%{$reset_color%}"
}
@maddiesch
maddiesch / Makefile
Last active November 19, 2020 06:31
Basic Golang & SAM Makefile
# Configuration
SAM_ARTIFACT_BUCKET := <artifact-bucket-name>
SAM_STACK_NAME := <sam cloudformation stack name>
SAM_DEPLOY_CAPABILITIES := CAPABILITY_IAM
SAM_TEMPLATE_PARAMETERS :=
export AWS_PROFILE := default
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
.PHONY: build
@maddiesch
maddiesch / AuroraServerless.yml
Last active February 25, 2019 03:05
Create an aurora serverless cluster.
---
Parameters:
DatabaseUsernameTemplateParameter:
Type: String
Description: The username for the database user
MaxLength: 16
Default: root
DatabasePasswordTemplateParameter:
Type: String
Description: The password for the database user

Destiny 2 Error codes

  • SNAIL
  • CHICKEN
  • DUCK
  • PONY
  • CAT
  • SHEEP
  • ELK
  • BOAR

Keybase proof

I hereby claim:

  • I am maddiesch on github.
  • I am skylarsch (https://keybase.io/skylarsch) on keybase.
  • I have a public key whose fingerprint is 0A98 EEB9 3667 76EF BFED A7FC EB5C 9CC8 F793 91D4

To claim this, I am signing this object:

@maddiesch
maddiesch / run.rb
Created August 22, 2018 20:32
Run a subcommand a set number of times
#!/usr/bin/env ruby
##
# Usage `run --number 5 b rspec`
#
#
##
require 'optparse'
require 'open3'