Skip to content

Instantly share code, notes, and snippets.

Repo

Haven't decided if I am going to submit code to it yet

Questions

👍 - Unlocked & Done 😊 - Locked & Done 🔒 - Locked & Not Done [] - Not yet Done

@brandhill
brandhill / DividerItemDecoration.java
Created August 23, 2020 15:36 — forked from johnwatsondev/DividerItemDecoration.java
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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@brandhill
brandhill / RVEmptyObserver.java
Created August 16, 2020 13:23 — forked from sheharyarn/RVEmptyObserver.java
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;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_layout);
// fixing portrait mode problem for SDK 26 if using windowIsTranslucent = true
if (Build.VERSION.SDK_INT == 26) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
@brandhill
brandhill / delete_artifacts.groovy
Created April 9, 2019 07:59 — forked from perja12/delete_artifacts.groovy
Delete artifacts from Jenkins with Groovy script.
// 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
brandhill / AdapterUsage.java
Last active July 1, 2018 03:21
Generic Adapter Pseido code
public class CategoriesAdapter extends GenericRecycleAdapter<Category, Holders.TextImageHolder> {
public CategoriesAdapter(List<Category> list, Context context) {
super(list, context);
}
@Override
void onItem(Category category) {
@brandhill
brandhill / System Design.md
Created October 10, 2017 14:27 — forked from vasanthk/System Design.md
System Design Cheatsheet

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
brandhill / ninePatchDemo.swift
Created July 29, 2017 07:15
Equivalent Android 9-patch for iOS and Swift 3.0 (multiple stretchable areas)
// 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];