Tuesday, December 15, 2015

Total Commander tips for compare files/folders

Enhance the Total Commander with some helpful buttons:

purpose: Compare folders
command: c:\Program Files (x86)\Meld\Meld.exe or c:\Program Files\KDiff3\kdiff3.exe
parameters: ?%X"%P." "%T."

purpose: Compare files
command: c:\Program Files (x86)\Meld\Meld.exe or c:\Program Files\KDiff3\kdiff3.exe
parameters: ?%X"%P%N" "%T%M"

purpose: Copy file names to clipboard (works well with filters)
command: cm_CopyNamesToClip

? prompts the user for parameters (should be removed when everything goes fine)
%X always use left - right as in the Total Commander panels
. after %P and %T fixes the \ ending by redirecting at the current folder

Friday, March 13, 2015

Go incursion on Windows - powershell

Today moved on Windows with the project and tried to address same folder limitation for go build (no luck: named files must all be in one directory; have blabla\ and blabla\someotherblabla\ )
$allGoFilesForBuildStringBuilder = New-Object -TypeName "System.Text.StringBuilder"
Get-ChildItem . -recurse | where { $_.extension -eq ".go" } | ForEach { $allGoFilesForBuildStringBuilder.Append('"').Append($_.FullName).Append('" ') } 
go build $allGoFilesForBuildStringBuilder.ToString()
Reminder: If you are stuck on GOROOT_BOOTSTRAP error, check that this env variable hints to a go folder having all the binaries in the bin subfolder.
[Environment]::SetEnvironmentVariable("GOROOT_BOOTSTRAP", "Go_Folder", "User")
Use "Machine" instead of "User" for system wide configuration

Thursday, November 20, 2014

Using VIM

Getting some time for myself, I decided to improve my professional skills by adding a new powerful tool: vi.
Having some trouble changing inside a quoted string with ci" (after some time i figure it out: it should be ci" and a space right after(for quotes)), I found this gem:

The operators that can be used are:
 ~ switch case     |v_~|
 d delete      |v_d|
 c change (4)     |v_c|
 y yank      |v_y|
 > shift right (4)     |v_>|
 < shift left (4)     |v_<|
 ! filter through external command (1)  |v_!|
 = filter through 'equalprg' option command (1) |v_=|
 gq format lines to 'textwidth' length (1)  |v_gq|

The objects that can be used are:
 aw a word (with white space)   |v_aw|
 iw inner word     |v_iw|
 aW a WORD (with white space)   |v_aW|
 iW inner WORD     |v_iW|
 as a sentence (with white space)   |v_as|
 is inner sentence     |v_is|
 ap a paragraph (with white space)   |v_ap|
 ip inner paragraph     |v_ip|
 ab a () block (with parenthesis)   |v_ab|
 ib inner () block     |v_ib|
 aB a {} block (with braces)   |v_aB|
 iB inner {} block     |v_iB|
 at a block (with tags)                  |v_at|
 it inner block                   |v_it|
 a< a <> block (with <>)    |v_a<|
 i< inner <> block     |v_i<|
 a[ a [] block (with [])    |v_a[|
 i[ inner [] block     |v_i[|
 a" a double quoted string (with quotes)  |v_aquote|
 i" inner double quoted string   |v_iquote|
 a' a single quoted string (with quotes)  |v_a'|
 i' inner simple quoted string   |v_i'|
 a` a string in backticks (with backticks)  |v_a`|
 i` inner string in backticks   |v_i`|
Additionally the following commands can be used:
 : start Ex command for highlighted lines (1) |v_:|
 r change (4)     |v_r|
 s change      |v_s|
 C change (2)(4)     |v_C|
 S change (2)     |v_S|
 R change (2)     |v_R|
 x delete      |v_x|
 D delete (3)     |v_D|
 X delete (2)     |v_X|
 Y yank (2)     |v_Y|
 p put      |v_p|
 J join (1)     |v_J|
 U make uppercase     |v_U|
 u make lowercase     |v_u|
 ^] find tag     |v_CTRL-]|
 I block insert     |v_b_I|
 A block append     |v_b_A|
Here is a list taken from stackoverflow lost somewhere in my browser history (thanks to the post author and to that great site build for knowledge):
select                                   v                                     
select row(s)                            SHIFT + v                             
select blocks (columns)                  CTRL  + v                             
indent selected text                     >                                     
unindent selected text                   <                                     
list buffers                             :ls                                   
open buffer                              :bN (N = buffer number)               
print                                    :hardcopy                             
open a file                              :e /path/to/file.txt                  
                                         :e C:\Path\To\File.txt                
sort selected rows                       :sort                                 
search for word under cursor             *                                     
open file under cursor                   gf                                    
  (absolute path or relative)                                                  
format selected code                     =                                     
select contents of entire file           ggVG                                  
convert selected text to uppercase       U                                     
convert selected text to lowercase       u                                     
invert case of selected text             ~                                     
convert tabs to spaces                   :retab                                
start recording a macro                  qX (X = key to assign macro to)       
stop recording a macro                   q                                       
playback macro                           @X (X = key macro was assigned to)    
replay previously played macro *         @@                                    
auto-complete a word you are typing **   CTRL + n                              
bookmark current place in file           mX (X = key to assign bookmark to)    
jump to bookmark                         `X (X = key bookmark was assigned to  
                                             ` = back tick/tilde key)          
show all bookmarks                       :marks                                
delete a bookmark                        :delm X (X = key bookmark to delete)   
delete all bookmarks                     :delm!                                 
split screen horizontally                :split                                
split screen vertically                  :vsplit                               
navigating split screens                 CTRL + w + j = move down a screen     
                                         CTRL + w + k = move up a screen       
                                         CTRL + w + h = move left a screen     
                                         CTRL + w + l = move right a screen    
close all other split screens            :only                                 

*  - As with other commands in vi, you can playback a macro any number of times.
     The following command would playback the macro assigned to the key `w' 100
     times: 100@w

** - Vim uses words that exist in your current buffer and any other buffer you 
     may have open for auto-complete suggestions.

Monday, February 10, 2014

Microcontroller Timer Frequency Calculator

Recently I needed to compute an appropriate frequency for a timer to proper modulate 38kHz with an ATTiny 13 . Made the computation and discover that the exact frequency cannot be reached with just the microcontroller without tampering with the OSCCAL and CLKPCE .
I needed to find the closest frequency to the target 38kHz (planned to use CTC on 2*38kHz = 76kHz, where CTC means: Clear Timer on Compare) that can be reached by using the timer (in hardware mode). Also I wanted to learn the basics for AngularJS . Below in this page is the resulted tool:

Usage Note: After you enter the base microcontroller clock source and the desired frequencies press the Compute Posibilities button. Look in the tables below for the resulted timer period, counter threshold and suggested prescalers configuration.

Note: Any feedback would be GREATLY appreciated. If you have suggestions how to improve this tool let me know. If you want to use this work in your site, please post a visible link to this blog page on your site page. Thank you!

UC Prescalers Timer

16 bit Timer

  • {{'1/'+Math.pow(2, sc.Scale)}}
  • {{'1/'+Math.pow(2, sc.Scale)}}
UC Base Frequency: Hz
Desired Frequencies:
  • Hz
Use this if not 0: ms
Least Common Multiple: Hz
Greatest Common Divisor: Hz

Sorting predicate = {{ResultsSort}}
Frequency (Hz) Timer Interval Timer Count UC Prescaler Timer Prescaler
{{result.FrequencyInHz}} {{result.TimerInterval}} {{result.TimerCount}} {{'1/'+Math.pow(2, result.UCPrescaler)}} {{'1/'+Math.pow(2, result.TimerPrescaler)}}
Frequency (Hz) Closest Frequency Error Timer Interval Timer Count UC Prescaler Timer Prescaler
{{result.FrequencyInHz}} {{result.FrequencyInHz + result.Error}} {{result.Error}} {{result.TimerInterval}} {{result.TimerCount}} {{'1/'+Math.pow(2, result.UCPrescaler)}} {{'1/'+Math.pow(2, result.TimerPrescaler)}}

Sunday, January 5, 2014

Tool for learning notes on guitar

Finally doing something that I always dreamed off: To play on guitar.

I made a tool that helped me A LOT to have an easy start: Learn Notes For Guitar executable (Windows with .Net Framework 4.5)

Below is a capture:

The user can select the correct answer by clicking on the proper button. After each 20 questions the program will switch the notation from the solfège to the letter and back.

The purpose of this application is to help the user to quickly learn:

  • the correspondence between the Solfège notation and the letter notation.
  • the position of notes on the first 12 frets of a guitar.

The application have the GNU General Public License, so everyone is permitted to use, copy and distribute verbatim copies of this application, but changing it is not allowed.

Any feedback is greatly appreciated.

Thursday, August 15, 2013

Flying Eagle

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