In this tutorial we will parse Flickr JSON
https://api.flickr.com/services/feeds/photos_public.gne?tags=mountains&tagmode=all&format=json#
As an Amazon Associate I earn from qualifying purchases.
Java: read URL to String text
To process JSON feed from Flickr we will have to get text from URL, this can be done with this simple utility
As an Amazon Associate I earn from qualifying purchases.
Android: adb: filtering logcat
Usually I use IDE, but sometimes I have to create a very precise LOGCAT FILTER in terminal window.
Here is how I create a tag:
private static final String TAG = SomeActivity.class.getSimpleName();
Log.d(TAG, "some description");
You could use getCannonicalName
Here I have following TAG filters:
- any (*) View - VERBOSE
- any (*) Activity - VERBOSE
- any tag starting with Xyz(*) - ERROR
- System.out - SILENT (since I am using Log in my own code)
Here what I type in terminal:
$ adb logcat *View:V *Activity:V Xyz*:E System.out:S
please +1 on stockoverflow:
http://stackoverflow.com/a/29307682/3566154
It takes time and effort to create tutorials, please support my efforts with a couple-dollar donation, any amount will be greatly appreciated and highly motivating!
Linux: RPM
Here is couple of functions I use when working with RPM packages:
Show containing "postg"
Show top 20:
Install package:
Uninstall:
Show containing "postg"
rpm -qa | grep postg
Show top 20:
rpm -qa | tail -20
Install package:
rpm -ivh somed-1.0.0.armv7l
Uninstall:
rpm -e somed-1.0.0.armv7l
find similar posts:
Linux/Unix,
RPM
Java Map interface
In this tutorial we will discuss various implementations of Java Map interface. Java Map is one of the most commonly used datatypes when you want to store items by key.
HashMap should be only used when the objects we store as KEYS have implemented the method hashCode in such way that it give unique key for a given object.
Let's say we have an object USCitizen
name,
socialSecurityNumber
Map myMap = new HashMap();
HashMap
HashMap should be only used when the objects we store as KEYS have implemented the method hashCode in such way that it give unique key for a given object.
@Override public int hashCode() {
name,
socialSecurityNumber
Map myMap = new HashMap();
find similar posts:
Java
Java: RegEx: WebSpider
In this tutorial we will create a basis for a WebSpider program that fetches all links from the given Web page, checks which have extensions of interest and downloads these files.
The result of the app will be a folder with Google Earth map overlays:
The result of the app will be a folder with Google Earth map overlays:
/Users/uki/Desktop/KMZ
├── 1.kmz
├── 10.kmz
├── 11.kmz
├── 12.kmz
├── 13.kmz
├── 14.kmz
├── 15.kmz
├── 16.kmz
├── 17.kmz
├── 18.kmz
We will use basic java networking classes:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
and regular expressions:
ublic class RegExConstants {
/** * @param extensions * @return * ( -- start of main grouping * [^\s]+ -- must contains one, or many strings (but not white space) * ( -- start of extension grouping * \. -- existence of a dot, eg.: .kmz * (?i) -- NOT case sensitive for the next group * (kmz|kml) -- kmz OR kml strings * )$ -- should exist on the end * ) -- end of main grouping */ public static String fileExtensionPattern(String[] extensions) {
StringBuilder sb = new StringBuilder("");
if (extensions.length > 0) {
int n = 0;
for (String extension : extensions) {
if (n > 0) {
sb.append("|"); // append OR }
sb.append(extension);
}
}
String pattern = "([^\\s]+(\\.(?i)(" + sb.toString() + "))$)";
System.out.println("fileExtensionPattern: " + pattern);
return pattern;
}
public static final String anchorTagPattern = "<a *href=\"(.+?)</a>";
public static final String urlPattern = "(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
}
find similar posts:
Java,
Regular Expressions
Project Planning
"Planning is a good preparation for an inevitable change of direction that throws out any plans made." ~Uki
find similar posts:
quote
Java: running with Maven
Compiling with Maven
note:
- mvn clean install
- location of created jar
uki@ WebSocketClientServer $ mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building WebSocket-GlassFish 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
...
.to /Users/uki/.m2/repository/edu/clcillinois/cit137/WebSocket-GlassFish/1.0-SNAPSHOT/WebSocket-GlassFish-1.0-SNAPSHOT-jar-with-dependencies.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Using variables to store long values
uki@ ~ $ export WEBSOCKET_JAR=~/.m2/repository/edu/clcillinois/cit137/WebSocket-GlassFish/1.0-SNAPSHOT/WebSocket-GlassFish-1.0-SNAPSHOT-jar-with-dependencies.jaruki@ ~ $ echo $WEBSOCKET_JAR/Users/uki/.m2/repository/edu/clcillinois/cit137/WebSocket-GlassFish/1.0-SNAPSHOT/WebSocket-GlassFish-1.0-SNAPSHOT-jar-with-dependencies.jar
Starting SERVER
$ java -cp $WEBSOCKET_JAR edu.clcillinois.websocket.server.WebSocketServer -h localhost -p 8025
Setting homeName to: localhostStarting the server.Mar 03, 2015 3:56:54 PM org.glassfish.tyrus.server.ServerContainerFactory createINFO: Provider class loaded: org.glassfish.tyrus.container.grizzly.GrizzlyEngineMar 03, 2015 3:56:54 PM org.glassfish.grizzly.http.server.NetworkListener startINFO: Started listener bound to [0.0.0.0:8025]Mar 03, 2015 3:56:54 PM org.glassfish.grizzly.http.server.HttpServer startINFO: [HttpServer] Started.Mar 03, 2015 3:56:54 PM org.glassfish.tyrus.server.Server startINFO: WebSocket Registered apps: URLs all start with ws://localhost:8025Mar 03, 2015 3:56:54 PM org.glassfish.tyrus.server.Server startINFO: WebSocket server started.
Type 'q' and Enter to stop server:
Starting Client(s)
uki@ CNH_PROD $ java -cp $WEBSOCKET_JAR edu.clcillinois.websocket.client.WebSocketClient -h localhost -p 8025
[DEBUG] 2015-03-03 16:02:44,354 edu.clcillinois.websocket.client.WebSocketClient main - Starting WebSockets clientSetting homeName to: localhost
Monitoring Java processes and Killing them
$ ps | grep java
30227 ttys001 0:00.00 grep java
30203 ttys002 0:01.37 /usr/bin/java -cp ~/.m2/repository/edu/clcillinois/cit137/xyz.jar edu.clcillinois.websocket.server.WebSocketServer -h localhost -p 8025
$ kill -9 30203 uki@ SimpleWebSocketServer $ ps | grep java30230 ttys001 0:00.00 grep java
Maven pom.xml example
note:
- group id
- artifact id
- version
- start-class
note:
- group id
- artifact id
- version
Maven build
note:
- plugins
- Java version 1.6, 1.7 or 1.8
- TODO change to Java 1.6 and observer what fails
- jar with dependencies
Subscribe to:
Posts (Atom)
My favorite quotations..
“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.” by Robert A. Heinlein
"We are but habits and memories we chose to carry along." ~ Uki D. Lucas
Recommended pages
Popular Recent Articles
-
I live in a very rugged Pacific Northwest (PNW). The terrain consists of sharp rocks in summer and wet or snow-covered sharp rocks in winte...
-
On my blog, I have noticed a very unsettling statistic , which prompted a fascinating question about AI and the future of blogs and maybe ...
-
All images and videos were taken by Uki, the author. At this point, I could only export raw movie footage from today's dive. In the fut...
-
After four meetings in a row, I had the need to get out of the office and go to Redmond French Cafe . The “Croque Madame” plate is not the b...
-
My friends frequently ask me about how I manage my time. The answer boils down to habits. Before discussing habits, I would like to talk abo...
-
I have been wearing wool products for a very long time now. The highlanders of the region where I was born were wearing wool in winter and ...
-
See the photo below. When I was posting my previous article on X.co (Twitter) I was literally following a post of Elon Musk. I thought it wa...
-
You know when you live in the right town when, on a single walk, you have to cross under a fallen tree and chase a coyote out of your path. ...
-
This slingshot shot took a lot of practice , but she had fun and became very consistent . Buy it on Amazon: Item Name Author Producer Amaz...
-
Only 9 years ago - 500,000 downloads - 2303 reviews Not too shabby. Today - couldn't log in Please SUBSCRIBE: https://ukidlucas.beehiiv...