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 / BadTickerException.java
Last active February 21, 2017 13:29
File/Web IO and HTML Writing Example
public class BadTickerException extends IllegalArgumentException {
private static final long serialVersionUID = 1L;
public BadTickerException() {
super();
}
public BadTickerException(String s) {
super(s);
@rjlutz
rjlutz / F3CActivity.java
Created March 14, 2017 22:55
example showing how to traverse chargepoint pojo
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
ChargePoint chargepoint = gson.fromJson(results.get(i).getJson(),
ChargePoint.class);
StationList slist = chargepoint.getStationList();
List<Summary> summaries = slist.getSummaries();
Summary summary = summaries.get(0);
long available = summary.getMapData().getLevel2().getPaid()
.getAvailable();
String toSpeak = available + "! " +
((available == 1) ? "charger is" : "chargers are") +
public class MainActivity extends AppCompatActivity implements SensorEventListener // class decl
SensorManager manager = (SensorManager) getSystemService(SENSOR_SERVICE); // oncreate
manager.registerListener(this, manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), // oncreate or onresume
SensorManager.SENSOR_DELAY_UI);
manager.unregisterListener(this); // ondestory or onpause
@Override
@rjlutz
rjlutz / html changes
Last active May 24, 2017 01:27
Guacamole Cordova Walkthrough
<!-- link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script -->
<link rel="stylesheet" href="lib/jquery.mobile-1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="lib/jquery-2.1.4/jquery-2.1.4.min.js"></script>
<script src="lib/jquery.mobile-1.4.5/jquery.mobile-1.4.5.min.js"></script>
...
<div align="center">
@rjlutz
rjlutz / PixabayQueryResult.java
Created June 5, 2017 02:35
helper class for Pixabay Response. Since we need to cache query results for 24 hours, this method will be used for caching a result. It will also fetch all the bitmaps and cache these too, since those fetches can be long running and can be initiating from a backround task.
package edu.ggc.lutz.pixabay;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import com.google.gson.Gson;
import java.io.IOException;
import java.io.InputStream;
@rjlutz
rjlutz / ComputeArea.java
Created June 7, 2017 03:31
Elementary Programming - examples from Liang Intro to Java Comprehensive 10e
public class ComputeArea {
public static void main(String[] args) {
double radius; // Declare radius
double area; // Declare area
// Assign a radius
radius = 20; // New value is radius
// Compute area
area = radius * radius * 3.14159;
// de-emphasize transient forces
private float lowPass(float current, float gravity) {
// ALPHA indicates the influence level of past observations
return current * (1-ALPHA) + gravity * ALPHA;
}
// de-emphasize constant forces
private float highPass(float current, float gravity) {
return current - gravity;
}
@rjlutz
rjlutz / AdditionQuiz.java
Last active June 11, 2017 23:27
Selections - examples from Liang Intro to Java Comprehensive 10e
import java.util.Scanner;
public class AdditionQuiz {
public static void main(String[] args) {
int number1 = (int)(System.currentTimeMillis() % 10);
int number2 = (int)(System.currentTimeMillis() / 7 % 10);
// Create a Scanner
Scanner input = new Scanner(System.in);
@rjlutz
rjlutz / ComputeAngles.java
Last active June 19, 2017 20:57
Math, Characters, Strings (Chapter 4) - examples from Liang Intro to Java Comprehensive 10e
import java.util.Scanner;
public class ComputeAngles {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// Prompt the user to enter three points
System.out.print("Enter three points: ");
double x1 = input.nextDouble();
double y1 = input.nextDouble();
@rjlutz
rjlutz / Dec2Hex.java
Last active June 26, 2017 18:18
Loops (Chapter 5) - examples from Liang Intro to Java Comprehensive 10e
import java.util.Scanner;
public class Dec2Hex {
/** Main method */
public static void main(String[] args) {
// Create a Scanner
Scanner input = new Scanner(System.in);
// Prompt the user to enter a decimal integer
System.out.print("Enter a decimal number: ");