riahc3 50 Â Team Colleague

?user= is not a valid query parameter.

I saw that and I thought to myself "Damn I have to edit it" but I just got too lazy to do it. Sorry about that.

I ment ?username=riahc3

riahc3 50 Â Team Colleague

OK, jQuery's cache buster now gets stripped out by our cachebuster detection system. This means that you don't have to cache your jQuery calls anymore. They will still force a hard refresh to our server, but our server will strip out the jQuery cachebuster parameter when comparing to the URIs it has saved in Memcached, so you still might get stale data.

It happened to me as well in C# Ill try to look into it and give some feedback.

riahc3 50 Â Team Colleague

But kept getting this:

I noticed this happened with the 'nested' parameter for forums too (just straight url into browser bar) - is this expected?

Ive had this strange bug many times; Depends on how you implement it.

Using ?user=riahc3 doesnt work.

But using other functions does.

I didnt know if was a bug or what.

riahc3 50 Â Team Colleague

By "in the future" I meant I'll re-evaluate the situation in a few weeks/months. In other words, I'm not closing the door on the idea, but it's not something immediately planned.

My mistake.

I'm not aware of AD having issues? Did I miss his thread? Were they related to a plugin as well?

What do you mean about not being able to post code to our library? That shouldn't be affected by the Files uploader?

AD (see previous post) has issues with the editor as well. Thats what I ment. I asked it two times because the second time was referring to the files bug which there was a thread about and it ended in being about a extension.

If it is aboout extension, then I apoligize as that has nothing to do 100% with Daniweb; Although my extensions are purely web related (FireBug, FirePHP, CacheToggle, Web Developer, EventBug and FiddlerHook)

riahc3 50 Â Team Colleague

hmm ... again makes me wonder .... getting flagged as bad post, yet no reason stated as to what was "bad" at it.
message to the person who flagged it as being a bad post, since it was a direct answer to the question asked: either inform me why my post is bad, or don't expect any "improvements" in my future replies.

I agree...why was your post flagged down?

I upvoted your post because it truely is not fair that you got downvoted.

riahc3 50 Â Team Colleague

I go to "edit profile", clicked on the "update member profile" button and log out. After that, the only way (for me) to login is to reset my password,

The only thing that can remotely have to do with it (I doubt it is thing) is that if you click edit profile, you can edit your password. If you dont do anything and click update member profile, technically (I imagine there are checks against this but...) your password is set to "". Daniweb's DB might not allow that and cause problems.

Its the only thing I can up with...

Nick Evan commented: Yup! +0
riahc3 50 Â Team Colleague

Again, this is a demo app........In a serious app, yes, Id use a while loop until the user actually inserts something valid.

Java is the shittiest language known to man. I hate it to death and I work on it at my workplace daily. If I had time (and knowledge) I would port every known software written in Java to a better language (for example C#).

And Im not even talking about the security issues (which dont really exist if you control your browser settings correctly); Im talking about the language itself.

riahc3 50 Â Team Colleague

riahc3 strikes me as the type that reached a point of being able to write code that "works" and doesn't want to continue improving

What works, works; Why reinvent the wheel?

Learning stuff is always great of course (when you dont know how) but I perfer to do something ASAP rather than look up information to do it a new/better way.

It really makes no difference to me; The programs I write (hobby or professional) arent performance intenstive or anything like that. Ive never cared in the slightest for performance at all, unless Im obviously asked for.

riahc3 50 Â Team Colleague

Hello

This is a demo showing Java interacting with Daniweb's new API ( http://www.daniweb.com/api/documentation ) You introduce a member's name and it should show you the total number of posts he has made. Demo is a proof of concept: No bug checking, error checking, etc is in this code.

In order to make this work you need the Jersey library. Download here:

http://jersey.java.net/nonav/documentation/latest/chapter_deps.html#core_client

Any comments, bugs, glitches, etc, please say and Ill look into it.

riahc3 50 Â Team Colleague

And here it is:

package DaniWebClient;


import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.ws.rs.core.MultivaluedMap;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;

public class DaniWebClient 
{


    public static void main(String[] args) 
    {
        /*I prepare the API*/
        Client client = Client.create();
        WebResource webResource = client.resource("http://www.daniweb.com/api/members");

        /*User introduces name*/
        System.out.println("Enter the member who's post you want to see: ");
        String user;     
        Scanner scanIn = new Scanner(System.in);
        user = scanIn.nextLine();
        StringBuilder username=new StringBuilder(user);

            /*I remove whitespaces except actual spaces*/
            for (int i=0;i<username.length();i++)
            {
                if ((Character.isWhitespace(username.charAt(i))) && (username.charAt(i)!=' '))
                        {
                            username.deleteCharAt(i);
                        }
            }
            user = username.toString();
            /*For some stupid reason, Java is stupid (no surprise there) and doesnt consider ALT+0160 a whitespace. I have to remove it manually*/
            user = user.replace("\u00A0","");

            /*I make sure that the user name isnt empty */
            if (user.length()==0)
            {
                System.out.println("Please insert a valid member");
            }
            else
            {

                /*I call the members method of the API and pass parameters by GET. POST not tested in Java*/
                MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
                queryParams.add("username", user);

                /*Send it and wait for reply*/
                String output = webResource.queryParams(queryParams).get(String.class);

                int first=0;
                int next=0;

                /*Finding where it says the post number in the response...*/
                first=output.indexOf("\"posts\":\"");

                if (first==-1) /*-1 means it could not find it therefore no member exists*/
                {
                    System.out.println("Member not found!");
                }
                else
                {
                    do
                    {
                        /*I find the next quote that actually begins the post number*/
                        next = output.indexOf("\"",Integer.valueOf(first));

                        /*Not neccesary but in case Dani changes the array to something else....*/
                        if (next==-1)
                        {
                            break;
                        }

                    }while(next==0);

                     /*VERY Ugly hack to get posts numbers. …
riahc3 50 Â Team Colleague
riahc3 50 Â Team Colleague

Since its a console app, Ill just post the code. Copy/paste and it should work as long as you have the library it should work.

riahc3 50 Â Team Colleague

Got a Java snippet working too :) Will post soon.

Only two languages I dominate (somewhat :P ) so thats the only contributions I can give to help others develop apps.

You need the Jersey library for this.

riahc3 50 Â Team Colleague

Hello

Im having problems removing the ALT+0160 character from a string. iswhitespace doesnt seem to work.

How can I manually remove it?

riahc3 50 Â Team Colleague

There is currently not an API to post. Write functionality is very limited, sorry.

OK I misunderstood you; I thought you were going to in the future allow posting as well, sorry

riahc3, You can't post code snippets. You can't attach files. You're the only person complaining, but it seems that is because you are experiencing something very different from all the rest of us. Maybe we'd all be complaining if things were as broken for us as they seem to be for you. Unfortunately it seems all of your problems are related to browser plugins that you're using that are manipulating DaniWeb from working the way it was designed.

Its only me? Ancient Dragon also has issues. Its only me? Theres a thread made by another member about the attaching issue (It was solved but nonetheless). I really hope the error highlight feature helps out (I havent been able to test it out yet) but Its not only me...

riahc3 50 Â Team Colleague

This is why I hate Java :P

Im porting my C# dummy program to Java as well but it seems its putting up some fights.

Thing is I spend 99% of my time (working) on Java and about 1% of my time as a hobby on C#!

BTW, ignore my PM Dani. I figured out what was happening.

riahc3 50 Â Team Colleague

Dani, Im going to send you a PM about a issue Im facing with the API. Im not sure if you want it to be visible so just in case......Its problably nothing.

riahc3 50 Â Team Colleague

LINQ is quite clear when used in small doses and in appropriate circumstances. I agree with you that code should be readable, however, that's no reason to avoid "advanced" coding methods.
I have seen some nightmare LINQ, truly, it should have been burned at some kind of sacrificial altar, but when used in small amounts, it's as easy to maintain and read as a normal loop statement. I don't understand why you wouldn't use a foreach, it seems wasteful to exclude these features which are there for our benefit and is in fact, more clear than a for loop.

LINQ (AFAIK) is some kind of SQL-like sintaxis for programming in .NET Its nonstandard practice, although versions exists for other languages as well. My C# code is fairly portable in the sense that with little changes, (except for RestSharp) this should also work in other languages. As a matter of fact, Im looking to do a Java version as well.

The reason I dont use a foreach is like I stated:

Its unclear to a first timer.
I have yet to personally find a foreach that cannot be subbed by a for loop.

riahc3 50 Â Team Colleague

I think it would be more useful if the validator could indicate the line or lines that have been flagged as invalid.

OK comment. Id perfer the other way but...

Because we learned from the BBCode nightmare (which is still ongoing behind the scenes) that heuristics cannot always be used to accurately predict what the end-user is trying to accomplish.

The end-user is trying to make a post. He at the end doesnt care if its formatted correctly to the standards of Daniweb. If your posting system thinks it is code, just automatically set it as code. If it isnt, I think a human being on these forums can tell. The important thing is that its a not a hell posting on these forums.

That's something I'll look into doing. I think it should be doable.

Something is better than nothing I guess...

Plus, for the posting client I plan to making using your API, it would make it a lot easier for me as well.

riahc3 50 Â Team Colleague

The problem arises that he also needs to decrypt it with the same key. So unless he transmitted the timestamp across so that the psuedorandom generator could generate the same number, this would not work.
If the timestamp were transmitted, then you've just given away your key... Also, I have been reliably informed that the encryption method you linked to is flawed and implemented incorrectly after I too, also attempted to use it as a base for my own encryption. I could not tell you why, I'm no security expert. ^.^

He asked, I answered.

riahc3 50 Â Team Colleague

Rather than your for loop to check for whitespace, you can put all the code into a LINQ statement :) textBox1.Text = String.Concat(textBox1.Text.Where(c => !char.IsWhiteSpace(c) || c.Equals(' '))); The need for String.Concat arises because the where clause returns IEnumerable<char> which is unfortunate :( There is probably also an improvement to resource usage with the above code as you won't be constantly creating string objects.

After reviewing some performance figures, instead of using String.Concat above, use textBox1.Text = new String(textBox1.Text.Where(c => !char.IsWhiteSpace(c) || c.Equals(' ')).ToArray()); In fact, never use String.Concat. It seems it sucks...BAD.

On a personal level, I have never cared or put intrest in resource hogging, memory hogging, or performance in any of my programs Ive written to date. I believe (your LINQ example) if it is not clear nor to me nor to most people that read the code, I should not use it. When writing code, I think that the most important thing is that the code is first clear to me than to others. Reason why I never use a foreach....

This code is as is and a proof of concept. No more than 10 minutes has been put into it. Its not ment to be used either seriously or in a production enviroment.

riahc3 50 Â Team Colleague

Did you marked your post on whitespace as solved yet?
You don't have to do this for my beautifull eyes you know...

Your post wasnt exactly the answer or solved it....

Ill upvote you if you want but thats it.

riahc3 50 Â Team Colleague

The code validation check looks for tabs, 4 or more spaces, or curly braces anywhere in the post. If those things are outside of a code block, you'll get the error message.

Look at the picture. There is nothing wrong with that and it completes all you mention.

Suggestion, instead of making the code validator look for tabs, 4 or more spaces or curly braces, why not if there are tabs, 4 or more spaces or curly braces........IT TURNS THAT TEXT INTO CODE FORMATTING?!?!?! Its really frustrating.

riahc3 50 Â Team Colleague

There really is no "best". Microsoft's SQL Server basically works out of the box I believe. But all others are pretty much compatible.

I personally always suggest MySQL/MariaDB. Very configurable (Note that this is a good AND bad thing) MSSQL is good but It just not 100% free nor open source.

riahc3 50 Â Team Colleague

So you saying this site is the best if you tend to ask stupid questionsa and don't know how to spell the word stupid?

Isn't life ironic?

otengkwaku commented: true how ironic? +0
riahc3 50 Â Team Colleague

You're welcome!! :) Thanks guys.

Why did you join? :P

On a side note, Dani developed this http://www.daniweb.com/web-development/php/threads/9379/vbulletin-mod_rewrite which was at its time (and Im sure many older sites use it as well today) helpful to MANY webmasters as it generated traffic for them.

A bit of Daniweb history: http://en.wikipedia.org/wiki/DaniWeb

I joined........(looking at threads ive made)............because............ah, yes, I was coding comething in C and I needed some help. Googled and somewhere else pointed me to this site (before StackOverflow). From then on, life has been OK in Daniweb...........until the editor change which I wont go into in this thread.

riahc3 50 Â Team Colleague

I don't know what the above link has to do with this thread but because my issue was resolved then I'm going to mark this thread as done.

I thought I posted my post in that thread. Sorry.

http://www.daniweb.com/community-center/daniweb-community-feedback/threads/439477/opinion-who-thinks-making-a-post-on-these-forums-is-horrible/7#post1932301

So no. this issue is not solved. Sometimes it works, sometimes it doesnt, with the same extensions enabled.

riahc3 50 Â Team Colleague

Sorry to bump this thread, but DaniWeb currently does have a public API:

Funny how things change from one year to the next.

riahc3 50 Â Team Colleague

http://www.obviex.com/samples/encryptionwithsalt.aspx

And where it says:

Random random = new Random(seed);

Put

Random random = new Random((int)DateTime.Now.Ticks);

Would be, I believe, the timebased encryption you are looking for....

riahc3 50 Â Team Colleague

Cheers Riahc3 :)

I want to cut my vains out because of the frustration that is posting on Daniweb!!!! :P

If you find any bugs/glitches please comment.

riahc3 50 Â Team Colleague

OK Ive been able to post it but without the text that I put after. What is wrong with it?

riahc3 50 Â Team Colleague

OK, its the text I put after the snippet. What is wrong with it?

riahc3 50 Â Team Colleague

RestSharp library needed

Mike Askew commented: Thanks for sharing, +rep +6
riahc3 50 Â Team Colleague

Latest Daniweb bug:

http://img502.imageshack.us/img502/2782/postjq.png

I wouldnt even call this a bug. Its just the damn editor.

Tells me code is incorrectly formatted. Im sorry but I cannot see it.

riahc3 50 Â Team Colleague

http://img502.imageshack.us/img502/2782/postjq.png

I am begging you Dani, and anyone else, please tell me what is wrong with this post?

riahc3 50 Â Team Colleague

I cant post it to the snippet section. Like Ive mentioned over and over, posting on Daniweb completely blows. Someone can post the code in the snippet section, although personally its not to my liking but for the good of the community....

Just give me credit, obviously :)

riahc3 50 Â Team Colleague

God, I cant wait to write a client to post on Daniweb. This is just frustrating that you can make a simply snippet post...

riahc3 50 Â Team Colleague

Two things I forgot; Most important IMO:

Thanks to Tekmaven for the idea on how to implement this in C#
Thanks to ddanbe for the spaces fix

riahc3 50 Â Team Colleague

Here is the code. Ill post this in the snippet section as well:

private void button1_Click(object sender, EventArgs e)
        {
            string newString = "";
            var client = new RestClient("http://www.daniweb.com/api"); /*I prepare the API*/

            /*I remove whitespaces except actual spaces*/
            for (int i = 0; i < textBox1.Text.Length; i++)
            {
                if ((char.IsWhiteSpace(textBox1.Text[i])) && (!textBox1.Text[i].Equals(' ')))
                {
                    textBox1.Text = textBox1.Text.Remove(i, 1); 
                }

            }


            /*I make sure that the user name isnt empty */
            if (textBox1.TextLength==0)
            {
                MessageBox.Show("Please insert a valid member");
            }
            else
            {

            /*I call the members method of the API and pass parameters by GET. POST did not work (Why?)*/
            var request = new RestRequest("members", Method.GET);
            request.AddParameter("username", textBox1.Text);

            /*Send it and wait for reply*/
            var response = client.Execute(request);

            /*Finding where it says the post number in the response...*/
            int next = 0;
            int first = response.Content.IndexOf("\"posts\":\"");
                if (first==-1) /*-1 means it could not find it therefore no member exists*/
                {
                    MessageBox.Show("Member not found!"); 
                }
                else
                {
                    /*I find the next quote that actually begins the post number*/
            do
            {
                next = response.Content.IndexOf("\"", first);
                /*Not neccesary but in case Dani changes the array to something else....*/
                if (next==-1)
                {
                    break;
                }
            } while ((next==0));



            /*VERY Ugly hack to get posts numbers. Tried with largest post numbers I could find (Dani's AFAIK)*/
            string str2 = response.Content.Substring(first, (next + 16) - first);
            newString = Regex.Replace(str2, "[^.0-9]", "");

            }

             if (textBox1.TextLength == 0)
             {
                 MessageBox.Show("Please insert a valid member");
             }
             else if (first!=-1)
             {
                 MessageBox.Show(newString, "The total amount of posts this user …
riahc3 50 Â Team Colleague

OK, applied quick fix so now members with spaces can now be found as well. Thank you to ddanbe for giving me ideas on how to implement it.

https://mega.co.nz/#!cFRyTRqY!OPJSFABLtywLF8egEjKiRk9CtBYt9PDZcaxZQmRGLPQ

riahc3 50 Â Team Colleague

@Riahc3, I'll take you up on that offer ;)

OK, ill tidy it up a bit and put some slight comments.

Remember this is a proof of concept; The code is very dirty and "as is".

riahc3 50 Â Team Colleague

You don't embed DLLs into executables, you package them in an installer such that they're copied to and registered with the target machine. So in your case you need to create a setup and deployment project. This project will produce an MSI that will handle installing all of the required files to run your application.

No way to do this then? That sucks.

riahc3 50 Â Team Colleague

Hey

I want to remove all strange whitespaces (such as Alt+0160) except the actual space, as in spacebar.

How can I do this?

riahc3 50 Â Team Colleague

OK here you go:

https://mega.co.nz/#!pUxxzDrB!LHaImnHwvhy607WG0j5XwHUvq1xQ4Ust3GTqp4i0WVk

This targets 4.0. Should run on Windows (obviously) and on OS X and Linux as long as you have the latest stable version of Mono.

riahc3 50 Â Team Colleague

Im going to recomply it for 4.0 which there is a stable version of Mono avaliable for your platform, Dani (OS X).

Here is a link: http://www.go-mono.com/mono-downloads/download.html get the stable version.

riahc3 50 Â Team Colleague

riahc, I can't run your program because it says I don't have the latest version of .NET. Plus, I'm on a mac.

Yes, its a C# program. You will have to install Mono and Im not sure if its supported. I complied this in VS2012 so you need the 4.5 framework.

The screenshots is pretty much all there is to it. Nothing else.

Its only purpose is to show the compatibilty between C# and your API.

Once I understand OAuth, Im problably going to work on a posting app.

riahc3 50 Â Team Colleague

Just URL encode the username. I fixed the bug where that was broken before.

As I mentioned it is a demo app; Not really useful for anything but shows that the API is also working with a desktop client.

You're confusing "won't" with "have no clue what's wrong". You say that it suddenly stopped working one day, but I made absolutely no code changes that could possibly have affected anything. I really am not sure at all what's wrong. Try disabling all Firefox plugins. Maybe one of your plugins/extensions is conflicting??

A extension is the only thing that could be causing it but it works on other pages with a similar system (hides dialog then shows)

riahc3 50 Â Team Colleague

Are you running the Ghostery plugin? If so then add Daniweb to the whitelist. That's what was causing that problem in my case

Nope

riahc3 50 Â Team Colleague
riahc3 50 Â Team Colleague

So the program doesnt explode because someone tries putting stupid stuff, Ive barred spaces so "Nick Evan" for example does not work.