C# Eggheads

    • Re: C# Eggheads

      DamnImGood wrote:

      One quick tip when writing code: give your variables meaningful names. "c", "t", "s", etc. aren't very meaningful; they tell you nothing about what's being stored in those variables and it makes reading and debugging much more difficult. It's an unfortunate trend with JavaScript developers. They do it to conserve script size (and to obfuscate their code), but it's annoying as hell.
      Yeah, any code that has an un-meaningful variable name is something I've copied and was unsure at the time what it was. I'll get to changing them tomorrow.

      I thought that was hard, the next one is trying to collect unique hashtags, and ignore duplicates. Which is proving challenging. So far I've managed to count each hashtag and how many occurrences it has. Maybe I'll stick with that come to think of it, just need to display the top 20 or in order of occurrence.

      I appreciate the help Brent, and hopefully I'll understand the PHP code. :p Then again, I have had some experience with PHP more than I have with C#.
    • Re: C# Eggheads

      Here it is in PHP (link is Pastebin):

      Clicky clicky

      Pretty much anything PHP can do, .NET should be able to do as well. PHP has a function called array_unique() which takes an array as an argument and returns another array without duplicate values.
      "I've never understood ethnic or national pride, because to me pride should be reserved for something you achieve or attain on your own, not something that happens by accident of birth."
      - George Carlin

      Striker88;1062839033 wrote:

      You know why nobody has gotten evidence? God hasn't allowed that and won't.
    • Re: C# Eggheads

      I'm sure .NET has similar functions.
      "I've never understood ethnic or national pride, because to me pride should be reserved for something you achieve or attain on your own, not something that happens by accident of birth."
      - George Carlin

      Striker88;1062839033 wrote:

      You know why nobody has gotten evidence? God hasn't allowed that and won't.
    • Re: C# Eggheads

      Practice makes perfect. The best way to learn to program is to do more of it. Also now that you know these functions exist (or at least I think similar ones exist for .NET) you can refine your code.
      "I've never understood ethnic or national pride, because to me pride should be reserved for something you achieve or attain on your own, not something that happens by accident of birth."
      - George Carlin

      Striker88;1062839033 wrote:

      You know why nobody has gotten evidence? God hasn't allowed that and won't.
    • Re: C# Eggheads

      There are some similar features that I've come across but unsuccessfully tried using, such as

      Source Code

      1. Array.Sort
      2. SortedList


      I've kicked myself backwards though, before I managed to get some code which listed everything with a number, which was the count of how many times that tweet(word) occurred. However, the .txt contains 3 HTML codes which are getting in my way. I've gone through MSDN so much today and the most I've come up with is using LINQ may be of some help to me, but I've still not managed anything.

      I'm trying to find some code, where I can ignore a certain part of a line, so when it comes to displaying the content in CMD it doesn't show <pre>, <p> or </pre>. Anywhere or any code that can help me out there?
    • Re: C# Eggheads

      Are you trying to remove just the tags themselves, or the tags and everything between them?

      If it's the former, then a simple string replace should suffice (replace the tags with an empty string). If you're looking to remove the tags and their contents, you'll have to use regular expressions.

      This is a function I wrote to parse [noparse]

      Source Code

      [/noparse] tags into <pre></pre> tags to display code. It uses a regular expression to do it.
      "I've never understood ethnic or national pride, because to me pride should be reserved for something you achieve or attain on your own, not something that happens by accident of birth."
      - George Carlin

      Striker88;1062839033 wrote:

      You know why nobody has gotten evidence? God hasn't allowed that and won't.
    • Re: C# Eggheads

      I was referring to the latter. One of the codes I'm got in another .cs file can remove the tags, which was pretty useful till I noticed the counter included inside the tags as words. It's proving harder than expected, although the nice push from LINQ to Regular Expressions is some help, as it's put me back to Regex. Unfortunately, eveytime I use String.Empty it wants to throw me a hissy fit. And Regex.replace isn't proving much handy either. But it's given me some more shit to research on now.
    • Re: C# Eggheads

      I think I got close to it, but every time I do it wipes the lines containing <pre>, </pre> or <p> clean which is baaaadddd..

      I got this, but I don't understand any of it inside the quote marks, and the whole </pre> was ignored and that still appeared on CMD when I was debugging.

      Source Code

      1. line = Regex.Replace(reader.ReadLine(), "[^<+.*' + '</pre>' + '.*>+]*", " ");
    • Re: C# Eggheads

      I've finally cracked it! With the aid of a Uni friend just pushing me into a website with the question that is identical to one of mine. Which is to order it, I managed to order my list in number of occurrences per tag, AND I killed the HTML tags. First with an array (not sure if I've mentioned it on here) THEN with an If statement which basically said if this variable identical to this, then nothing.. And it didn't appear in the CLI. :cool: