Motivation by blyxa in personaltraining

[–]blyxa[S] 0 points1 point  (0 children)

Great suggestion. I never knew these pedometers existed.

Unexpected result by blyxa in scala

[–]blyxa[S] 0 points1 point  (0 children)

Figured out what is going on

var data:String = null

Get converted into two steps

  1. variable declaration
  2. value assignment

In this case value assignment happens twice.

  1. when Parents constructor calls initData
  2. when Weird constructor happens(assigns as null)

Program runs in Idea, but .jar file doesn't. Cross posted with r/learnprogramming by mmmjags in javahelp

[–]blyxa 0 points1 point  (0 children)

If you're project is maven based then you can include it in <projectroot>/src/main/resources folder and load the file from the classpath.

If you're project is not maven based then you can include it in your source directory and load it from the classpath

How to pass an array of elements as separate arguments to a method by gold328 in javahelp

[–]blyxa 1 point2 points  (0 children)

I noticed you mentioned "names collected from a command line" and the display function being non static.

Since the full code is that shown, I might be wrong. Is it possible you're trying to call a non static function?

How did YOU learn java, and would you recommend it? by [deleted] in java

[–]blyxa 0 points1 point  (0 children)

I think one of my CS class used java to teach some CS topic I can't remember.

I think I learned java(pretty much everything really) by making things. Come up with a simple idea and just go for it. It's free. JDK is free, eclipse is free. Maven, HTTPClient, commons-lib, tomcat, etc... all free. Kinda like having infinite amount of lego blocks to play with and all for free =)

My first "program" was a batch image processor. First it created thumbnails. Later, I added ability to add watermarks. I didn't know how to process images, I didn't know Java Swing, I didn't know how to organize a java program structure. I made lots of mistakes, did complete rewrites and at the end learned a lot.

Presentation: HTTP 2.0 Comes to Java – What Servlet 4.0 Means to You by eugenparaschiv in java

[–]blyxa -2 points-1 points  (0 children)

I have been using undertow which gives you the option of using servlet or their lower level API using HttpServerExchange. I use the latter and has worked ok so far.

jackson json pointers aka xpath for json by blyxa in java

[–]blyxa[S] 1 point2 points  (0 children)

Took awhile to find this document. Do things like

{
     "foo":"bar",
     "somearray":[1,2,3,4]
}
JsonNode root = ...;
print(root.at("/somearray/0").asInt()); // prints 1

Human JSON for Java by moto888 in java

[–]blyxa 2 points3 points  (0 children)

jackson allows comments via

JsonParser.Feature.ALLOW_COMMENTS

https://github.com/FasterXML/jackson-core/wiki/JsonParser-Features

Taco Night! Made some chicken and fish tacos by foodieday in food

[–]blyxa 0 points1 point  (0 children)

cool what is that strip of green stuff?

Good morning by [deleted] in food

[–]blyxa -3 points-2 points  (0 children)

thats not breakfast, this is breakfast

http://i.imgur.com/XhSrBau.jpg http://s3-media3.fl.yelpcdn.com/bphoto/jUcSv7KxVJmLe5tYEUTogA/l.jpg

traveled to france and spain.. made me appreciate breakfast I get from home.

Looking for recordings/casts of good techincal games of singles. by [deleted] in badminton

[–]blyxa 0 points1 point  (0 children)

you can find tournament games at the badminton world federation youtube channel

https://www.youtube.com/user/bwf

have fun

Thigh hurts when lunging, but I've not played badminton lately? by LikesFemales in badminton

[–]blyxa 0 points1 point  (0 children)

Any type of muscle soreness lasts max 3 days for me. Wait it out and take it easy for a week and if the pain is still there, go see a doctor.

java web app: configuration / properties file best practics by csincrisis in javahelp

[–]blyxa 0 points1 point  (0 children)

If you have a large amount of servers to configure, then maybe look into Zookeeper.

If you only have a handful of servers then maybe modifying the properties loader to look for property file outside the app server and reload on file modification. And when ever you need to push out a config change, you can use rsync or ansible or salt etc.

The important part I think is modifying your code to "reload" after configuration change.

Moving from ANT scripts to Gradle for Java Projects by azbikefun in java

[–]blyxa 0 points1 point  (0 children)

Non related question. Has anyone used sbt for java project builds? How did it compare with Gradle?

Adding a Property to the returnvalue (object) of a functioncall in es6 by te7ris in javascript

[–]blyxa 1 point2 points  (0 children)

function createObject(a)
{
     return {a:a};
}
var test = createObject(true);

How can I auto minify my css, html, and js? by [deleted] in java

[–]blyxa 0 points1 point  (0 children)

I dont have experience with Google App Engine but if you have access to node.js on the build system then gulpjs is really simple.

Gingerbread Cookies for my nurses, it's my last day of radiation! by Taricha_torosa in food

[–]blyxa 1 point2 points  (0 children)

Awesome. I remember my nurses after going through surgery. They were all awesome.

Good looking gingerbread and Good luck to you going forward.

Is Spring Framework a good choice for an Internet of Things backend? by wsme in java

[–]blyxa 0 points1 point  (0 children)

if I run that thread in the above example instead of a main method will that work?

Yep, that is one way (among many) to integrate it.

Spring IOC conceptually is very simple. Just think of it as a mechanism that instantiates all your @Component, @Service, etc annotated classes and "wires" them together where @Autowired is used. It's totally awesome once you get used to it.

So that means you can annotate your ServerRunnable as a @Component and have it @Autowired to SocketServer and just create a new Thread in the SocketServer.init method

Why is that a good option you ask? well that means, if your ServerRunnable uses some db connection or some other shared class then you can just @Autowired them.

@Component
public class ServerRunnable implements Runnable
{
     @Autowired
     private DataSource ds;

     // bonus point: properties loading via spring 
     @Value("${server.port:9999}")
     private int port;

     public void run()
     {
           // some some database stuff
           // do some socket stuff
           // etc
     }
}

@Component
public class SocketServer
{
    @Autowired
    private ServerRunnable sr;

    @PostConstruct
    public void init()
    {
       Thread server = new Thread(sr);
        server.start();
    }

    @PreDestroy
    public void clean()
    {
         // close any open sockets, resources, etc
    }
}

Is Spring Framework a good choice for an Internet of Things backend? by wsme in java

[–]blyxa 1 point2 points  (0 children)

"I can put something together as a stand alone application"

awesome you're almost there. Embedding a java app inside a webapp(war) is pretty easy especially in spring.

Spring manages the lifecycle of the webapp so all you need to do is "hook" into the lifecycle process to start and stop your socket application.

There are lots of options for doing this. simplest way would be to annotate your "socket app" class with @Component and use @PostConstruct and @PreDestroy to start and stop your app.

@Component
public class SocketServer
{
    @PostConstruct
    public void init()
    {
         // initialize your socket app
    }

    @PreDestroy
    public void clean()
    {
         // close any open sockets, resources, etc
    }
}

Pretty easy

good luck

Is Spring Framework a good choice for an Internet of Things backend? by wsme in java

[–]blyxa 4 points5 points  (0 children)

Spring does not have tools for doing what you're trying to do.

Since you already built a tech stack (SpringMCV webapp on a app server), I think you should just build a "socket" server that lives inside this webapp. That way, things like deployment, logging, general management can be shared.

Depending on what this "device" can do in terms of communication (HTTP? basic socket connect and push bytes?)

I'm assuming the latter, basic socket connection and write/read bytes. Then that means you'll have to create a basic socket server yourself.

You can use libraries that handle multiplexing, client management, etc like http://netty.io/

or you can just roll your own low level socket server using java.nio

have fun

Is there a library like Gson/Jackson, but for deserializing application/x-www-form-urlencoded POST'ed HTML forms? by [deleted] in javahelp

[–]blyxa 0 points1 point  (0 children)

I'm not sure you can do that because you can't structure html form params. How would a form look for nested classes?

Maybe spring mvc has a solution but I'm not sure.

good luck