« first day (562 days earlier)      last day (3457 days later) » 

12:00 AM
Until there I have used wxPython, PyQt/PySide and a little bit of Qt, AWT and Swing at school.
My favourite was PySide. Had there been properties instead of getters and setters, it would have been even better :)
 
@Jamal Do what I normally do: Read some working code that uses the functionality you want. Understand how the code works. Adapt the code to what you need.
Now if there only was a website with a whole bunch of working code, preferably also tagged in a good way so that it was easy to find questions related to oh, there we go!
@Jamal here's some questions you might find useful: codereview.stackexchange.com/search?q=[swing]+boxlayout
motherPanel.setLayout(new BoxLayout(motherPanel, BoxLayout.Y_AXIS);
that's the one
 
Hey guys!
 
Hey :)
 
Hey @AlexL
@Jamal Did my suggestion help? Bumping into any problems?
 
12:21 AM
I may try to figure it out later. This is all still too complicated. I'm currently working on a close button.
 
@Jamal close button = a button to close the window (frame)? frame.dispose(); is your friend (if I remember correctly, that is)
and you can use button.addActionListener (I think) to add that listener
 
I have it working, but now I'm trying to display it at the bottom of the window. It's not even showing up with everything else I have.
 
ah, the pain of layouting...
If you're using Eclipse or Netbeans, the IDE can help you layout your frame
unless you want to do it by hand of course.
 
12:57 AM
It's 2 a.m. and I am eventually gettin tired. See you later :)
 
It's 2 a.m. and I am not tired -.-
3
 
It's 8pm.... I am tired.
 
I have a bunch of code, but very little displayed in my frame. I guess I'm making progress.
 
1:38 AM
It's 2:40 a.m. and I am tired.
2
 
Good, go to sleep ;-)
 
2:35 AM
0
Q: Feedback on Python Conway's Game of Life without objects

CynI was wondering if anyone could provide some feedback on my solution to Conway's game of life. I tried to solve it without using objects. It returns a dictionary of living points on a grid and points that were alive at some point. I'm wondering if there is a better way to check the surrounding po...

 
 
1 hour later…
3:53 AM
0
Q: Handling WinAPI return values and errors without code being verbose

speedballI'm trying to come up with a way to streamline a bunch of WinAPI calls that return true or false without having a bunch of if statements while still checking for errors, I'm using C# but this could apply to C++ and other languages as well. on MSDN, the conventional way of calling WinAPI function...

0
Q: Implement a Clock in Javascript

gitarchieHow idiomatic is my code? var Clock = function(hour, minute) { this.hour = hour || 0; this.minute = minute || 0; this.plus = function(minutes) { computed_minutes = this.minute + minutes if (computed_minutes > 60) { this.minute = computed_minutes % 60 this.hour += comp...

 
 
1 hour later…
5:15 AM
0
Q: Splitting coma-separated values in C

NitI stumbled upon a question on SO asking how to split a coma-separated string into individual values. Since it's been a while since I've had any good reason to write C I'd like to ask for some feedback. #include <stdio.h> #include <string.h> int main (int argc, const char * argv[]) { const c...

 
5:47 AM
Monking @all
 
6:41 AM
Monking
 
6:55 AM
monking @all
 
7:47 AM
hey
 
Monking @all
 
ho ho ho
 
8:06 AM
0
Q: Correct usage of Repository Factory Pattern?

Ivan-Mark DebonoMy repository pattern is setup like this: public interface IRepository<T> where T : class {} public abstract class Repository<C, T> : IRepository<T> where C : DbContext, IBaseContext where T : class, IEntity {} public interface ICustomerRepository : IRepository<Customer> {//specifi...

 
8:20 AM
-1
Q: method to receive wholesale cost and markup % as arguments and return retail price c#

DrakkhulI typed out this code for homework and it works. However, the method part is incorrect. The method should receive 2 values (wholesale price and markup percentage) from the form as arguments and return the retail price. Here is what I have so far, and I am just wondering what I need to move where ...

 
8:49 AM
0
Q: Java Karp-Rabin String Matching, Part 2

tsleysonPart 1 is here. I wrote a Java implementation of the Karp-Rabin seminumerical string matching algorithm. I incorporated the suggestions of @fge and @maaartinus from the other question into my new code: the match method now returns a boolean so you can write if (KarpRabin.match(pattern, text)), an...

 
9:39 AM
0
Q: Why not getting the address of structure pointer?

quidstoneIn this code at //1 i am getting the intended result. Why? #include <stdio.h> #include <stdlib.h> int count=0; typedef struct node{ int number; struct node *next; struct node *previous; } node; node* create (int n){ node *nd = malloc(sizeof(node)); nd->number = n; nd->...

 
10:09 AM
0
Q: Is there a better way to write this javascript replace

Kristian RaftesethI have some code to translate some color names, and this is what i did quick and dirty. But I'm guessing there might be some function to replace arrays with arrays maybe, like in php? Where you can have str_replace($array_of_colors, $replace_array_of_colors, $colors); var color = colors[...

 
10:19 AM
omg I answered a javascript question...
 
@Vogel612 need a doctor ?
 
@Heslacher maybe...
 
@Vogel612 y did u do dis? ç_ç
 
@Morwenn because it was so obvious!!!
I mean I had to scrape the mdn docs for Array.forEach(), but then I was .. finished..
 
10:37 AM
0
Q: How can I apply the DRY principle in this code segment?

furorPlease refer to my codes below. I have 2 buttons click event handler. The codes are working well, but I want to apply the DRY principle. How should I rewrite the following code in the button_click event handler so that I don't have to repeat in all my 10 buttons? private void CreateWindows(User...

 
@CaptainObvious Basic Class-Naming conventions anyone?
 
0
Q: Is there any better way to right that code in C?

Nikos KLonIs there a more stable way to write that code? Do I have take all the restrictions I could? The following code reads a txt file that contain only numbers. Read the first one, create a dynamic array and put the other numbers on it, made some procidures and in the end write a file with the int to...

 
10:54 AM
toying around with java 8...
Can I put multiple functions in a lambda
Because my lambda's are not small inlines anymore
@Override
public FutureTask<List<StreamInfo>> requestGetStreams()
{
    StreamComponentImpl component = this;
    FutureTask<List<StreamInfo>> future = new FutureTask<>(() ->
    {
        Future<JSONObject> responseTask = component.sendRequest("streamGetInfo.json", null);
        do
        {
            try
            {
                JSONObject result = responseTask.get();
                if (result.has("response"))
                {
                    JSONObject response = result.getJSONObject("response");
I'd like to extract the body of "response.has("streams")" if I can
 
waaait...
@Pimgd you sure can put multiple statements into a lambda.
I'd suggest you extract that into a method and put that as a consumer though..
 
It's try + catch + bad error checking + a for loop + bad code style
that's why it's so big
 
What are you doing there anyways??
 
    FutureTask<List<StreamInfo>> future = new FutureTask<>(() ->
    {
        Future<JSONObject> responseTask = component.sendRequest("streamGetInfo.json", null);
        do
        {
            try
            {
                JSONObject result = responseTask.get();
                if (!result.has("response") || !result.getJSONObject("response").has("streams"))
                {
                    System.out.println(result);
                    return null;
                }
                //extract to method
I'm converting a json response that kinda looks like this
{"streams":[{"Expected Bitrate":3,"Stream encoding":2,"Expected Framerate":4,"Stream url":"bogus","Video Height":5,"Video Width":6,"Stream index":1},{"Expected Bitrate":2,"Stream encoding":1,"Expected Framerate":3,"Stream url":"bogus","Video Height":4,"Video Width":5,"Stream index":0}]}
Into a bunch of objects
 
11:10 AM
hmm... it looks like you could strongly benefit of something like a JSON library...
 
already doing that
Any JSON library still needs me to tell which keys go where
so I wouldn't gain anything from switching to whatever library you have in mind
because the keys don't match member variables of objects.
 
    Gson gson = new Gson();
    JSONChatEvents events = gson.fromJson(rString, JSONChatEvents.class);
that's... the complete JSON->Object transformation in the JavaBot on my github
 
... it will fail since it can't map "Video Width" to private int width
 
then your Objects are misfit for proper deserialization..
 
... okay...
 
11:13 AM
anyways you could benefit of .filter(Predicate).findFirst().ifPresent(Consumer)
 
suppose if I did rename the variables and so
How would I convert "Stream encoding":2
 
Use an underscore
 
to StreamEncoding.STREAMENC_MJPEG
 
public class JSONChatEvent {

    private int    event_type;

    private long   time_stamp;
with "event type", "time stamp" as keys ;)
 
hmmmmh
so I create a normal object, a json object, and have toJSONObject and toNormalObject on them respectively?
Don't I still end up writing the conversions then?
hmm, I'll have to take a good look at what I'm communicating, I guess
 
11:19 AM
Why not work directly on the JSON object?
 
0
Q: Including a page specified in query string. Coult be susceptible to any security attacks like remote file inclusion?

HelpNeederThis is how I include a page depending by name. Example url http://www.page.com/index.php?page=admin where admin.inc.php lays inside /modules/ directory. The files are located in a directory I specified. The included files should not render when connected to them directly. So, are there ANY ...

 
because it can also be a big fat error
Because that part of the device is turned off
hmhm then you'd have null anyway
Pick a different reason, Pim
Because I want my variables to auto complete...
Because I want type safety in the rest of my application
Passing JSON objects around the rest of the application is bound to lead to a lot of discomfort
 
Why does a JSONObject not provide typesafety?
You don't have to name it JSONStreams.
 
Because I can give you a JSONObject that contains a wifi network's metadata, instead of a video stream's metadata
And then I have to check and recheck that stuff exists
 
ohhhhhhhh..
soo.. you want to put your JSON into different Types depending on what type they are?
 
11:24 AM
typedef enum application_requestID {
	/*auth - 1xx*/
	/*Requests the preferred authentication type from the camera.*/
	AUTH_TYPE = 100,

	/*Authenticates with the camera using the preferred authentication type. AUTH_LOGIN with AUTHTYPE AUTHTYPE_NONE will intercept the request and throw an error to the client.*/
	AUTH_LOGIN = 101,

	/*move - 2xx*/
	/*Requests the movetype of the camera.*/
	MOVE_TYPE = 200,

	/*A command for relative movement. Only for MOVETYPE_RELATIVE cameras.*/
	MOVE_TO = 201,
 
You might want to consider a static fromJSON(String json) method then...
 
Each of those = 1x JSON response
and there will be even more
 
... You misunderstood.
for every kind of JSON you get, you have to provide a dedicated class to parse it to.
 
yeah
well no
Only the big ones
MOTIONDETECTION_SUPPORTED = 900,

	/*Retrieves the status of infrared.*/
	MOTIONDETECTION_GET_STATUS = 901,
thats a bool and a enum respectively
no need for a whole object there
there's plenty more like that
 
0
Q: Binary Index tree optimization

aksamI have written code for binary index tree.My problem is there are many functions based on the binary index tree the function stores the sum of element within a given range of binary index tree and my task is to compute the sum of all the functions with provide range.Below example will clarify my...

 
11:27 AM
so where's the problem? you need to make your typesafety yourself..
 
it's things like stream metadata and wifi scans and recordings and maybe IP settings that'll take the big space and require separate objects
Yeah, but I can isolate the typesafety in the communicating component
I am building a communications library
To be used in applications
 
hm... you're parsing stuff to certain types manually..
you can drop the "manually" part by providing the types to a library.
 
yeah but I'm basically using JSON to convert this...
typedef struct {
	char ssid[32];
	wifi_encryptionType encryption;
	wifi_mode mode;
} WifiNetwork;

typedef struct {
	WifiNetwork base;
	uint8_t signalStrength;//In percentage, 0-100
} ScannedWifiNetwork;
to a Java object
There's 2 enums in there again
for streams it's this one
typedef struct {
	/*The internal index the camera assigns to the stream.*/
	uint8_t streamIndex;
	/*malloc pointer to char array*/
	char* stream_url;
	streaming_encoding encoding;
	/*In pixels*/
	unsigned int height;
	/*In pixels*/
	unsigned int width;
	uint8_t expectedFramerate;

	/*In kibibit (Ki) per second. Used by apps to check if their network speed will support video playback.*/
	unsigned int expectedBitrate;
} stream_info;
 
@Pimgd and what exactly is the problem with that?
 
I have these enums I want to use. I imagine the library can't handle the enums
Thus I have to do it manually.
 
11:31 AM
it's just another Type.. If you specify the Type you provide to GSON correctly the parsing to the "subtypes" itself.
I don't know about enums, but I figure Gson can handle them....
 
... and at that point, am I not simply providing key and type like I'm doing right now?
jsonObject.getInt("Stream index")
I get that it could be useful, but I only have 1 simple object
The rest is either single value, no value or complex with enums or values requiring further conversion
 
@Pimgd that's done internally..
 
yeah but
JSONObject element = streams.getJSONObject(i);
                            byte streamIndex = (byte) element.getInt("Stream index");
                            String url = element.getString("Stream url");
                            StreamEncoding encoding = StreamEncoding.fromInt(element.getInt("Stream encoding"));
Some of the values are simple, some are complex
 
all you do is Gson parser = new Gson(); Result result = parser.fromJson(response, Result.class); and you're done
 
How do I pass the "subtypes", as you say?
 
11:34 AM
your Result is a type.
 
I just see myself getting back the object that has a int encoding
I don't want int encoding, I want StreamEncoding encoding
 
typedef Result {
    byte Stream_index;
    String Stream_url;
    StreamEncoding Stream_encoding;
}
and Gson does the rest.
 
...
dfkckdfad
 
we're missing each other...
 
fucking wireless keyboard always losing connection
 
11:37 AM
lel
 
Okay, does Gson support non-sequential enums?
typedef enum wifi_encryptionType {
	/*No encryption - an open network.*/
	WIFIENCTYPE_NONE = 1,

	/*WEP encryption - all widths.*/
	WIFIENCTYPE_WEP = 2,

	/*WPA 1 with a preshared key using Temporal Key Integrity Protocol.*/
	WIFIENCTYPE_WPA_PSK_TKIP = 4,

	/*WPA 1 with a preshared key using Advanced Encryption Standard via CCMP. */
	WIFIENCTYPE_WPA_PSK_AES = 8,

	/*WPA 2 with a preshared key using Temporal Key Integrity Protocol.*/
	WIFIENCTYPE_WPA2_PSK_TKIP = 16,

	/*WPA 2 with a preshared key using Advanced Encryption Standard via CCMP.*/
like something like that
I would convert it, but I don't have a lot of processing power on the device, nor memory
I accidentally declared a 10 MB array and I had to reboot the darn thing =D
14
Q: Using Enums while parsing JSON with GSON

Sachin KulkarniThis is related to a previous question that I asked here earlier JSON parsing using Gson I am trying to parse the same JSON, but now I have changed my classes a little bit. { "lower": 20, "upper": 40, "delimiter": " ", "scope": ["${title}"] } M...

seems it does, if you fiddle around a bit
hmhmhh
I dunno whether the timesavings are worth replacing what I have now
especially since it's just cleaning stuff up
Null object pattern for camera components was easier to justify since it would save error checking in applications
 
you mean... cutting your code down by ... 50 LoC minimum?
 
Yeah but it doesn't affect the exposed sections of the library
same stuff goes in same stuff goes out, used in the same way by that which requests and receives the output
release deadlines suck
I was just spotting that I was starting to make a bit of a mess of things, and if I could extract the method somehow, it'd be cleaner
 
11:54 AM
... what's speaking against extracting a method again?
you don't have to use Gson ;)
 
Whether I can have multiple functions in a lambda
I could just plonk it in the parent module but I dunno, it seems like a utility method
 
what do you mean by "multiple functions"?
 
I woulda stuffed it in the model class maybe but I don't wanna pollute that with JSON
 
you want to put the same thing from your stream into multiple methods? then you need to get your consumer right.
you want to change the type of the thing you're streaming? use .map()
 
like so
FutureTask<List<StreamInfo>> future = new FutureTask<>(() ->
        {
            Future<JSONObject> responseTask = component.sendRequest("streamGetInfo.json", null);
            do
            {
                try
                {
                    JSONObject result = responseTask.get();
                    if (!result.has("response") || !result.getJSONObject("response").has("streams"))
                    {
                        System.out.println(result);
                        return null;
Java/pseudo code mixed
It's not much better but at least it separates the boilerplate from the work
13:00 lunch
 
12:01 PM
this isn't even a proper stream. there is no lambdas in there..
also you should be able to extract the "methodName" to a clean and separate method outside of your lambda.
 
12:23 PM
am I getting terms mixed up
() -> is lambda expression, right?
It's what the IDE offered to change my whole new Runnable construct with
 
correct.
But I don't understand what you mean by multiple "functions"
since lambdas are mostly used in the streams API and you're having so many streams in your code, I kinda... borked up..
anyways what you have here is probably internally converted to a Runnable.
 
I could make it runnable manually and add the method in there
 
why would you need to constrain the method to the runnable?
private void methodName(JSONArray stream, StreamComponentImpl parent) {
works just as well...
 
because not only is it private, there's no need to use it anywhere else
not a case of need
more like want
 
still why would you clutter your futureTask with it?
 
12:30 PM
I dunno, I'm just trying to make it work
 
after all your future task is not really about ... whatever you're actually doing in that method..
but the abstraction of iterating over the array and have it done
 
My future task is really about "wait for response, then parse it"
maybe you can snip it down to "wait for response"
 
exactly
 
That just becomes confusing
 
the parse it is done by your method. But that's not the responsibility of your future task.
 
12:31 PM
because then I pass the burden of parsing the response to external components
 
not really..
 
well if the future task doesn't contain a parse() of sorts
 
you just make the future task "wait for response, then pass it to parsing method"
 
ah okay.
 
why would it need to?
 
12:31 PM
I don't mean as method
as a call
 
the parsing method is not an integral part of the future tasks responsibility..
how the parsing works is actually irrelevant to the task.
 
a future task that just { waitForResponse() } would pass the responsibility to external components
but { response = waitForResponse(); parseResponse(response); } seems okay
hmmmh
I'll just write a couple more of these functions, maybe a pattern will emerge
 
~lunch
 
then I can make a wrapper for the JSON library I'm using and handle some of the crud there
 
12:56 PM
... damn I've been programming too much in C
making char[] for strings =/
I feel silly
or maybe not.... SSID's can be just 64x hex
Is there a way in Java to say "I take arrays of length 32 only"?
like public WifiNetwork(char[32] ssid) or something
 
1:12 PM
nope... you can reject the input though..
 
Nope.
 
if (arg.length != 32) { throw new IllegalArgumentException(); }
 
working on that now
it's not really obvious if you have
wow that was the wrong button
accidentally my browser
It's not really obvious if you have
public WifiNetwork(char[] hexSSID, WifiEncryptionType encryption, WifiMode mode)
public WifiNetwork(byte[] hexSSID, WifiEncryptionType encryption, WifiMode mode)
that they need different sizes
 
1 char = 2 byte ... it is kinda obvious..
 
hey again
 
1:16 PM
hey @skiwi
 
What's not obvious is that you need to fill the whole array though
 
@Pimgd you can't express that though method-signature in java..
you need to document that with JavaDoc...
 
... damn, I've been programming too much in C
=D
... wait, java char is 2 bytes...?
yeah that's obvious but that's also stupid of me
 
1:31 PM
char -> ASCII value -> 2bytes...
 
ASCII is one byte
goes from 0 to 255
well the extended version, anyway
the normal one from 0 to 127
 
> char | 16 bit | java.lang.Character | 0 ... 65.535 (e.g. 'A')
 
Monking
 
char supports unicode, it's 2 bytes.
 
char is UTF-8
SSIDs are ASCII (31 chars, +1 for NULL),
or hex (32 octets[bytes])
 
1:41 PM
Greetings, Programs.
 
@Donald.McLean Greetings, user
 
Greetin53"(-'bbb6ybf000000r-ddub6z6r8tvvvçz((u'(qkzn
4
segfault
4
 
Greetings, segfault.
 
0xdeadbeef
 
-1
Q: How to convert integer to roman numerals

hanaHi I would like to know how do I make a program that would convert an integer to a Roman numeral using if and if else only?

 
1:54 PM
wow.. 50 rep on so and 55 on cr...
something's definitely off today..
 
@Morwenn This has happened to me too many times in the past few weeks
 
@Pimgd That's what you get when you use C.
 
2:21 PM
@skiwi When are we gonna get a custom design?
 
Wat. I can't type quotes in MonoDevelop
 
2:53 PM
@Pimgd It may take months.
 
@Pimgd Up to one light year
 
which is... a distance..
 
@Vogel612 lol, perhaps the design is being space freighted to us from that distance.
Need to get a tracking number
 
monking
 
Monking @Mat'sMug
 
3:01 PM
Mugging @Mat'sMonk
4
 
Monking @All
 
0
Q: Example: Interfaces for adding data to a collection (readability, extensibility)

xvdiffI'm looking for some good practice advises regarding designing class interfaces where multiple methods should be provided to do a single task. As an example: Adding data to a collection. Requirements Adding a single item to the collection Adding multiple items to the collection Solution 1 p...

 
@rolfl Monking :)
 
Refactoring the heck out of some older code.
 
That's called "rewriting from scratch".
2
 
3:09 PM
0
Q: A java class for reading columns of a delimited text file

qedCode: import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; import java.util.Arrays; import java.util.List; import java.util.function.Supplier; import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stre...

 
0
Q: Null Object Pattern and Input validation - copy real implementation or silently accept everything?

PimgdI have a WifiComponent in my Camera in my client application. This WifiComponent can either be enabled (in which case I can do things with it, like checking connection status and scanning) or disabled (in which case you can't do anything with it at all). This "enabled/disabled" is decided at co...

 
lol
3
 
@Pimgd inb4: "It depends"
 
That's what the general question is for
Contract or neutrality?
I had "should it mimic the real implementation" before but that was seen as subjective
probably because of should
 
@Morwenn No, I just changed the name of one of my frequently used concepts to better reflect what it does and how it's used, so I had to rename a dozen or so classes and a bunch of methods.
 
3:18 PM
Is that still refactoring?
Right click -> rename...
3
dooone.
 
anyone use Jabbr for creating a chat on a website?
 
SE chat only chat
the rest are INFERIOR
 
Yay, yearling badges on CR!
3
 
gz @skiwi
<-- still needs to wait 4 months
 
3:40 PM
1
Q: Preventing errors while getting substrings from variable length strings

PhyreI am decoding Gs1 barcodes and need to match up application identifiers with relevant data about them. 0 SSCC (Serial Shipping Container Code) N2+N18 FALSE SSCC 1 Global Trade Item Number (GTIN) N2+N14 FALSE GTIN 2 GTIN of Contained Trade Items N2+N14 FALSE ...

 
2
A: Null Object Pattern and Input validation - copy real implementation or silently accept everything?

Bart van Ingen SchenauAs the null-implementation is supposed to be a drop-in replacement for the full-functional implementation, the null-implementation should fully adhere to the interface that it implements. If the WifiComponent interface specifies that connect() throws an exception if it gets invoked with an unsup...

yay, an answer
I'll let it sit till tomorrow, maybe people will have different opinions
 
in Tavern on the Meta on Meta Stack Exchange Chat, 1 min ago, by Frank
Mission: Outstar this other chatroom. http://chat.stackexchange.com/rooms/8595/the-2nd-monitor
4
we were declared war...
 
3:55 PM
:O
wonders which side to take
 
pff they're 1600 or so behind
 
1.1k..
 
That's gonna take a while
 
they're usually more..
 
Well maths is hard
 
3:57 PM
but looking at it now.. ;)
though the difference in starred messages is just 2000
off by one power of ten.. blames rounding errors
 
eh?
 
The Tavern has been around how long? The 2nd Monitor got 99.99% of its stars in the past year alone.
 
We star a lot though
 
@Mat'sMug it's the mse tavern though..
they are also not around since that long.
 
hmm
so what, we're more star-happy anyway
 

« first day (562 days earlier)      last day (3457 days later) »