Skip to content

Instantly share code, notes, and snippets.

@brandhill
brandhill / DividerItemDecoration.java
Created Aug 23, 2020 — forked from johnwatsondev/DividerItemDecoration.java
Customizing the DividerItemDecoration class so we can remove divider / decorator after the last item
View DividerItemDecoration.java
/*
* 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 Aug 16, 2020 — forked from sheharyarn/RVEmptyObserver.java
Set Empty Layout for RecyclerViews in Android
View RVEmptyObserver.java
/**
* 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;
View Activity.java
@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 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()
View Effective_Engineer.md

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 Jul 1, 2018
Generic Adapter Pseido code
View AdapterUsage.java
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 Oct 10, 2017 — forked from vasanthk/System Design.md
System Design Cheatsheet
View System Design.md

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 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
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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.loginscript</string>
<key>ProgramArguments</key>
<array>
<string>/path/to/executable/script.sh</string>
</array>