Thursday, August 15, 2013

Flying Eagle

Intoduction:
My new Passat is getting some goodies: AM parking sensors (both front and back). I decided that I want the experience to mount the parking sensor kit myself. What better chance to brush up my Eagle CadSoft skills?
I designed 2 mini PCB boards for front and back connections (some relays that will trigger the sensors behavior and decouples the parking sensors from the signals sources).

Tips to remember when the need arises next time:
- in layout board when you want to make the grounding, use the rename tool on the Cu surface. Also remember that button from the toolbar that should be on when the polygon tool is picked.
- to multiply the board and to print on the right scale use the replicate_board.upl tool by the UPL button from the toolbar (the script is on the CadSoft site), then print the resulted board without mirror or rotate.
- remember that the text you want on the bottom should be mirrored.
- make some clearance via the checking tool (1mm was fine for this project)
- you can make a default wire setup via net bla bla from the Edit menu.

Saturday, March 2, 2013

Internationalization in ASP.Net MVC Razor

More often internationalization is known as localization. The tools for the job are always the main decision factor in choosing the approach.

Last approach I used in an ASP.Net MVC site was using a resx for each culture. Didn't need (and also want) to replicate the views for each culture supported by the site. So I took every view and for each string needed to be internationalized, like a mindless robot :( , I iterated the folowing steps:

1. Selected the string
    2. Pressed the Ctrl+K,S then in Surround With popup pressed H, Tab, Q, Tab


    3. Back in the editor window, first notice the caret position (right after the legend tag and before the quote symbol), pressed Ctrl+Shift+] and the selection was remade(including quotes this time)

    4. Pressed Ctrl+R,Ctrl+X to show the Resource Refactor dialog (modified to be more proficient)


    5. There (because of my own ASP.Net MVC convention) I filled the prefix once for each new file I went through and proceeded with the string extraction and replacement with a property generated in the resx designer by the IDE.


    Note: Steps 1 and 2, sometimes were not needed (when the string was already had quotes). The Surround With script named quote was made by me, also as I mentioned the Resource Refactor VS extension was changed to allow a prefix for resource name.
    If you have a faster/smarter way, don't hesitate to leave a comment.

    Later edit:

    The step 2 needed an explanation for cryptic H and Q keys: H comes from HTML, Q comes from quote 


    Thursday, February 14, 2013

    Excel strikes back - some VBA

    From time to time a step back to basics is needed:
    Sub CreateHeadersAndFirstRowFormulaes()
        Range("AA1").Select
        ActiveCell.FormulaR1C1 = "ProperDate"
        Range("AA2").Select
        ActiveCell.FormulaR1C1 = "=DATE(VALUE(LEFT($C2;4)); VALUE(MID($C2;5;2)); VALUE(RIGHT($C2; 2)))"
        Range("AB1").Select
        ActiveCell.FormulaR1C1 = "ProperTime"
        Range("AB2").Select
        ActiveCell.FormulaR1C1 = "=TIME(VALUE(LEFT($D2;2)); VALUE(RIGHT($D2;2));0)"
    End Sub
    Sub PropagateFormulaes()
        Dim lastrow As Long
        lastrow = Range("C" & Rows.Count).End(xlUp).Row
        Range("AA2:AB2").Select
        Selection.AutoFill Destination:=Range("AA2:AB" & lastrow)
    End Sub