Skip to content

Instantly share code, notes, and snippets.

@toddway
toddway / aChecklistForReviewingCode.md
Last active October 7, 2020 15:50
A checklist for reviewing code

A checklist for reviewing code

Integration

  • Will merging this code create source conflicts?
  • Is there a clear and concise description of the changes?
  • Did all automated checks (build, test, lint) run and pass?
  • Are there supporting metrics or reports (e.g. test coverage, fitness functions) that measure the impact?
  • Are there obvious logic errors or incorrect behaviors that might break the software?

Readability

@toddway
toddway / pr-to-ide.sh
Created April 18, 2018 18:54
bash command to fetch PR and launch in Android Studio
#!/bin/sh
if [ -z "$1" ]
then
echo must provide a PR number
else
git fetch origin pull/$1/head:pr-$1 # for github
git fetch origin pull-requests/$1/from:pr-$1 # for bitbucket
git checkout pr-$1
studio .
@toddway
toddway / Examples.kt
Created July 24, 2017 18:47
Kotlin property delegates for SharedPreferences
val preferences : SharedPreferences = ...
//Old way...
val MY_BOOLEAN_PREF = "myBooleanPref"
val MY_STRING_PREF = "myStringPref"
fun oldSharedPreferenceExample() {
//set
val editor = preferences.edit()
@toddway
toddway / README.md
Last active August 29, 2015 14:22
Sample Public Gist

coming soon

@toddway
toddway / cache-get-json.js
Created April 29, 2013 21:43
Cache getJSON calls
var fetchCache = {};
function fetchJSON(url, callback, secondsToCache) {
secondsToCache = secondsToCache ? secondsToCache : 60*60; //default to one hour
var nowInSeconds = Math.round(new Date().getTime() / 1000);
if (!fetchCache[url] || ((fetchCache[url].timestamp + secondsToCache) < nowInSeconds)) {
$.getJSON(url, function(response) {
fetchCache[url] = {response: response, timestamp: nowInSeconds};
callback(fetchCache[url].response);
});
}
(function ($) {
//request user 1 in JSON format
$.getJSON('http://mysite.com/rest/user/1.json', function(data) {
console.log(data); //print the JSON response object to the console
});
})(jQuery);
@toddway
toddway / gist:5171043
Created March 15, 2013 16:13
PHP/Drupal example of making an authenticated user search request to the Passport API
<?php
/*
PHP/Drupal example of making an authenticated user search request to the Passport API
*/
function example_passport_api_request() {
$server = 'http://example.com/rest/';
//login request - we need to authenticate before requesting protected data
$username = 'username';