Skip to content

Instantly share code, notes, and snippets.

brandhill /
Created Aug 23, 2020 — forked from johnwatsondev/
Customizing the DividerItemDecoration class so we can remove divider / decorator after the last item
* Copyright (C) 2016 The Android Open Source Project
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
brandhill /
Created Aug 16, 2020 — forked from sheharyarn/
Set Empty Layout for RecyclerViews in Android
* Custom implementation of AdapterDataObserver to show empty layouts
* for RecyclerView when there's no data
* Usage:
* adapter.registerAdapterDataObserver(new RVEmptyObserver(recyclerView, emptyView));
public class RVEmptyObserver extends RecyclerView.AdapterDataObserver {
private View emptyView;
protected void onCreate(Bundle savedInstanceState) {
// fixing portrait mode problem for SDK 26 if using windowIsTranslucent = true
if (Build.VERSION.SDK_INT == 26) {
} else {
brandhill / delete_artifacts.groovy
Created Apr 9, 2019 — forked from perja12/delete_artifacts.groovy
Delete artifacts from Jenkins with Groovy script.
View delete_artifacts.groovy
// Delete old artifacts that fills up the disk on the master node.
// Run this from the Jenkins console (Manage Jenkins, Manage Nodes, master, Script Console)
def project = Jenkins.get().getItemByFullName('your-project-id')
def jobs = project.getAllJobs()
def total_size = 0
jobs.each{ job ->
def builds = job.getBuilds()

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.

Effective Engineer - Notes

What's an Effective Engineer?

brandhill /
Last active Jul 1, 2018
Generic Adapter Pseido code
public class CategoriesAdapter extends GenericRecycleAdapter<Category, Holders.TextImageHolder> {
public CategoriesAdapter(List<Category> list, Context context) {
super(list, context);
void onItem(Category category) {
brandhill / System
Created Oct 10, 2017 — forked from vasanthk/System
System Design Cheatsheet
View System

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
brandhill / ninePatchDemo.swift
Created Jul 29, 2017
Equivalent Android 9-patch for iOS and Swift 3.0 (multiple stretchable areas)
View ninePatchDemo.swift
// origin
UIImageView *unHandleImg = [[UIImageView alloc] initWithFrame:CGRectMake((SCREENWIDTH-200)/2, 100, 200, 30)];
unHandleImg.image = [UIImage imageNamed:@"theImage"];
[self.view addSubview:unHandleImg];
// with stretchable
UIImageView *handleImg = [[UIImageView alloc] initWithFrame:CGRectMake((SCREENWIDTH-200)/2, 200, 200, 30)];
UIImage *img = [UIImage imageNamed:@"theImage"];
// stretchable areas
img = [img resizableImageWithCapInsets:UIEdgeInsetsMake(35, 35, 35, 35) resizingMode:UIImageResizingModeStretch];
View gist:18845c14bc98e51bb713274c8bc14e2d
git reset HEAD^ # remove commit locally
git push origin +HEAD # force-push the new HEAD commit
git push origin +HEAD^:<name of your branch, most likely 'master'> # Ex: git push origin +HEAD^:Ring_master
brandhill / com.user.loginscript.plist
Last active May 31, 2017
Run a script at login for all users
View com.user.loginscript.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">