Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

PaulLinton

@PaulLinton
About
Posts
24
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • What position is the letter A? Let's use a lookup table!
    P PaulLinton

    I thought I had a more useless lookup table, but I was wrong

    private static Dictionary alphabet = new Dictionary();
    static AlphabetPositionMap()
    {
    alphabet['A'] = 'A';
    alphabet['B'] = 'B';
    // you get the idea
    }

    I am wrong because it is only a small step from this code to creating an Enigma machine in software, which I believe had some amount of use a few years back. Failed at being useless :sigh:

    The Weird and The Wonderful ruby question

  • Planetary orbit problems again
    P PaulLinton

    I haven't seen Interstellar but have read some articles about the science. The depiction of the black hole was quite interesting. The accretion disk is actually fairly flat. In the movie it looks like a sphere because of the bending of light around the black hole. As I understand it, the light from the far side of the accretion disk that you would expect to go over the top of the black hole and not enter your eye is bent by the warping of space around the hole. The light from the far side enters your eye but appears to be coming from above the black hole and so it looks like there is accretion disk above. -- A little like a normal mirage where light from the sky is bent and appears to be on the road ahead. -- Apparently, they had to write their own rendering software because all existing software assumes light travels in straight lines, which is vastly not true near a black hole. The story goes that they set their new software an overnight rendering job to see what the accretion disk would look like. There was surprise at first when they saw the result but worked out why they got the result when they thought carefully about how light would be bent near the hole. (Found a link http://www.wired.com/2014/10/astrophysics-interstellar-black-hole/[^])

    The Lounge question

  • Well I never
    P PaulLinton

    When you pay too much tax to the taxman who then gives you back your money with no interest why do most people think that is good? I aim to pay less tax during the year so that the taxman has basically been giving me an interest free loan which I repay at the end of the year. It has always puzzled me that people think getting a tax refund is a good thing.

    The Lounge

  • Sloppy Code - thoughts
    P PaulLinton

    How does 'just' relate to 'ctrl+shift+alt+windows+1+F'? :) https://www.youtube.com/watch?v=ab8GtuPdrUQ[^]

    The Lounge question discussion

  • It's Primes as far as the eye can see!
    P PaulLinton

    What's the problem? That lists all the primes less than 26. It also lists some other numbers as well, no extra charge.

    The Weird and The Wonderful question

  • Error message of the week
    P PaulLinton

    I just tried to register for a 'free' report at an accountant's web site. Entered First, Last, Email, Pass and captcha. Then clicked on 'Register' to get this

    INSERT INTO `dbbizval`.`tblauth` (`fldCustomerID`, `fldCustomerUserName`, `fldCustomerPassword`, `fldCustomerEmail`, `fldCustomerDate`, `fldCustomerFirstName`, `fldCustomerLastName`, `fldCustomerAddress1`, `fldCustomerCity`, `fldCustomerStateID`, `fldCustomerCountryID`, `fldCustomerPostCode`, `fldCustomerPhone`, `fldActive`, `fldLoginAttempts`, `fldDisabledTime`, `fldRandomKey`, `fldHowHeard`) VALUES (NULL, "My Email address", "MyPassword", "MyEmail", CURRENT_TIMESTAMP, "Paul", "Linton", NULL, NULL, NULL, NULL, NULL, NULL, "1", NULL, NULL, NULL, NULL);Could not connect: Access denied for user 'dbbizval'@'27.50.90.137' (using password: YES)

    (My email and password were both displayed in plain text) Nice of them to give me their username and password as well as telling me my own.

    The Lounge help

  • IIF to the rescue...
    P PaulLinton

    I don't know VB and was just wondering ... if

    Return OrderNumber = 0

    does a comparison and returns the result then how would you set the value of OrderNumber to 0 and then return OrderNumber? In C#, the first is

    return OrderNumber == 0;

    and the second is

    return OrderNumber = 0;

    The Weird and The Wonderful help

  • Interesting boolean technique
    P PaulLinton

    If ! is hard to read then make it more obvious

    private bool CaseWeCareAbout(string input)
    {
    return !!!!!!!!!!!input.StartsWith("Case we don't care about");
    }

    The Weird and The Wonderful question

  • Silly VisualStudio.
    P PaulLinton

    Double-click does not detach the tab for me. Dragging a tab does. Maybe you just need to change the drag sensitivity? http://blogs.msdn.com/b/oldnewthing/archive/2009/04/10/9541813.aspx[^]

    The Lounge visual-studio database question

  • Built my first computer 40 years ago
    P PaulLinton

    1976 (or there abouts) I soldered up a veroboard mounted National Semiconductor SC/MP (scamp). 256 bytes of memory in two chips. Front panel had 8 leds, 8 switches for address and 8 switches for data. A push button for deposit and another for run. There was a single bit of output which I connected to an earpiece and it could play very simple, very short pieces of 'music', mainly stuff from my 'Learn to play the Recorder' workbook. The 'case' was made of chipboard with holes drilled in the top to allow ventilation. Front panel was a lovely piece of brushed aluminium. Consumed months of my pocket money and worth every cent. The design came from Electronics Australia and they had produced a pcb but I couldn't afford to buy it. Did anyone else make one of these?

    The Lounge performance question learning

  • Make a textbox act like Excell Cell
    P PaulLinton

    Are you aware of this article A Calculation Engine for .NET[^]

    WPF csharp asp-net com help

  • Button Bound To Command Won't Disable
    P PaulLinton

    Whenever you change isTesting you will need to call

    RunCommand.OnCanExecuteChanged()

    (If it isn't, you might want to make isTesting a property and call OnExecuteChanged from the Setter)

    WPF wpf csharp architecture help question

  • A new definition of efficiency
    P PaulLinton

    Just saw this posted on another forum

    List _chars = new List();

    for (int i = 0; i < 2000; i++)
    {
    if ((i >= 48 && i <= 57) || (i >= 97 && i <= 122))
    {
    _chars.Add((char)i);
    }
    }

    The author claimed that the code "work efficiently". I wonder how the upper limit of 2000 was determined? Why not int.MaxValue? Then you could maximise the inefficiency. Of course, you could do better with a long, or a lower bound of int.MinValue but that's getting silly. The way _chars was used later all that was required was

    string _chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    The Weird and The Wonderful question learning

  • It was the 13th hour of the 13th day of the 13th month...
    P PaulLinton

    Yes, it is bad but understandable. The equivalent of that code works just fine in Excel, for example. Try "=Date(2011,Month(Today())+1,1)" and you get 1/1/2012 which seems sensible to me. It's a coding style I have used for years. No excuses, I'm just saying.

    The Weird and The Wonderful

  • Redundancy Peaking
    P PaulLinton

    I hope this code didn't get in to production :laugh: because it doesn't work. Try

    TruthChecker(false, 1)

    I think this will return true :(

    The Weird and The Wonderful question

  • Redundancy Peaking
    P PaulLinton

    In c# I prefer

    // to be sure, to be sure, to be sure
    if (((boolVar == true) == true) == true) {

    I find that three levels is optimum

    The Weird and The Wonderful question

  • Road Deaths
    P PaulLinton

    It was interesting, to me at least, that in every month of 2001 more people were killed in road deaths in the US than died in the terrorist attacks of September that year. Is that too high? Imagine a 9/11 occurring every month. Month in - month out. That's the level of road deaths. I reckon its too high.

    The Lounge question

  • How come I get a rounded number when I multiply doubles?? [modified]
    P PaulLinton

    You are always going to store 24.25 in a floating point number exactly. 24.25 is a power of two. You should never see any of the results you listed (except 24.25) no matter what print formatting is specified.

    C# help question

  • Query regarding IEnumerable [modified] - Stupid question
    P PaulLinton

    I can create a method on any class called GetEnumerator(), it doesn't have to have anything to do with IEnumerable. Eg public class DumbClass { public string GetEnumerator() { return "Good morning";} } Not very useful but now I can say DumbClass x = new DumbClass(); Console.WriteLine(x.GetEnumerator()); ForEach needs an implementation of IEnumerable.

    C# question database

  • de Morgan Who?
    P PaulLinton

    If the logic is difficult for the author to understand, have pity on anyone else who will read the code. How about if (!ignoreExisting) throw; if (sx.Number != 2714) throw; Personally, I find double negatives put my head in a spin, so I would go for if (obeyExisting) throw; for the first test.

    The Lounge help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups