Skip to content

Instantly share code, notes, and snippets.

View rjlutz's full-sized avatar

Bob Lutz rjlutz

  • Georgia Gwinnett College
  • Lawrenceville, GA
View GitHub Profile
@rjlutz
rjlutz / generate-images.script
Last active January 19, 2019 23:55
Automate JMol to created multiple 2d images through looping
# 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 / CircleWithException.java
Last active November 21, 2018 12:46
Exceptions and File I/O (Chapter 12) -- examples from Liang Intro to Java Comprehensive 10e
public class CircleWithException {
/** The radius of the circle */
private double radius;
/** The number of the objects created */
private static int numberOfObjects = 0;
/** Construct a circle with radius 1 */
public CircleWithException() {
this(1.0);
@rjlutz
rjlutz / storage.dart
Last active November 13, 2018 15:05
helpful artifacts for the flutter student picker app
// 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 October 8, 2018 19:54
Including a SettingsActivity in your Android Studio Project
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) {
@rjlutz
rjlutz / Categories.java
Last active September 10, 2018 03:36
NYT App
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 June 10, 2018 16:07
template for porting Palindrome.java to 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 16:52
Assets for Grizzly Gray (Grizzly Grayscale Picker)
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 / 1 notes
Last active April 1, 2018 13:46
Bike and Barge notes and text bits
add drawables
add to strings (can use translations or copy/paste)
create a new TableLayout underlayouts called photos.xml
add rows (can be found below)
create a new LinearLayout underlayouts called tours.xml
add stuff (can be found below)
@rjlutz
rjlutz / # mumps - 2018-03-06_00-14-37.txt
Created March 6, 2018 05:22
mumps (udacity/carnd-mpc-project/mumps) on macOS 10.13.3 - Homebrew build logs
Homebrew build logs for udacity/carnd-mpc-project/mumps on macOS 10.13.3
Build date: 2018-03-06 00:14:37
@rjlutz
rjlutz / steps
Last active January 30, 2018 22:46
Steps to import Wargo's 14.1 Media Player Example
download or clone https://github.com/johnwargo/apache-cordova-api-cookbook-code
cordova create ...
cordova platform add android
graft content from
~/Downloads/apache-cordova-api-cookbook-code-master/chapter14-media/Ex14.1 (your downloads, of course)
cordova plugin add cordova-plugin-media
cordova plugin add cordova-plugin-device