Saturday, April 18, 2015

WinDbg strikes back

Typical problems with winDbg:

.loadby sos mscorwks
Unable to find module 'mscorwks'


for .NET framework 4+ use
.loadby sos clr

SOS does not support the current target architecture.


I see this exception when I run multiple commands because dump was created on 64 bit arch for 32 bit process (I still recommend taking dump using 32 bit Task Manager that is located under C:\Windows\SysWOW64).
!wow64exts.sw
Helps to run some commands like
!clrstack

Tuesday, February 24, 2015

Universal Google Analytics Event Tracking Problems

I keep receiving a following error under Google GA Debugger plugin in Chrome:

Command ignored. Unknown target: undefined

In Google Analytics (GA) I do not see any events. I am using Universal Google Analytics and I attached it to a page thru Google Tag Manager (GTM).
When I change in GTM Tag Type from Universal Anaytics to Custom HTML Tag and paste manually GA code everything works.

Solution to the problem is to set a Tracker Name in GTM config

and raise events in a following way (Tracker Name is set to internalTrackerName):
ga('internalTrackerName.send', 'event', 'button', 'click', 'View Bookings');

Saturday, February 21, 2015

Python after years

Recently I've been installing python on Windows. I haven't done it for few years now. I was surprised that msi installer by default installs pip with its dependencies. It also comes with a basic IDE. This is really nice. Pip seams to be a standard now. But definitely there are few things that didn't change. A quick look at Django code:

def b85decode(b):
        _b85dec = [None] * 256
        for i, c in enumerate(iterbytes(_b85alphabet)):
            _b85dec[c] = i

        padding = (-len(b)) % 5
        b = b + b'~' * padding
        out = []
        packI = struct.Struct('!I').pack
        for i in range(0, len(b), 5):
            chunk = b[i:i + 5]
            acc = 0
            try:
                for c in iterbytes(chunk):
                    acc = acc * 85 + _b85dec[c]
            except TypeError:
                for j, c in enumerate(iterbytes(chunk)):
                    if _b85dec[c] is None:
                        raise ValueError(
                            'bad base85 character at position %d' % (i + j)
                        )
                raise
            try:
                out.append(packI(acc))
            except struct.error:
                raise ValueError('base85 overflow in hunk starting at byte %d'
                                 % i)

Ech, not much changed since I was looking at python programming style years ago. Its not language fault, it is more about how well people are writing open source code. How much does it take to understand what a method above is doing - the method name is a great help, but to understand implementation takes more than few minutes, and it is far more time than few seconds.

Wednesday, January 28, 2015

Latency Numbers Every Programmer Should Know

I am not sure if 1% of programmers know it, but it is a great reference, kudos to Jeff Dean and Peter Norvig: Latency Comparison Numbers
L1 cache reference                            0.5 ns
Branch mispredict                             5   ns
L2 cache reference                            7   ns             14x L1 cache
Mutex lock/unlock                            25   ns
Main memory reference                       100   ns             20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy              3,000   ns
Send 1K bytes over 1 Gbps network        10,000   ns    0.01 ms
Read 4K randomly from SSD*              150,000   ns    0.15 ms
Read 1 MB sequentially from memory      250,000   ns    0.25 ms
Round trip within same datacenter       500,000   ns    0.5  ms
Read 1 MB sequentially from SSD*      1,000,000   ns    1    ms  4X memory
Disk seek                            10,000,000   ns   10    ms  20x datacenter roundtrip
Read 1 MB sequentially from disk     20,000,000   ns   20    ms  80x memory, 20X SSD
Send packet CA->Netherlands->CA     150,000,000   ns  150    ms
 
Notes
-----
1 ns = 10-9 seconds
1 ms = 10-3 seconds
* Assuming ~1GB/sec SSD

Saturday, January 24, 2015

Adding already existing project to GitHub using command line

A typical problem that I often have, playing with various repositories and frameworks is how to add already existing project to a remote repository. In this tutorial I show how to do it for a GitHub mostly by using a command line. I assume that git environment is already set up and that there is already a working environment that is able to push/pull data from GitHub. For windows the only thing that one has to do is to install GitHub for windows.
  • 1. Create a new repository in GitHub - it means go to GitHub page, login, add a new repository. This is the only step that requires doing something not in a command line. I will create a my-app repository, so it will be available under https://github.com/sagasu/my-app
  • 2. Open a git shell.
  • 3. Navigate to a project directory. Actually you have to 'cd my-app', and be in a directory with a project files.
  • 4. git init
  • 5. git add .
  • 6. git commit -m 'message'
  • 7. git remote add my-app https://github.com/sagasu/my-app
  • 8. git push -u my-app master

Saturday, December 13, 2014

Windows Update error 0x80073712

I was not able to install Windows 8.1 Update for x64-based Systems (KB2919355), For a last few months. It's not like I was trying to do it everyday, simply when I noticed that I am not able to install it I tried again after few weeks. Unfortunately this update is required for me to install other update that is required to play with new .NET 4.6 preview framework (link to Visual Studio 2015 download, because that's the place that allowed framework to be downloaded).

What didn't work


Using File System Checker to repair missing or corrupted system files

sfc /scannow

Running in cmd as Admin following commands

net stop wuauserv
net stop bits
net stop cryptsvc
ren %systemroot%\System32\Catroot2 Catroot2.old
net start cryptsvc
ren %systemroot%\SoftwareDistribution SoftwareDistribution.old
regsvr32 wuapi.dll
regsvr32 wuaueng.dll
regsvr32 wucltux.dll
regsvr32 wups2.dll
regsvr32 wups.dll
regsvr32 wuwebv.dll
net start bits
net start wuauserv
net start Eventlog
exit

What resolved the problem


Running in cmd as Admin following commands

DISM.exe /Online /Cleanup-image /Scanhealth

DISM.exe /Online /Cleanup-image /Restorehealth
DISM process failed few times when I run it.

Monday, December 8, 2014

Run psake task from powershel


I constantly keep forgeting this command, because I use it once per few months. Here is how to trigger a psake task from pshell:
.\psake.ps1 "<fileWithTasks.ps1>" "<taskName>"

Some example:
.\psake.ps1 "default.ps1" "UpdateDatabase"