tag:blogger.com,1999:blog-17172185115298102002024-02-01T22:04:15.985-08:00Bits in rainBrankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.comBlogger89125tag:blogger.com,1999:blog-1717218511529810200.post-31063470183052203952018-12-21T12:02:00.000-08:002018-12-21T12:02:24.014-08:00Arrow functions in ReactJS<div dir="ltr" style="text-align: left;" trbidi="on">
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...<br />
<br /></div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-89403220161914426892018-10-29T13:53:00.002-07:002018-10-29T13:53:25.157-07:00Ruby: blank vs empty vs any vs nil vs...<div dir="ltr" style="text-align: left;" trbidi="on">
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.<br />
<br />
Here is a short version:<br />
<br />
- nil?<br />
Works on any object and checks is it nil or not.<br />
It returns true only for nil value.<br />
<br />
- empty?<br />
It does work on strings, hashes and arrays, and enumerators in general.<br />
It returns true if there are not elements in the array.<br />
It does not handle nil values, you have to check is object is nil and is object is empty.<br />
<br />
a.nil? && a.empty?<br />
<br />
- blank?<br />
It is Rails construct, not part of Ruby.<br />
It is a shortcut for false, empty of whitespace string.<br />
<br />
- present?<br />
Opposite of blank, part of Rails framework.<br />
<br />
- any?<br />
It works on arrays, hashes and sets.<br />
It checks is there is anything in the collection that can evaluate to true?<br />
It returns true if array has no elements except when it has nil values only.</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-50391565692874880122018-10-18T10:31:00.001-07:002018-10-18T10:31:39.561-07:00After a long time....<div dir="ltr" style="text-align: left;" trbidi="on">
It's been very busy year. I've changed the stack and now I am working in Ruby/Rails/ReactJS world.<br />
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!<br />
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!<br />
<br />
</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-61280517509443149842017-03-16T11:14:00.000-07:002017-03-16T11:14:55.761-07:00Orphaned sql users<div dir="ltr" style="text-align: left;" trbidi="on">
If you restore database,there are scenarios when our user gets orphaned.<br />
<br />
USE myDb<br />EXEC sp_change_users_login 'Report'<br />
<br />
<br />
<br />
<br />
<br />
<br />If you do have orphaned users, you can restore them if they exist but they are not linked to actual logins. <br />
<br />
EXEC sp_change_users_login 'Auto_Fix', 'user'</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-88251912769563513952017-01-17T12:05:00.004-08:002017-01-17T12:05:57.350-08:00How to share local disc when RDP<div dir="ltr" style="text-align: left;" trbidi="on">
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,<br />
<br />
<ol class="sbody-num_list" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; color: black; font-family: "Segoe UI", "Segoe UI Web", "Segoe UI Symbol", "Helvetica Neue", "BBAlpha Sans", "S60 Sans", Arial, sans-serif; font-size: 15px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal; letter-spacing: normal; margin: 0px; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<li style="box-sizing: border-box; margin-bottom: 12px;">Click<span class="Apple-converted-space"> </span><strong class="uiterm" style="box-sizing: border-box; font-weight: 700;">Start</strong>, point to<span class="Apple-converted-space"> </span><strong class="uiterm" style="box-sizing: border-box; font-weight: 700;">All Programs</strong><span class="Apple-converted-space"> </span>(or<span class="Apple-converted-space"> </span><strong class="uiterm" style="box-sizing: border-box; font-weight: 700;">Programs</strong>), point to<span class="Apple-converted-space"> </span><strong class="uiterm" style="box-sizing: border-box; font-weight: 700;">Accessories</strong>, point to<span class="Apple-converted-space"> </span><strong class="uiterm" style="box-sizing: border-box; font-weight: 700;">Communications</strong>, and then click<span class="Apple-converted-space"> </span><strong class="uiterm" style="box-sizing: border-box; font-weight: 700;">Remote Desktop Connection</strong>.</li>
<li style="box-sizing: border-box; margin-bottom: 12px;">Click<span class="Apple-converted-space"> </span><strong class="uiterm" style="box-sizing: border-box; font-weight: 700;">Options</strong>, and then click the<span class="Apple-converted-space"> </span><strong class="uiterm" style="box-sizing: border-box; font-weight: 700;">Local Resources</strong><span class="Apple-converted-space"> </span>tab.</li>
<li style="box-sizing: border-box; margin-bottom: 12px;">Define your disk as local disk for the connection.</li>
<li style="box-sizing: border-box; margin-bottom: 12px;"> Connect - it will be available in File Explorer as local disk.</li>
</ol>
<br />
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 <b>Edit </b>option did bring options for rdp and allowed me to add local disk to the connection.<br />
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.<br />
</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-3000502838948820802017-01-17T12:00:00.002-08:002017-01-18T15:54:59.212-08:00Windows 8 and .NET Framework 3.5<div dir="ltr" style="text-align: left;" trbidi="on">
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.<br />
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:<br />
<span style="font-family: Georgia,"Times New Roman",serif;"><span style="color: #990000;"><b><code style="background-color: #eff0f1; border: 0px none; font-size: 13px; margin: 0px; padding: 0px; white-space: inherit;"><br /></code></b></span></span>
<br />
<div style="text-align: left;">
<span style="font-family: Georgia,"Times New Roman",serif;"><span style="color: #990000;"><b><code style="background-color: #eff0f1; border: 0px none; font-size: 13px; margin: 0px; padding: 0px; white-space: inherit;">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.</code></b></span></span></div>
<br />
<br />
<pre class="default prettyprint prettyprinted" style="-webkit-text-stroke-width: 0px; background-color: #eff0f1; border: 0px; color: #393318; display: block; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal; letter-spacing: normal; margin: 0px 0px 1em; max-height: 600px; orphans: 2; overflow: auto; padding: 5px; text-align: left; text-indent: 0px; text-transform: none; widows: 2; width: auto; word-spacing: 0px; word-wrap: normal;"><code style="background-color: #eff0f1; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; margin: 0px; padding: 0px; white-space: inherit;"><span class="pln" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">DISM </span><span class="pun" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">/</span><span class="typ" style="border: 0px; color: #2b91af; font-size: 13px; margin: 0px; padding: 0px;">Online</span><span class="pln" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">/</span><span class="typ" style="border: 0px; color: #2b91af; font-size: 13px; margin: 0px; padding: 0px;">Enable</span><span class="pun" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">-</span><span class="typ" style="border: 0px; color: #2b91af; font-size: 13px; margin: 0px; padding: 0px;">Feature</span><span class="pln" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">/</span><span class="typ" style="border: 0px; color: #2b91af; font-size: 13px; margin: 0px; padding: 0px;">FeatureName</span><span class="pun" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">:</span><span class="typ" style="border: 0px; color: #2b91af; font-size: 13px; margin: 0px; padding: 0px;">NetFx3</span><span class="pln" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">/</span><span class="typ" style="border: 0px; color: #2b91af; font-size: 13px; margin: 0px; padding: 0px;">All</span><span class="pln" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">/</span><span class="typ" style="border: 0px; color: #2b91af; font-size: 13px; margin: 0px; padding: 0px;">LimitAccess</span><span class="pln" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">/</span><span class="typ" style="border: 0px; color: #2b91af; font-size: 13px; margin: 0px; padding: 0px;">Source</span><span class="pun" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">:</span><span class="pln" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">d</span><span class="pun" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">:</span><span class="pln" style="border: 0px; color: #303336; font-size: 13px; margin: 0px; padding: 0px;">\sources\sxs</span></code></pre>
<br /></div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-28794995738977358082016-03-23T22:37:00.001-07:002016-03-23T22:37:31.290-07:00Notepad++ and xml<div dir="ltr" style="text-align: left;" trbidi="on">
Notepad++ is a veritable well of usefulness. Everyday I am finding new nice features.<br />
Today, it's ability to collapse all nodes in xml document via keyboard shortcut.<br />
<br />
To collapse all nodes:<br />
ALT-0<br />
To expand all nodes:<br />
ALT-SHIFT-0<br />
To expand certain level only:<br />
ALT-SHIFT-2 (for level 2)<br />
To collapse on certain level only:<br />
ALT-1<br />
<br />
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.<br />
<br />
<br />
<br />
</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-42148416753282655462016-03-03T15:36:00.002-08:002016-03-03T15:36:55.766-08:00Visual Studio search broken after BizTalk installation<div dir="ltr" style="text-align: left;" trbidi="on">
I am not sure who exactly broke my Visual Studio 2013, either BizTalk ESB Toolkit or PowerTools for TFS broke Visual Studio search.<br />
Find in Files for a word would return summary only, without actual list of files to go and see - pretty useless.<br />
<br />
Solution is to fix default value for registry key:<br />
<br />
<span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Segoe UI', Helvetica, Garuda, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">HKEY_CLASSES_ROOT\</span><br />
<span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Segoe UI', Helvetica, Garuda, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">Wow6432Node\</span><br />
<span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Segoe UI', Helvetica, Garuda, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">CLSID\</span><br />
<span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Segoe UI', Helvetica, Garuda, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">{73B7DC00-F498-4ABD-AB79-D07AFD52F395}\</span><br />
<span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Segoe UI', Helvetica, Garuda, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">InProcServer32</span><br />
<br />
<span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Segoe UI', Helvetica, Garuda, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">to:</span><br />
<span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Segoe UI', Helvetica, Garuda, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"> <span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Segoe UI', Helvetica, Garuda, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"> </span></span><br />
<span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Segoe UI', Helvetica, Garuda, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;"><span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Segoe UI', Helvetica, Garuda, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\TextMgrP.dll</span> </span><br />
<br />
<span style="-webkit-text-stroke-width: 0px; background-color: white; color: #666666; display: inline !important; float: none; font-family: 'Segoe UI', Helvetica, Garuda, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">It was blank, I've entered the value and it worked without even restarting VS. </span></div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-1681588146043210572016-02-01T11:25:00.003-08:002016-02-01T11:25:35.513-08:00Unable to connect to proxy server error<div dir="ltr" style="text-align: left;" trbidi="on">
This error is very annoying because culprit is IE update.<br />
Regardless of what browser you are using, IE changes the settings for the proxy internally, blocking every browser. <br />
Solution is to go to Internet Options, then to Connections, LAN and then uncheck proxy option there.<br />
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. <br />
<br />
</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-23715306958128350512016-01-11T11:55:00.001-08:002016-01-11T11:55:08.662-08:00AppPool identity<div dir="ltr" style="text-align: left;" trbidi="on">
To be able to give App Pool identity permission on the folder, you need to search for:<br />
<br />
<span style="color: #990000;"><b>IIS AppPool\DefaultAppPool</b></span><br />
<br />
Otherwise you will not find it.<br />
</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-29756345901215292862015-12-07T11:07:00.000-08:002015-12-07T11:07:07.902-08:00Sql server database(s) size<div dir="ltr" style="text-align: left;" trbidi="on">
When you have many databases on the server, this is the fastest way to get their size in Mb:<br />
<br />
exec sp_helpdb;<br />
<br />
I wish it does break it down by data and transaction log like Disk Usage Report, it just gives the summary.<br />
<br />
<br />
<br />
<br /></div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-25203778628376650142015-11-25T10:31:00.005-08:002015-11-25T10:31:58.908-08:00Programming is difficult business. It should never be undertaken in ignorance - so true!<div dir="ltr" style="text-align: left;" trbidi="on">
From Douglas Crockford book, "JavaScript, The Good Parts":<br />
<br />
The amazing thing about JavaScript is that it is possible to get work done with it<br />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<br />know what you’re doing. <b>Programming is difficult business. It should never be<br />undertaken in ignorance."</b><br />
<br />
Isn't this the truth?!<b><br /></b><br />
<b> </b></div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-35699733363172054552015-08-12T11:58:00.002-07:002015-08-12T11:58:38.840-07:00TFS shelvesets<div dir="ltr" style="text-align: left;" trbidi="on">
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.<br />
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.<br />
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.<br />
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).<br />
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.<br />
</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-31715040072346104212015-07-09T15:22:00.001-07:002015-07-09T15:24:48.502-07:00Setting up Autofac<div dir="ltr" style="text-align: left;" trbidi="on">
Autofac is very nice DI container, but documentation on their site is lacking on specifics.<br />
This is how I set up Autofac in global.asax.cs:<br />
<br />
<br />
<code>
protected void Application_Start()<br /> {<br /> <span style="background-color: #fce5cd;"><span style="color: #444444;">RegisterAutofac();</span></span><br /><br /> AreaRegistration.RegisterAllAreas();<br />
GlobalConfiguration.Configure(WebApiConfig.Register);<br /> FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);<br /> RouteConfig.RegisterRoutes(RouteTable.Routes);<br /> BundleConfig.RegisterBundles(BundleTable.Bundles);<br />
<br />
}</code><br />
<code><br />
</code>
<br />
and then do registration of all the things you want injected:<br />
<br />
<code>
private void RegisterAutofac()<br /> {<br /> var builder = new ContainerBuilder();<br /> var config = GlobalConfiguration.Configuration;<br /> // all controllers are going to be built by autofac<br /> builder.RegisterApiControllers(Assembly.GetExecutingAssembly());<br /> // concrete implementation first, interface second<br /> <span style="background-color: #fce5cd;"><span style="color: #444444;">builder.RegisterType<ItemRepository>().As<IItemRepository>();</span></span><br /><br /> //<br /> var container = builder.Build();<br /> config.DependencyResolver = new AutofacWebApiDependencyResolver(container);<br />}<br />
</code>
</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-67657381372581447602015-07-02T14:35:00.003-07:002015-07-09T15:30:32.333-07:00Post vs Put vs Patch in Web API<div dir="ltr" style="text-align: left;" trbidi="on">
Debates rages on and on. Why, when and how.<br />
My 2 cents:<br />
<br />
<ol style="text-align: left;">
<li>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.</li>
<li>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.</li>
<li>PATCH - intended for partial updates, not really available yet.</li>
<li>POST - update - tricky one. Since we don't have PATCH yet that's the only alternative for partial updates as of now.</li>
</ol>
<br />
So something like this for POST:<br />
<br />
<code>
// POST: api/Items<br />[ResponseType(typeof(BudgetItem))]<br />public IHttpActionResult Post(BudgetItem item)<br /> {<br /> if (ModelState.IsValid)<br /> {<br /> _itemRepository.CreateItem(item);<br /> return CreatedAtRoute("DefaultApi", new { id = item.Id }, item);<br /> }<br /> else<br /> {<br /> return BadRequest(ModelState);<br /> }<br /> }</code><br />
<br />
<code>And for PUT:</code><br />
<br />
<code>// PUT: api/Items/5<br />public IHttpActionResult Put(int id, BudgetItem item)<br /> {<br /> if (!ModelState.IsValid)<br /> {<br /> return BadRequest(ModelState);<br /> }<br /> BudgetItem oldItem = _itemRepository.GetItem(id);<br /> if (oldItem == null)<br /> {<br /> _itemRepository.CreateItem(item);<br /> return CreatedAtRoute("DefaultApi", new { id = item.Id }, item);<br /> }<br /> else<br /> {<br /> _itemRepository.UpdateItem(item);<br /> return Ok(item);<br /> }<br /> }
<br />
<br />
</code>
</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-13680695615853240152015-06-10T15:40:00.001-07:002015-06-10T15:40:23.995-07:00400s vs 500s error codes in REST<div dir="ltr" style="text-align: left;" trbidi="on">
The best explanation I've seen so far:<br />
<br />
<a href="http://restcookbook.com/HTTP%20Methods/400-vs-500/">http://restcookbook.com/HTTP%20Methods/400-vs-500/</a><br />
<br />
<br />
<blockquote class="tr_bq">
<blockquote class="tr_bq">
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; color: #2c3e50; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 20px; margin: 0px 0px 10px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
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.</div>
</blockquote>
<blockquote class="tr_bq">
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; color: #2c3e50; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 20px; margin: 0px 0px 10px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;">
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.</div>
</blockquote>
</blockquote>
</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-67678237684215813722015-05-01T14:05:00.000-07:002015-07-02T14:37:44.026-07:00Removing item from dictionary in C#<div dir="ltr" style="text-align: left;" trbidi="on">
There is a method aptly named Remove:<br />
<pre style="font-family: Consolas, Courier, monospace !important; font-size: 13px; line-height: 17.5499992370605px; overflow: auto; padding: 5px; word-wrap: normal;"><span style="color: blue;">
</span></pre>
<pre style="font-family: Consolas, Courier, monospace !important; font-size: 13px; line-height: 17.5499992370605px; overflow: auto; padding: 5px; word-wrap: normal;"><span style="color: blue;"> public</span> <span style="color: blue;">bool</span> Remove</pre>
<pre style="font-family: Consolas, Courier, monospace !important; font-size: 13px; line-height: 17.5499992370605px; overflow: auto; padding: 5px; word-wrap: normal;"> (
TKey key
)</pre>
<br />
<span style="background-color: #fce5cd;"><span style="color: #444444;"> </span><span style="color: #444444;">dict.Remove(keyId)</span></span><br />
<br />
It will not raise the exception if key does not exist - handy!<br />
<br />
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).<br />
<br /></div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-64552744910383411862015-04-30T14:52:00.001-07:002015-04-30T14:52:43.683-07:00Another framework<div dir="ltr" style="text-align: left;" trbidi="on">
There is a framework called Vanilla-JS. No, there is NOT :) It's a joke people!<br />
<br />
http://vanilla-js.com/</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-41233764217482605762015-04-30T14:48:00.000-07:002015-04-30T14:48:04.911-07:00Sql Server user and login problem<div dir="ltr" style="text-align: left;" trbidi="on">
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.<br />
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...<br />
Just recreate the user :)</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-90977598121095425582015-01-13T09:58:00.001-08:002015-01-13T09:58:38.115-08:00Flat vs Realism<div dir="ltr" style="text-align: left;" trbidi="on">
Awesome, funny and well done:<br />
<br />
<a href="http://flatvsrealism.com/">http://flatvsrealism.com/</a><br />
<br /></div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-56786554180128648972014-12-08T11:04:00.000-08:002014-12-08T11:04:56.505-08:00When Google fails<div dir="ltr" style="text-align: left;" trbidi="on">
10 years ago, I wrote Windows Service, and I do remember I had to use instalutil.exe to install the thing and that was a pain in the neck to install it, figure out what was wrong, deinstall it and go again... I remember having a batch file to do all this.<br />
Turns out that there is a trick to do it easily - you use windows console app instead of windows service, and check in Main is this Environment.UserInteractive or not. That way you can attach to the process to debug it and iron out all the issues, and still have your windows service when deployed. In other words, have your cake and eat it.<br />
And why Google failure? You can not search for this trick until you know it is possible. Many many people use installutil and forums and StackOverflow are full of answers to that, but to find out console app masquerading as service, you have to know about it, then you will find couple of nice blogs where this is explained.<br />
So back to Stanislaw Lem story - to ask proper question, you have to know most of the answer already. </div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-20773539143956620832014-12-08T10:31:00.004-08:002014-12-08T10:31:57.885-08:00Order of sections in configuration files matters<div dir="ltr" style="text-align: left;" trbidi="on">
Looks like order of sections in web.config (or app.config for that matter) matters - you can not have appSettings before configuration section, or it ConfigurationManager will not read it.</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-8299317997413245552014-11-11T13:30:00.000-08:002014-11-11T13:30:06.187-08:00Fiddle, fiddler on the roof<div dir="ltr" style="text-align: left;" trbidi="on">
Fiddles are scaled down environment accessible via web, used to testing, demonstration, or just to share snippets. They usually have a window split for code, markup, output... Very handy.<br />
<br />
I've used JSFiddle a lot since it allows you to add easily many popular frameworks, like jQuery, KnockoutJS, Prototype, AngularJS and even allow you to specify how you will run your code (onReady, onLoad...).<br />
<br />
<br />
<a href="http://www.jsfiddle.net/"> http://www.jsfiddle.net</a><br />
<br />
It has echo API to simulate API calls.<br />
<br />
Then there is Plunker - it's grown up sibling. It has link to GitHub and ability to split code into multiple files. I really liked it, and my only issue is that they succumbed to Web 2.0 fad and named the site by skipping vowels, making me mistype the site name _every_single_time.<br />
<br />
<a href="http://plnkr.co/">http://plnkr.co/</a><br />
<br />
But beside that unfortunate name, it's really useful tool, good for fast prototyping.<br />
<br />
And last one I've found is SQL Fiddle:<br />
<br />
<a href="http://www.sqlfiddle.com/">http://www.sqlfiddle.com/</a><br />
<br />
<br />
It has a list of supported databases (mySQL, SQL Server, Oracle and Postgress) that you can target. In one pane, you can create your db schema, in second pane, you can run your queries.<br />
<br />
It supports OpenId login and accepts donations, although I couldn't find a link for donating. Looks like site is work in progress still.<br />
<br />
<br /></div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-8380724473730468952014-10-28T10:43:00.001-07:002014-10-28T10:46:34.707-07:00classList and className<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
JavaScript is a language full of surprises. <br />
<br />
Every DOM element always had className property, that was nothing but white space separated list of classes. That was not the most convenient so JQuery encapsulated manipulation of that with addClass and removeClass methods.<br />
<br />
Now, new browsers are supporting classList API, allowing JavaScript to add and remove classes from the DOM elements easily, without JQuery. This is important for mobile browsers, where everything should be parred down if possible.<br />
<br />
So classList is a list of classes, with length property and this list of methods for manipulation:<br />
<ul>
<li>add (class)</li>
<li>contains (class)</li>
<li>item (index)</li>
<li>remove (class)</li>
<li>toggle (class) </li>
</ul>
</div>
Looks like certain browsers allows even to pass multiple classes to add, separate by space.<br />
<br />
Of course, older IE does not support this, only IE 10 and up. <br />
<div>
<br />
This should do for a check:<br />
<br />
<pre><code><span class="kwd">if</span><span class="pun">(</span><span class="str">'classList'</span><span class="pln"> </span><span class="kwd">in</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">createElement</span><span class="pun">(</span><span class="str">'elem'</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></pre>
<pre> </pre>
<pre> <code><span class="pln">document.getElementById('elem').classList.add('newClass');</span></code> </pre>
<pre><code><span class="pln">}</span></code></pre>
<pre><code><span class="pln">else</span></code></pre>
<pre><code><span class="pln">{</span></code></pre>
<pre><code><span class="pln"> </span></code></pre>
<pre><code><span class="pln"> document.getElementById('elem').className += " newClass";
</span></code></pre>
<pre><code><span class="pln">}</span></code></pre>
</div>
</div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0tag:blogger.com,1999:blog-1717218511529810200.post-35808945384932501882014-10-24T14:32:00.001-07:002014-10-24T14:32:51.507-07:00Debugger for media queris<div dir="ltr" style="text-align: left;" trbidi="on">
https://github.com/bueltge/Simple-Media-Queries-Debugging<br />
<br /></div>
Brankahttp://www.blogger.com/profile/00539384663732441045noreply@blogger.com0