Welcome...



...All those moments will be lost in time, like tears in rain....

- soliloquy from Blade Runner


Bits and bytes do get lost, awash in the rain of data flow that is Internet. They slip away from us, never to found again... some of them will be captured here, many more will not... like tears in rain...



Friday, December 21, 2018

Arrow functions in ReactJS

 Should I say that searching google for something you don't know what is it, going only with syntax is hard? Coming from C# world construct "=>" is lamda, in ReactJS world is "arrow function", doh. Yeah, make sense of course, more than lamda...

Monday, October 29, 2018

Ruby: blank vs empty vs any vs nil vs...

Sometimes having too many good things is not really good for you. So many ways to test for existence of the object or array that it's confusing.

Here is a short version:

- nil?
 Works on any object and checks is it nil or not.
 It returns true only for nil value.

- empty?
 It does work on strings, hashes and arrays, and enumerators in general.
 It returns true if there are not elements in the array.
 It does not handle nil values, you have to check is object is nil and is object is empty.

 a.nil? && a.empty?

 - blank?
 It is Rails construct, not part of Ruby.
 It is a shortcut for false, empty of whitespace string.

- present?
Opposite of blank, part of Rails framework.

- any?
 It works on arrays, hashes and sets.
 It checks is there is anything in the collection that can evaluate to true?
 It returns true if array has no elements except when it has nil values only.

Thursday, October 18, 2018

After a long time....

  It's been very busy year. I've changed the stack and now I am working in Ruby/Rails/ReactJS world.
 To say that things are different is understatement! From working on Mac to using whole new ecosystem of tools and acronyms to feeling of being a noob ... It's not being easy!
 However, light is starting to shine from the end of the tunnel and I do feel better, enough to start thinking about my blog again. There is evens that I can start sharing again, so let's go back to having fun while learning again!

  

Thursday, March 16, 2017

Orphaned sql users

 If you restore database,there are scenarios when our user gets orphaned.

USE myDb
EXEC sp_change_users_login 'Report'






If you do have orphaned users, you can restore them if they exist but they are not linked to actual logins.

EXEC sp_change_users_login 'Auto_Fix', 'user'

Tuesday, January 17, 2017

How to share local disc when RDP

 Most of the time, copy-paste works seamlessly, until data amount or file is too big to copy. In that case, sharing local disk is perfect solution,

  1. Click Start, point to All Programs (or Programs), point to Accessories, point to Communications, and then click Remote Desktop Connection.
  2. Click Options, and then click the Local Resources tab.
  3. Define your disk as local disk for the connection.
  4.  Connect - it will be available in File Explorer as local disk.

 Wrinkle I encountered was that I had .RDP shortcuts already defined (from Azure) and bringing up properties didn't show me actual remote connection properties. But right click and Edit option did bring options for rdp and allowed me to add local disk to the connection.
 Connection is not permanent - if you stay connected to the machine for a long time, disk can disappear after a while, and should be defined again.
 

Windows 8 and .NET Framework 3.5

 I had an interesting problem - brand new Windows 8.1 with .NET framework 4.5 installed was not able to connect o windows update to download Framework 3.5. Reason for old framework - SQL Server 2014 requires it.
 After lots of googling, and experimenting, I've finally found option to do silent install, meant for situations where you don't have internet connection, and that worked:


LimitAccess switch is the key to signal Windows to use local dvd (or local ISO in my case) and not connect to internet for that.


DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:d:\sources\sxs

Wednesday, March 23, 2016

Notepad++ and xml

 Notepad++ is a veritable well of usefulness. Everyday I am finding new nice features.
 Today, it's ability to collapse all nodes in xml document via keyboard shortcut.

 To collapse all nodes:
 ALT-0
 To expand all nodes:
 ALT-SHIFT-0
 To expand certain level only:
 ALT-SHIFT-2 (for level 2)
 To collapse on certain level only:
 ALT-1

 Of course, you do need to install XML plugin to manipulate XML documents, then you can format it and validate and do all kinds of useful things with it.



Thursday, March 3, 2016

Visual Studio search broken after BizTalk installation

 I am not sure who exactly broke my Visual Studio 2013,  either BizTalk ESB Toolkit or PowerTools for TFS broke Visual Studio search.
 Find in Files for a word would return summary only, without actual list of files to go and see - pretty useless.

 Solution is to fix default value for registry key:

HKEY_CLASSES_ROOT\
Wow6432Node\
CLSID\
{73B7DC00-F498-4ABD-AB79-D07AFD52F395}\
InProcServer32

to:
  
C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\TextMgrP.dll

It was blank, I've entered the value and it worked without even restarting VS. 

Monday, February 1, 2016

Unable to connect to proxy server error

  This error is very annoying because culprit is IE update.
   Regardless of what browser you are using, IE changes the settings for the proxy internally, blocking every browser.
 Solution is to go to Internet Options, then to Connections, LAN and then uncheck proxy option there.
  One of those issues that underlies why Microsoft was sued for antitrust violations. I almost never use IE (except for testing) and yet, this silent update blocks everything else.

 

Monday, January 11, 2016

AppPool identity

 To be able to give App Pool identity permission on the folder, you need to search for:

  IIS AppPool\DefaultAppPool

 Otherwise you will not find it.
 

Monday, December 7, 2015

Sql server database(s) size

 When you have many databases on the server, this is the fastest way to get their size in Mb:

 exec sp_helpdb;

I wish it does break it down by data and transaction log like Disk Usage Report, it just gives the summary.




Wednesday, November 25, 2015

Programming is difficult business. It should never be undertaken in ignorance - so true!

From Douglas Crockford book, "JavaScript, The Good Parts":

The amazing thing about JavaScript is that it is possible to get work done with it
without knowing much about the language, or even knowing much about programming. It is a language with enormous expressive power. It is even better when you
know what you’re doing. Programming is difficult business. It should never be
undertaken in ignorance."


Isn't this the truth?!

 

Wednesday, August 12, 2015

TFS shelvesets

 TFS is a strange beast - some things are so easy to do, some things are unbelievably hard. And it's not easy to find answers either when you are stuck.
 Case in the point - making shelveset is very easy - you just have to click on Shelve button instead of Checkin, name it (paying attention to avoid certain characters in the naming, as usual on windows) and that's it.
 Finding a shelveset? Before latest TFS, you had to go to Files menu, then to Source Control, then to Find, then to Find Shelvesets. Not exactly path that you would expect. So, in the latest version, they added it to Pending Changes screen, under Actions link, much handier.
 That allows you to see your own shelvesets. If you want to find other people shelvesets, then nature of the beast shows up. It's hard. You have to know exact name of the person that made shelveset, and search box will not accept partial name, or not complete name (and that can include  things like company name, status etc, whatever TFS admin / IT set up).
 Only workaround I have found so far is to use wildcard "*" instead. That will show you ALL shelvesets from everybody, and you can then look for the one you want, and see exact spelling of the user name there for the next search.
 

Thursday, July 9, 2015

Setting up Autofac

 Autofac is very nice DI container, but documentation on their site is lacking on specifics.
 This is how I set up Autofac in global.asax.cs:


  protected void Application_Start()
   {
     RegisterAutofac();

     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
      
  }



and then do registration of all the things you want injected:

private void RegisterAutofac()
 {
   var builder = new ContainerBuilder();
   var config = GlobalConfiguration.Configuration;
   // all controllers are going to be built by autofac
   builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
   // concrete implementation first, interface second
   builder.RegisterType<ItemRepository>().As<IItemRepository>();

   //
   var container = builder.Build();
   config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
}

Thursday, July 2, 2015

Post vs Put vs Patch in Web API

 Debates rages on and on. Why, when and how.
 My 2 cents:

  1. POST- create if you don't know resource location, but leaving it to the server to determine it and send back location of new resource to you in the header.
  2. PUT - hm, it should really be called replace. It should either create resource on specified url (by client!) or completely update it, no partial updates here.
  3. PATCH - intended for partial updates, not really available yet.
  4. POST - update - tricky one. Since we don't have PATCH yet that's the only alternative for partial updates as of now.

So something like this for POST:

// POST: api/Items
[ResponseType(typeof(BudgetItem))]
public IHttpActionResult Post(BudgetItem item)
 {
   if (ModelState.IsValid)
     {
        _itemRepository.CreateItem(item);
        return CreatedAtRoute("DefaultApi", new { id = item.Id }, item);
     }
   else
      {
      return BadRequest(ModelState);
      }
  }


And for PUT:

// PUT: api/Items/5
public IHttpActionResult Put(int id, BudgetItem item)
  {
     if (!ModelState.IsValid)
       {
           return BadRequest(ModelState);
        }
     BudgetItem oldItem = _itemRepository.GetItem(id);
     if (oldItem == null)
        {
           _itemRepository.CreateItem(item);
           return CreatedAtRoute("DefaultApi", new { id = item.Id }, item);
        }
      else
       {
          _itemRepository.UpdateItem(item);
          return Ok(item);
       }
   }

Wednesday, June 10, 2015

400s vs 500s error codes in REST

 The best explanation I've seen so far:

http://restcookbook.com/HTTP%20Methods/400-vs-500/


4xx codes are used to tell the client that a fault has taken place on THEIR side. They should not retransmit the same request again, but fix the error first.
5xx codes tell the client something happened on the server and their request by itself was perfectly valid. The client can continue and try again with the request without modification.

Friday, May 1, 2015

Removing item from dictionary in C#

  There is a method aptly named Remove:

  public bool Remove
  (
 TKey key
  )

  dict.Remove(keyId)

 It will not raise the exception if key does not exist -  handy!

  If you do want to check existence of the key anyways, it will return false if it  is unable to find a key (or unable to remove it for some other odd reason).

Thursday, April 30, 2015

Another framework

 There is a framework called Vanilla-JS. No, there is NOT :) It's a joke people!

 http://vanilla-js.com/

Sql Server user and login problem

 I run into the issue of having user and login disconnect in my local database. What happened was that I restored database from testing server, and that disconnected user and login. They both existed in database, but user was of type SQL Server user WITHOUT Login, even if that login right there.
 After lots of searching, solution that works was - DROP THE USER and Recreate User. That will give you chance to relink them (SID update) and it works. All other solutions just didn't work - I couldn't find any orphaned users, I couldn't do Alter user...
 Just recreate the user :)