Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
DATESTAMP=`date "+%Y-%m-%d-%H-%M-%S"`
MOPIDY_CONFIG_DIR="$HOME/.config/mopidy"
MOPIDY_CONFIG="$MOPIDY_CONFIG_DIR/mopidy.conf"
MOPIDY_SUDOERS="/etc/sudoers.d/010_mopidy-nopasswd"
MOPIDY_DEFAULT_CONFIG="$MOPIDY_CONFIG_DIR/defaults.conf"
EXISTING_CONFIG=false
PYTHON_MAJOR_VERSION=3
PIP_BIN=pip3
/*
* Block Safety
*
* We sometimes accidentally invoke a nil block...this protects against it.
*
*/
#define SAFE_CALL(b, ...) \
if(b) b(__VA_ARGS__);
/*
* Strongify / Weakify shortcuts
*
* These declare and instantiate weak and strong variables
* statically so it's easier to write. It's a nice middle-ground
* when compared to other solutions in the wild.
*
*/
#define WEAKIFY(aSelf) __weak typeof(aSelf) weakSelf = aSelf;
#define STRONGIFY(aSelf) __strong typeof(aSelf) strongSelf = aSelf;
/**
* Lazy Getter
*
* Helps reduce silly errors when writing lazy getters.
*/
#define ADD_LAZY_GETTER(type, name, initialValueBlock) \
-(type)name \
{ \
if (!_##name) { \
_##name = initialValueBlock(); \
#
# This is my preferred .bash_profile
#
# It has more context around git repositories, coloring, etc. Sections of this .bash_profile
# were certainly inspired by others' files (especially the git aliases).
#
export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
@vinnybad
vinnybad / Fastfile
Created June 3, 2016 19:16
Shows one way to fail a build in fastlane when code coverage does not meet a minimum threshold.
#
# Shows one way to fail a build in fastlane when code
# coverage does not meet a minimum threshold.
#
# there are other ways to check the coverage of the commit,
# but I couldn't find an existing tool that makes this easier
# that will run on bitrise. I would have normally used diff-cover
# to do this because you can compare branches and only check the diffs.
# Unfortunately that means you have to find a way to install it on bitrise
# at the time of writing and that can be tricky.
/**
* Lazily initializes an object. Mainly used for reducing boilerplate code.
*/
#define DEFINE_LAZY_GETTER(type, name, initialValueBlock) \
- (type)name { \
if (! _ ## name) { \
_ ## name = initialValueBlock(); \
} \
return _ ## name; \
}
@vinnybad
vinnybad / mergegenstrings.py
Created January 21, 2016 19:24 — forked from yoichitgy/mergegenstrings.py
A script to generate .strings file for .swift, .m, .storyboard and .xib files by genstrings and ibtool commands, and merge them with existing translations.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Localize.py - Incremental localization on XCode projects
# João Moreno 2009
# http://joaomoreno.com/
# Modified by Steve Streeting 2010 http://www.stevestreeting.com
# Changes
# - Use .strings files encoded as UTF-8
@vinnybad
vinnybad / genAllStrings.m
Last active November 6, 2015 03:09
Generate .strings files for a particular language (overwrites existing strings file)
#!/bin/bash
# find all .m files and pump it through genstrings, outputting it to en.lproj/Localizable.strings
find . -name '*.m' | xargs genstrings -o en.lproj
@vinnybad
vinnybad / BJMWebService.m
Last active October 3, 2015 20:26
Download a file using AFNetworking
/*
* Downloading files using AFNetworking is not a 1-step process, but it's still pretty easy.
*
* NOTE: If you're downloading a file from S3, make sure to set the proper Content-Type. For example,
* a zip file should ideally have the content type of application/zip.
*
* Inspired by various sources online.
*/
#pragma mark - Downloading Files