Tethik's Profile User Rating: -----

Reputation: 17 Tradesman
Group:
Active Members
Active Posts:
61 (0.04 per day)
Joined:
14-March 10
Profile Views:
4,006
Last Active:
User is offline Sep 27 2012 03:28 PM
Currently:
Offline

Previous Fields

Country:
SE
OS Preference:
Linux
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0
Icon   Tethik is lurking.

Posts I've Made

  1. In Topic: What are you working on today?

    Posted 10 Jul 2012

    I'm creating graphs using Microsoft Chart Controls and coding Stored Procedures to fetch the data used by the graphs. Our customer wants a statistics overview of their system that we code and maintain for them.

    Learned a bit about temporary tables and was able to make my queries better performance wise :)
  2. In Topic: [ASK] BinaryReader

    Posted 5 May 2012

    Let's analyse where all the memory disappears to:
        Function readd(ByVal path As String, Optional ByVal Separator As String = " ")
            ' Store the line in this String.
            Dim line As String
    
            ' Create new StreamReader instance with Using block.
            Using reader As StreamReader = New StreamReader(path)
                ' Read one line from file
                line = reader.ReadToEnd
            End Using
    
    

    After this the variable line should contain all the contents of the file given by path. So 100 mb.

            ' Convert to ASCII and go through all the bytes
            For Each Character As Byte In ASCIIEncoding.ASCII.GetBytes(line)
                oReturn.Append(Convert.ToString(Character, 2).PadLeft(8, "0"))
                oReturn.Append(Separator)
            Next
    
    

    Out of every byte you're now converting to a string in base 2. So now for example:
    "a" -> "01100001" // 8 times bigger than original byte.
    
    

    You then add another zero and a separator, so at least 2 more chars per char to the new string that is being built.

    I guestimate that in the end the program will be using something like 1,1 GB of memory to read your file 100 MB into a string.

    To fix you may want to consider writing it to another file like Ionut said. You could also grab the bytes directly from the stream by reading them one at a time, instead of storing them all in the line variable. This should cut 100 MB of memory usage.
  3. In Topic: Quick Search problem

    Posted 5 May 2012

    View PostdeVirus, on 05 May 2012 - 08:27 AM, said:

            Dim sql As String = "select * from account_table where customer_surname like '%'" & tbox_acc.text & "'%'"
    
    


    Should probably be:

            Dim sql As String = "select * from account_table where customer_surname like '%" & tbox_acc.text & "%'"
    
    


    Only difference is that there is no ' inside the LIKE search-string.
  4. In Topic: Challenge: The Dot Creation Of Numbers (Intermediate)

    Posted 4 May 2012

    Here's my first simple attempt. Using a stringbuilder and CType operator.
    Note also that it's not possible to write the "Negative" prefix after the first dot.

    I will try to improve on it a bit. Too much repetition at the moment...

    Spoiler




    Edit: New version using only Integer extensions and Static fields. :whistling:
    Should be easy now to write a macro that generates these classes and extensions given String + Number value.
    Imports System.Runtime.CompilerServices
    
    Module NumberDotting
    
        Public Class Number
            Public Shared Zero As Integer = 0
            Public Shared One As Integer = 1
            Public Shared Two As Integer = 2
            Public Shared Three As Integer = 3
            Public Shared Four As Integer = 4
            Public Shared Five As Integer = 5
            Public Shared Six As Integer = 6
            Public Shared Seven As Integer = 7
            Public Shared Eight As Integer = 8
            Public Shared Nine As Integer = 9
    
            Public Class Negative
                'Public Shared Zero As Integer = 0 'Negative Zero? Will only cause problems.
                Public Shared One As Integer = -1
                Public Shared Two As Integer = -2
                Public Shared Three As Integer = -3
                Public Shared Four As Integer = -4
                Public Shared Five As Integer = -5
                Public Shared Six As Integer = -6
                Public Shared Seven As Integer = -7
                Public Shared Eight As Integer = -8
                Public Shared Nine As Integer = -9
            End Class
        End Class
    
        <Extension()> _
        Public Function Zero(ByVal val As Integer) As Integer
            If val = 0 Then
                Throw New Exception("Bad Integer Format!") ' If user tries to put Zero.?
            End If
            Return val * 10
        End Function
    
        <Extension()> _
        Public Function One(ByVal val As Integer) As Integer
            Return Zero(val) + IIf((val > 0), 1, -1)
        End Function
    
        <Extension()> _
        Public Function Two(ByVal val As Integer) As Integer
            Return Zero(val) + IIf((val > 0), 2, -2)
        End Function
    
        <Extension()> _
        Public Function Three(ByVal val As Integer) As Integer
            Return Zero(val) + IIf((val > 0), 3, -3)
        End Function
    
        <Extension()> _
        Public Function Four(ByVal val As Integer) As Integer
            Return Zero(val) + IIf((val > 0), 4, -4)
        End Function
    
        <Extension()> _
        Public Function Five(ByVal val As Integer) As Integer
            Return Zero(val) + IIf((val > 0), 5, -5)
        End Function
    
        <Extension()> _
        Public Function Six(ByVal val As Integer) As Integer
            Return Zero(val) + IIf((val > 0), 6, -6)
        End Function
    
        <Extension()> _
        Public Function Seven(ByVal val As Integer) As Integer
            Return Zero(val) + IIf((val > 0), 7, -7)
        End Function
    
        <Extension()> _
        Public Function Eight(ByVal val As Integer) As Integer
            Return Zero(val) + IIf((val > 0), 8, -8)
        End Function
    
        <Extension()> _
        Public Function Nine(ByVal val As Integer) As Integer
            Return Zero(val) + IIf((val > 0), 9, -9)
        End Function
    End Module
    
    
  5. In Topic: Communicate on the internet based on asp.net website

    Posted 4 May 2012

    You should be able to use Sockets (System.Net.Sockets) in the backend code.
    http://msdn.microsof...et.sockets.aspx

My Information

Member Title:
D.I.C Head
Age:
22 years old
Birthday:
October 1, 1991
Gender:
Location:
Stockholm
Programming Languages:
PHP, C++, Java, C#

Contact Information

E-mail:
Private
MSN:
MSN  zockas@hotmail.com

Friends

Tethik hasn't added any friends yet.

Comments

Page 1 of 1
  1. Photo

    NotarySojac Icon

    01 Sep 2011 - 11:37
    awesome, I'm glad!
  2. Photo

    Tethik Icon

    30 Aug 2011 - 08:57
    You're free to use it as you wish NotarySojac. Credits are nice of course but I would only ask for a small notice.
  3. Photo

    NotarySojac Icon

    29 Aug 2011 - 15:41
    Hey, I'm posting it now at http://www.dreamincode.net/forums/topic/245363-sudoku-on-rails-code-critiques-plz/
    Let me know if you'd like anything changed or removed, I'd be more than happy to remove it when you get this. ttyl
  4. Photo

    NotarySojac Icon

    29 Aug 2011 - 12:42
    Hey Tethik,
    Remember that Sudoku challenge that you participated in? Can I use your code in an upcoming, open source demo project I'm about to make a post for? You shall certainly be credited, and only minor adjustments were made to your Sudoku.rb to allow it to interpret puzzles directly on the command line.
Page 1 of 1