Skip to content

Instantly share code, notes, and snippets.

View thenickreynolds's full-sized avatar

Nick Reynolds thenickreynolds

View GitHub Profile
@thenickreynolds
thenickreynolds / How To Ask Great Questions.md
Last active September 25, 2022 03:53
Article: How to Ask Great Questions

One aspect of being a successful engineer is asking great questions! We shouldn't be afraid to ask questions (they are critical to how we learn and grow) but, if you follow these steps, you'll ensure the questions you ask are high quality and you can learn the most from the answers you get.

When

Ask when you've gotten stuck for a while (e.g. 20 minutes) and you're not making progress or if you've been spinning your wheels for a while.

Before you do

Make sure you've searched for the answer in the documentation, Stack Overflow, in channels (on Slack or Discord), etc.

How

Get straight to the point (skip the hello) and ask in the right place (where are the experts for this).

@thenickreynolds
thenickreynolds / index.d.ts
Created August 1, 2020 19:09
sharethis-reactjs types for InlineShareButtons
declare module "sharethis-reactjs" {
type SharingNetwork =
| "blogger"
| "delicious"
| "digg"
| "email"
| "facebook"
| "flipboard"
| "google"
| "linkedin"
@thenickreynolds
thenickreynolds / CellBackgroundColorItemDecorator.java
Created January 23, 2017 20:57
Add a background color (or in the future dotted outline, etc.) for a cell background that does not move with dragging/swiping
/**
* This adds a background color to all recycler view cells that is not moved when dragging a view - this allows a "placeholder" for dragged items
* such as a background color, in the future a dotted/broken line outline, etc.
*/
public class CellBackgroundColorItemDecorator extends ItemDecoration {
private final Paint colorPaint;
public CellBackgroundColorItemDecorator(@ColorInt int color) {
colorPaint = new Paint();
colorPaint.setColor(color);
@thenickreynolds
thenickreynolds / OptionsMenuFactory.java
Created December 9, 2016 20:18
This is a possible solution to allow adapters to create options menus without knowing about UI... Similar to providing a list of options to the fragment in many ways
import android.content.Context;
import android.support.design.widget.BottomSheetDialog;
import android.support.v7.view.menu.MenuBuilder;
import com.airbnb.android.utils.Check;
import com.airbnb.n2.BottomSheetBuilder;
import com.airbnb.n2.BottomSheetItemClickListener;
import com.airbnb.n2.BottomSheetMenuItem;
import java.util.List;
protected <T> void subscribe(Observable<T> observable, ResubscriptionObserver<T> observer) {
observable.compose(observableGroup.<T>transform(observer.resubscriptionTag().toString()))
.subscribe(observer);
}
@thenickreynolds
thenickreynolds / Slow Compilation Examples.swift
Created August 9, 2016 23:57
Slow Compilation Examples
// Code snippet 1
func test() {
let f: Int = 5
// Original:
CGPoint(x: f + f * (f + f) + f * f, y: 1) // (1.5786 sec)
// Faster:
let x = f + f * (f + f) + f * f; let y = 1; CGPoint(x: x, y: y) // put in variables (0.0066 sec)
var trie = createTrie(dictionary);
function findWords(board) {
var count = 0;
var visited = [];
for (var x = 0; x < board.width; x++) {
visited[x] = []
for (var y = 0; y < board.height; y++) {
var BoggleBoard = function(letters, width, height) {
if (letters.length != width * height) throw 'incorrect board length';
this.width = width;
this.height = height;
this.letters = letters;
}
BoggleBoard.prototype.at = function(x, y) {
var TrieNode = function(letter) {
this.letter = letter == null ? null : letter.toUpperCase();
this.children = [];
this.isLeaf = false;
};
TrieNode.prototype.hasChild = function(letter) {
return letter.toUpperCase() in this.children;
};
var dictionary = [
'the',
'of',
'and',
'to',
'a',
'in',
'for',
'is',
'on',