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 / BadTickerException.java
Last active Feb 21, 2017
File/Web IO and HTML Writing Example
View BadTickerException.java
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 Mar 14, 2017
example showing how to traverse chargepoint pojo
View F3CActivity.java
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") +
View gist:3e000bcffb0cfb48e8aba76715c556ac
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 / Palindrome Utility
Last active Aug 15, 2018
Bits to build a palindrome app, class with static method that tests a string to see if its a palindrome
View Palindrome Utility
public class Palindrome {
public static boolean check(String _s) {
return check(_s, 0, _s.length()-1);
}
private static boolean check(String _s, int _start, int _end) {
// base case
if (_start >= _end) return true;
@rjlutz
rjlutz / html changes
Last active May 24, 2017
Guacamole Cordova Walkthrough
View html changes
<!-- 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">
View Bruschetta strings.xml
<resources>
<string name="app_name">Recipe</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="tvTitle">Bruschetta</string>
<string name="description">Recipe Image</string>
<string name="btnRecipe">View Recipe</string>
<string name="tvIngredients">Ingredients</string>
<string name="tvIngredients1">4 plum tomatoes</string>
@rjlutz
rjlutz / PixabayQueryResult.java
Created Jun 5, 2017
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.
View PixabayQueryResult.java
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 Jun 7, 2017
Elementary Programming - examples from Liang Intro to Java Comprehensive 10e
View ComputeArea.java
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;
View ..lowPass highPass methods
// 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 Jun 11, 2017
Selections - examples from Liang Intro to Java Comprehensive 10e
View AdditionQuiz.java
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);
You can’t perform that action at this time.