« first day (1495 days earlier)      last day (3439 days later) » 
02:00 - 12:0012:00 - 23:00

2:13 AM
hi all
can any one answer this
0
Q: how to encrypt response data in filter

Remboi am trying encrypt response data before it written into the HttpServletResponse, so i have implemented custom response wrapper and output streram and a filter classes, Problem is i need to encrypt whole response data once, but there is no write(String content) method, but there are three method...

anyone know how to use CipherOutputStream class with HttpServletResponseWrapper??
 
 
2 hours later…
4:47 AM
I am trying to think of a name for a class that is essentially a wrapper around java.util.function.Predicate but it is capable of printing itself as a human-readable string. Best so far I've come up with is PrintablePredicate but I'm thinking that might be misleading as Print* usually has a specific connotation
 
 
1 hour later…
5:56 AM
The name is OK IMHO
 
6:47 AM
Okay, in my honest opinion
 
7:08 AM
@brcolow how about SelfDescriptivePredicate or HumanReadablePredicate?
 
7:30 AM
YES MY INTERNET IS BACK!!!
 
 
1 hour later…
9:00 AM
@Gemtastic Welcome back to the living world
 
Thank you~ let's hope iot stays this way now
 
Yaaaay I got a bronze tag badge on meta...
well meta.cr, but alas ;)
 
Gratz
 
/me bows
 
If only static methods can be abstract...
 
9:15 AM
@Unihedron you're demanding the impossible..
 
I know the use case is terrible, but it would allow me to sacrifice that bit of robustness for readability and easier to write.
 
9:26 AM
Huh, it seems that inner classes of interfaces are static by default.
So if I want instanced inner classes in an abstract object, I have to use an abstract class.
 
I'm not sure whether this is true..
but interfaces on sourcelevel < 8 only have public abstract or static members...
 
I'm using Java 8.
^ Yeah, abstract class does what I want.
 
that is an enum right there...
 
As you can see on the second pic, FactoryMeta.MessageType isn't syntax error, so it's automatically static.
Yes it is.
 
why is it not an enum then??
 
9:30 AM
Because I'm testing whether if it's static.
Or encapsulation. Choose either.
Actually, I remembered why I set up a enum-like object like this, and now I'm regretting this design.
lol
 
@Unihedron I kinda anticipated this...
 
Hi guys!
 
This is waaay to much of a hack to not be regretted ;)
Hiya @iceone23
 
Hey there @iceone23!
@Vogel612 Well, now I have a better plan. You might like it.
 
If I hadn't got a deadline coming up for friday, I'd probably stick around ;)
 
9:40 AM
please help me with javax.media.jai.InterpolationBilinear
 
but that said... ~timeout
 
No worries :)
 
1 sec
 
Seeya!
 
You can play with Junior meanwhile ;)
 
9:40 AM
##eval:"hello world"
 
~opens 2nd eclipse instance
 
:D
 
He'll spawn in the sandbox..
 
I feel like I need a practical example of how to use threads :/
Does someone have that for a JavaFX application?
 
~JavaBot, at your service
@Gemtastic there is no "practical" example.. just unpractical ones.
 
9:42 AM
lol, bots can get expensive sometimes
 
@Vogel612 Well, an example from a working application then :P
 
meh that's mostly because I have 2 eclipse instances, sourcetree, double word, h2 database and jboss running simultaneously
 
i need to do interpolation on a 2x2 grid with InterpolationBilinear.interpolate()
 
on top of chrome and some other background stuff..
 
here's method
 
9:44 AM
@Gemtastic Junior got some multithreading inside... not running against Thread though..
 
what for I need xfrac, yfrac ?
/**
* Performs interpolation on a 2x2 grid of integral samples.
*
* @param s00 the central sample.
* @param s01 the sample to the right of the central sample.
* @param s10 the sample below the central sample.
* @param s11 the sample below and to the right of the central sample.
* @param xfrac the X subsample position, multiplied by 2^(subsampleBits).
* @param yfrac the Y subsample position, multiplied by 2^(subsampleBits).
* @return the interpolated value as an int.
*/
public final int interpolate(int s00, int s01,
 
@Vogel612 is he implementing runnable instead?
 
s00, s01, s10, s11 - that's my values
and what is xfrac, yfrac ?
 
@Gemtastic naah he's got some ScheduledExecutorServices lying around..
Why would he need to implement Runnable and where would you do that..
keep in mind Junior needs a main-method as entry-point
and doesn't start automagically like JavaFX...
 
I have no idea, I thought it was pretty obvious that I don't know multi threading yet :P
 
9:48 AM
Yea it is..
 
Executors are overpowered, especially ones that does the caching of threads in the pools for you for free.
 
true and completely starworthy
mental note to self: even Uni can be a troll at times.
 
I didn't know what an executor was either :/
I hate not knowing stuff :(
 
@Gemtastic you could try your luck with Junior's Program.java
there the "magic" part happens..
 
As a quick FYI, thread pools are objects which keeps tracks of threads so you can call them from the pool instead of having to keep track yourself. Executors are what allows you to call runnables. Different executors does different stuff, some even constructs threads as needed, some runs them synchronously, some runs them asynchronously.
 
9:51 AM
not that there's any magic involved.
 
@Vogel612 I'll look it up
 
Cool, you can use dollar signs in field names and class names!
 
10:36 AM
Yo
I have an Apache CLI "Hello World" example compiled and packaged with Maven
How the hell do I run it now? XD
cough @Unihedron
 
Which IDE are you using, or are you trying to build it with the maven assembly?
 
I'm using Intellij as a dev IDE, but I compile with mvn clean install (console)
 
Hmm, I think Apache CLI won't be present unless you specify compiling a fat jar with the dependencies, unless you download the Apache CLI's jar and put it in your execution directory.
 
It's specified as a dependency in the POM file
 
But it should be java -jar yourjarfilename.jar
 
10:40 AM
<dependency>
    <groupId>commons-cli</groupId>
    <artifactId>commons-cli</artifactId>
    <version>1.2</version>
</dependency>
My jar is in the target subdir, correct?
> no main manifest attribute, in target/clientProperties-0.1-SNAPSHOT.jar
Is the error I'm getting when running that
Dammit, why couldn't they let me build it with NodeJS and be done with it? XD
 
yes it should be in the target subdir
The error says, you don't have a Main-Class specified..
I assume the maven-prototype already contains a main-class?
 
Haha, node.js..
 
because then you'll just have to tell maven about the main-class it should put into the manifest:
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<configuration>
					<archive>
						<manifest>
							<mainClass>org.apache.cli.example.Main</mainClass>
						</manifest>
					</archive>
                              </plugin>
 
@Vogel612 I'm not sure what maven-prototype is.
 
@SecondRikudo the "Hello World" example
 
10:47 AM
package com.taboola.clientproperties;

public class ClientProperties {
    public static void main(String[] args) {
        new Cli(args).parse();
    }
}
This?
 
exactly this...
 
So yeah
 
have the mainClass attribute point to this class, repack and you should be good to go..
 
<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.taboola.clientproperties.ClientProperties</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>
Right?
 
at the very least ;)
 
10:49 AM
Same error :|
build success, still can't run
 
maybe you'll have to add a descriptor ref to trigger packing..
 
I thought you have to trigger assembly.
So run like mvn clean install assembly.
 
</archive>
					<descriptorRefs>
						<descriptorRef>what-you-name-it</descriptorRef>
					</descriptorRefs>
				</configuration>
 
@Vogel612 What does that do?
@Unihedron Tells me I need a specific goal
 
now if I knew that...
 
10:51 AM
@SecondRikudo Then, assembly:single instead
 
but we got it in the javabot config like this and running mvn clean compile assembly:single works fine
or at least it did last time I checked..
 
Yeah, they're using install though, which does most of the things better.
^ That's the build config for JChatEx as of yet.
 
Hallelujah! That works.
So now to distribute that as a command line tool (end goal is to have command whatever and not java -jar ............. whatever
 
ermph.. cheat your way around it with a batch to do the java -jar ...
 
I need to distribute that jar file, and have an executable script that runs java -jar ........ $0 in the /usr/local/bin directory?
 
10:56 AM
put that into a folder included in PATH and you're fine
 
Or is there a less hacky way to do it?
 
Remember to add PAUSE so it doesn't kill itself.
Have like RUN.bat stuff.
 
/usr/local/bin is probably not the right place to put stuff..
 
@Vogel612 Why not?
 
also you'd have to put it into a .sh for *NIX.
because everything's there...
 
10:57 AM
@Vogel612 Your point?
 
and getting it out again (in case that's considered) might be a mess
 
@ECHO OFF
SET BINDIR=%~dp0
CD /D "%BINDIR%
java -Xmx1024M -jar myjar.jar
PAUSE
 
with all the stuff in there you might get name-collisions..
 
@Unihedron Linux
 
There you go, typical RUN.bat's
Yeah, for *nix you gotta write something else. I don't have one handy.
 
10:58 AM
@Vogel612 I won't, it's a very specialized name, but okay
Now another question, now that I have it running
Is it possible for Apachi CLI to have a CLI tool similar to how git does it?
 
well then your .sh reduces to: java -jar .... &
 
Like instead of cli -flags, cli command -flags?
 
@SecondRikudo git is cheating..
 
Cheating how?
 
there is a git.exe that in turn takes the command as parameter.
and that git.exe calls the commands...
 
11:00 AM
:O
 
Again, linux.
But I didn't know that :o
 
s/exe/sh/gi
 
Me neither
 
the principle is the same ;)
 
Shocking revelation: How git handles commands
 
11:01 AM
Bah, git's executable is binary, will have to see source later
 
That and I don't think it uses CLI.
 
@Unihedron It doesn't even use Java
 
:O
 
11:02 AM
that's my git installation's /bin-folder
this folder is added to the path, but I dare you call diff directly ;)
 
Aha, so different "classes", with different handling of parameters, and one main executable that calls whichever via delegation.
 
That's so hacky.
 
something along these lines..
 
Very hacky.
 
naah it's rather standard
 
11:04 AM
What if someone replaces a .exe with their own? Won't it be like totally insecure?
 
since the commands are self-governing you make it modularizable..
@Unihedron I double dare you to do that..
sure you could, but whom would you want to mess with?
also you can always check signatures and hashes
 
Teacher of the programming class.
@Vogel612 OH. :(
 
but there's no real benefit in replacing a git executable
once you can do that with a malicious intent you can do other waaaay more interesting stuff
 
LOL, true that.
 
11:26 AM
sigh
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project clientProperties: Compilation failure
[ERROR] /home/dor/client-properties/src/main/java/com/taboola/clientproperties/Commands.java:[6,7] enums are not supported in -source 1.3
[ERROR] (use -source 5 or higher to enable enums)
WTH maven?!
How do I specify a source version? (if that even makes sense)
 
I hate Java
 
don't say that...
you hate maven...
that's something different.
 
I have Java and Maven
 
if you hate maven you might be interested in looking into gradle
 
11:31 AM
@SecondRikudo Maven sucks.
Well to some extend Java sucks as well, but PHP sucks even more.
 
I hate it that I need a 20 second build step for a 1 line change.
That's not maven's fault, that's Java.
 
Use maven-ant-plugin. You can change code live while running a debugger.
 
For a freaking HelloWorld application, no less.
 
@SecondRikudo ... compiling is slower in setting up, but often much faster in execution
you're just trading off waiting times..
 
// In JavaScript, I can do something like this
var command = commands[args[0]];
command(args);
Can I do something like this with Java?
 
11:33 AM
javascript is a hack...
 
i.e. instantiate an object that corresponds to the command, without a switch case?
 
this is a mess, but yes you can..
depending on your setup you'd have to mess with "Reflection" though..
 
Yeah, no thanks :X
 
What you want here is a Map<String, Class<?>> commands
 
@Vogel612 That sounds better
 
11:35 AM
Yay mappers!
 
then you can commands.get(args[0]).getDeclaredConstructors()[0].invoke(args);
which is a hack anyways.
Also it's probably a given you should hide that carp behind a Facade and return the instance as ... implements Command
then you can have your map run Map<String, Class<? extends Command>
or you do it differently and make Commands reentrant
then you can just store instances and don't have the mess with Constructor invoking..
for more information, see my "implementation" of something similar, that got ripped apart on CR
11
Q: More German overengineering™ - Class mappings and factories

Vogel612Goals: So the plan was simple: Provide a factory to instantiate implementations of a certain interface (ModelConverter<T>), depending on what model-class you want to convert. The approach is relatively straightforward: statically map model-classes to ModelConverter implementations use that ma...

 
SGHAEUHTEOUTJEILJSTHRYH
OMG the horrors are coming back
 
> He who is called the sleeping horror
 
FFS I'll just go with the switch/case
Before that one last attempt
commands = new HashMap<String, Class<? extends Command>>();
How do I add a class to that?
class.forName() gives off the wrong type, couldn't find a suitable new Class constructor
 
commands.put("commandname", ClassName.class);
 
11:49 AM
of course... xD
@Vogel612 I don't have the invoke method, I'm guessing it's not available in Java 6?
 
umm.. gimme a sec
 
commands.get(args[0]).getDeclaredConstructors()[0].newInstance(args);
Like this perhaps?
 
yes...
like this
invoke() was for Methods
you'll get a bunch of exceptions thrown in your face btw..
 
} catch (Exception e) {
    System.out.println("ERROR! " + e.getMessage());
}
FTW
 
IllegalAccessException and all the crap coming with reflection..
yea, Java6 is problematic with that..
I'd prefer multi-catch over this any time though.
 
11:55 AM
@Vogel612 I do have multicatch
Just not for this reflection
 
Pokemon exception handling?
 
At least for now
 
Gotta catch em all!
 
@Unihedron you really don't have to explain the joke..
usually that's killing it..
 
-_-
 
11:58 AM
public static void main(String[] args) {
    try {
        mapCommands();
        Object cmdObj = commands.get(args[0]).getDeclaredConstructors()[0].newInstance();
        Command cmd = (Command) cmdObj;
        cmd.parse(args);
    } catch (ArrayIndexOutOfBoundsException e) {
        help(args);
    } catch (ClassNotFoundException e) {
        help(args, true);
    } catch (NullPointerException e) {
        help(args, true);
    } catch (Exception e) {
        System.out.println("ERROR! " + e.getClass().toString() + " " + e.getMessage());
Pretty
 
Combine the ClassNotFoundException and NPE?
catch (ClassNotFoundException | NullPointerException e) {
 
Didn't know it was possible, thanks
 
that's multi-catching at it's finest.
 
Not supported in 6 though
 
one of the things I would never want to give up after having them once.
 
02:00 - 12:0012:00 - 23:00

« first day (1495 days earlier)      last day (3439 days later) »