Skip to content

Instantly share code, notes, and snippets.

View zsiegel's full-sized avatar

Zac Siegel zsiegel

View GitHub Profile

Keybase proof

I hereby claim:

  • I am zsiegel on github.
  • I am zac_siegel (https://keybase.io/zac_siegel) on keybase.
  • I have a public key ASCYByFxKK6PPTljWeUDyY0yPJ2Ynh1Go0j-IqN-T2TbNwo

To claim this, I am signing this object:

@zsiegel
zsiegel / arch_setup.md
Last active July 15, 2021 06:56
ArchLinux install steps

ARCH LINUX

This is a simple guide with un-encrypted volumes.

  • setup the time
    • timedatectl set-ntp true
  • rank your packman mirrors
    • cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
    • rankmirrors -n 3 /etc/pacman.d/mirrorlist.bak > /etc/pacman.d/mirrorlist
  • update pacman
@zsiegel
zsiegel / systemd-example.md
Last active May 9, 2020 01:20
systemd example - works on Ubuntu 16.04

Ubuntu 16.04 systemd service setup

Enable persistent user systemd services

loginctl enable-linger $user

Create a user systemd directory

mkdir -p ~/.config/systemd/user
@zsiegel
zsiegel / build-version.gradle
Last active January 9, 2020 06:42
Android manifest versioning with gradle and git
task('increaseVersionCode') << {
def manifestFile = file("src/main/AndroidManifest.xml")
def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
def manifestText = manifestFile.getText()
def matcher = pattern.matcher(manifestText)
matcher.find()
def versionCode = Integer.parseInt(matcher.group(1))
android.defaultConfig.versionCode = versionCode + 1
println "Setting version code to ${android.defaultConfig.versionCode}"
def manifestContent = matcher.replaceAll("versionCode=\"" + android.defaultConfig.versionCode + "\"")
@zsiegel
zsiegel / gist:3939819
Created October 23, 2012 16:18
Core Text - Calculating line height
CGFloat GetLineHeightForFont(CTFontRef iFont)
{
CGFloat lineHeight = 0.0;
check(iFont != NULL);
// Get the ascent from the font, already scaled for the font's size
lineHeight += CTFontGetAscent(iFont);
// Get the descent from the font, already scaled for the font's size
@zsiegel
zsiegel / gist:7919194
Last active December 31, 2015 02:09
Android Strict Mode
public void setupStrictMode() {
StrictMode.enableDefaults();
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDeath()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
@zsiegel
zsiegel / gist:7588299
Last active December 29, 2015 00:49
WTF
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
teamSelector.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
teamSelector.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
@zsiegel
zsiegel / gist:3969946
Created October 28, 2012 21:15
CouchDB replication filter template
function (doc, req) {
if(doc._deleted){ return true; }
//YOUR CUSTOM LOGIC HERE
return false;
}
@zsiegel
zsiegel / gist:3954413
Created October 25, 2012 18:12
UIView Rounded Corner Mask
CAShapeLayer *layer = [CAShapeLayer layer];
NSUInteger cornersToRound = UIRectCornerTopLeft | UIRectCornerBottomLeft;
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds
byRoundingCorners:cornersToRound
cornerRadii:CGSizeMake(5.0, 5.0)];
layer.path = path.CGPath;
self.layer.mask = layer;
@zsiegel
zsiegel / gist:3954411
Created October 25, 2012 18:12
UIView Rounded Corner Mask
CAShapeLayer *layer = [CAShapeLayer layer];
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerBottomLeft) cornerRadii:CGSizeMake(5.0, 5.0)];
layer.path = path.CGPath;
self.layer.mask = layer;