Skip to content

Instantly share code, notes, and snippets.

Bob Lutz rjlutz

Block or report user

Report or block rjlutz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rjlutz
rjlutz / DiceNotation.java
Created Feb 25, 2019
Class to Perform Creation of Die Set
View DiceNotation.java
package edu.ggc.lutz.dungeonmasterdiceroller;
// adapted from:
// https://stackoverflow.com/questions/35020687/how-to-parse-dice-notation-with-a-java-regular-expression
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DiceNotation {
@rjlutz
rjlutz / generate-images.script
Last active Jan 19, 2019
Automate JMol to created multiple 2d images through looping
View generate-images.script
# script to systematically create many images of molecular structures
# R Lutz 19 Jan 2019
set antialiasImages FALSE # the following is recommended to avoid ragged
# edges around the image, per JMol docs
# ====================================================================
# CONFIGURABLE PARAMS
var rot_max = 2.0 # in degrees
var output_width = 600 # shouldn't be > 600, according to automl guidance
@rjlutz
rjlutz / storage.dart
Last active Nov 13, 2018
helpful artifacts for the flutter student picker app
View storage.dart
// thanks - https://flutter.io/docs/cookbook/persistence/reading-writing-files
import 'dart:async';
import 'dart:io';
import 'package:path_provider/path_provider.dart';
import 'student.dart';
class Storage {
Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
@rjlutz
rjlutz / Basic steps
Last active Oct 8, 2018
Including a SettingsActivity in your Android Studio Project
View Basic steps
1 - Use existing Android Studio project or create a new project. If new, start with a Basic Activity so that the Settings pulldown is available under the Options menu.
2 - It might be good to test deploy to make sure everyting is working ok.
3 - Create a new SettingsActivity. File -> New -> Activity -> SettingsActivity
4 - Link the new Activity to the Options menu. Navigate to app -> java -> <<your package>> -> MainActivity.java and add the following to onOptionsItemSelected():
@Override
public boolean onOptionsItemSelected(MenuItem item) {
View Categories.java
package package <<YOUR PACKAGE HERE>>;
import java.util.HashMap;
public class Categories extends HashMap<String, String> {
public Categories() {
put("Home","home");
put("Opinion", "opinion");
put("World", "world");
@rjlutz
rjlutz / main.dart
Created Jun 10, 2018
template for porting Palindrome.java to dart
View main.dart
// refer to the Java code here:
// https://gist.github.com/rjlutz/3c26a1be877529de8dd28049d12415d0
// complete the dart implementation below to have the same functionality
class Palindrome {
// TODO implement check
static check(String s) {
return true;
}
}
@rjlutz
rjlutz / decToBase method
Last active May 22, 2018
Assets for Grizzly Gray (Grizzly Grayscale Picker)
View decToBase method
private String decToBase(int d, int base) {
// credit to and adapted from:
// https://stackoverflow.com/questions/13465098/decimal-to-hexadecimal-converter-in-java
// Note that there are several one-liners that can be used too
String digits = "0123456789ABCDEF";
String hex = "";
if (d <= 0) hex = "0";
while (d > 0) {
int digit = d % base; // rightmost digit
hex = digits.charAt(digit) + hex; // string concatenation
@rjlutz
rjlutz / # mumps - 2018-03-06_00-14-37.txt
Created Mar 6, 2018
mumps (udacity/carnd-mpc-project/mumps) on macOS 10.13.3 - Homebrew build logs
View # mumps - 2018-03-06_00-14-37.txt
Homebrew build logs for udacity/carnd-mpc-project/mumps on macOS 10.13.3
Build date: 2018-03-06 00:14:37
@rjlutz
rjlutz / detect.py
Last active Jan 17, 2019
Starter code and data files for neural net / python practice assignment
View detect.py
## modified from:
## https://github.com/miloharper/simple-neural-network and
## https://medium.com/technology-invention-and-more/how-to-build-a-simple-neural-network-in-9-lines-of-python-code-cc8f23647ca1
## thanks!
import csv
from numpy import exp, array, random, dot
class NeuralNetwork():
def __init__(self):
@rjlutz
rjlutz / BubbleSort.java
Last active Nov 10, 2017
Sorting and Searching (Chapter 23) -- examples from Liang Intro to Java Comprehensive 10e
View BubbleSort.java
public class BubbleSort {
/** Bubble sort method */
public static void bubbleSort(int[] list) {
boolean needNextPass = true;
for (int k = 1; k < list.length && needNextPass; k++) {
// Array may be sorted and next pass not needed
needNextPass = false;
for (int i = 0; i < list.length - k; i++) {
if (list[i] > list[i + 1]) {
You can’t perform that action at this time.