Setting up Redis on Windows with Chocolatey

by Victor 22. January 2016 20:25
Step 1
Install chocolately (https://chocolatey.org/)
Open cmd prompt as Administrator
Run the following:
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

Step 2
Install redis using chocolatey
Open cmd prompt as Administrator
Run the following:
choco install redis-64

Step 3
Set up redis to run as a service (if it didn't set it up automatically, check local services if "Redis" exists)
Open cmd prompt as Administrator
Run the following:
cd C:\ProgramData\chocolatey\lib\redis-64
redis-server --service-install "redis.windows-service.conf"

If the service won't start, open redis.window-service.conf and make sure the path in the logfile setting uses forward slash (/) not back slash (\). Also make sure the "logs" folder exists at C:\ProgramData\chocolatey\lib\redis-64\logs.
If you need to uninstall, run:
redis-server --service-uninstall
 
Here's a link to a free Redis explorer:
http://redisdesktop.com

Tags: , ,

.NET | Software Development | Web Development

AngularJS - Browser autocomplete not updating model

by Victor 18. December 2015 00:15

This doesn't apply just to AngularJS but to any js framework that uses models. Some browsers (Safari, Chrome) have been known not to emit the change event when a user fills in a field using the autocomplete feature of the browser. Use this polyfill to have the change event fired

https://github.com/tbosch/autofill-event

This still won't be enough to get the view value back into the model. But, now that you have an event to hook into you, you can use a directive like this to transfer the value from the view to the model.

// http://stackoverflow.com/a/23919364/867891
app.directive('autoFillSync', ['$log', function ($log) {
return {
require: 'ngModel',
link: function (scope, elem, attrs, model) {
elem.change(function (event) {
$log.debug('autoFillSync.link.change');
model.$setViewValue(elem.val());
})
}
};
}]);
 
Then use the directive on your input element
 
<input type='text' ng-model='city' auto-fill-sync />
 
This solution was inspired by this StackOverflow answer:
http://stackoverflow.com/a/23919364/867891

Tags: , ,

AngularJS | javascript | jQuery | Web Development

Useful extensions for Visual Studio

by Victor 21. October 2015 01:37

Web Compiler:
The easiest and most powerful way to compile LESS, Scss, JSX and CoffeeScript files directly within Visual Studio or through MSBuild.
https://visualstudiogallery.msdn.microsoft.com/3b329021-cd7a-4a01-86fc-714c2d05bb6c

Image Optimizer:
Lossless optimization of JPEG, PNG and Gifs - including animated Gifs
https://visualstudiogallery.msdn.microsoft.com/a56eddd3-d79b-48ac-8c8f-2db06ade77c3

Bundler & Minifier:
Adds support for bundling and minifying JavaScript, CSS and HTML files in any project.
https://visualstudiogallery.msdn.microsoft.com/9ec27da7-e24b-4d56-8064-fd7e88ac1c40

Web Analyzer:
Provides static analysis directly in Visual Studio for JavaScript, TypeScript, JSX, CSS and more
https://visualstudiogallery.msdn.microsoft.com/6edc26d4-47d8-4987-82ee-7c820d79be1d

Querying BsonIgnore fields in MongoDB using LINQ

by Victor 8. October 2015 22:27

If you have a BsonIgnoreIfDefault attribute on a property, that property will not get serialized and persisted to your MongoDB database if its value is the default for its type. The default for reference types is null. The default for primitives are: int/double/long/decimal = 0, bool = false.

 

Now, let's take a look at a use case. Here, we want MiddleName to never be null, and to be an empty string if it's never set.

 

public class Person
{
    public string FirstName { get;set; }

    [BsonIgnoreIfDefault]
    [BsonDefaultValue("")]
    public string MiddleName
    {
        get { return _middleName; }
        set { _middleName = value == null ? "" : value; }
    }
    private string _middleName = "";
}

var john = new Person { FirstName = "John" };
PersonRepository.Add(john);

PersonRepository.Where(p => p.FirstName == "John", p.MiddleName == "");

 

In this case, the query will not return anything because an empty string is the default for middle name and we told the serializer to ignore MiddleName if it's the default. So, in the database, this Person object is saved without a MiddleName field. In order to query for any Person that does not have a MiddleName, you have to use null, like so:

 

PersonRepository.Where(p => p.FirstName == "John", p.MiddleName == null);

Tags:

.NET | C# | MongoDB

Formatting a phone number in .NET

by Victor 8. October 2015 22:24

If you save your phone numbers as only numbers, eg., 5615551234then you can use this code to format it for display:

 

string.Format("{0:###-###-####}",long.Parse("5615551234"));

 

which will output 561-555-1234. Neat huh?

Tags: , ,

.NET | ASP.NET | C# | Software Development

ASP.NET Bundling of AngularJS templates

by Victor 7. October 2015 23:47

Saving this link here for future reference. Great post on how to add your AngularJS templates to ASP.NETs bundling and minification process.

 

http://blog.scottlogic.com/2014/08/18/asp-angular-optimisation.html

Tags: , , ,

AngularJS

Easy Javascript Unit Testing (QUnit, Jasmine, Mocha) In Visual Studio

by Kevin 3. October 2014 20:34

I recently found the need to do my JavaScript unit testing inside of my IDE(Visual Studio). I mean who wants to carry around two devices because one has features the other doesn't when you can have a single device do both?  So after struggling with finding a couple of bad eggs I came across the golden egg Chutzpah.  I found a nice post explaining how to hook it up so instead of writing a wall of text here I'm going to give you two URL's so you can go ahead and get your environment setup quickly and read the fluff later.

 

Tutorial: http://codeforcoffee.org/setting-up-angular-js-jasmine-and-karma-in-visual-studio/ (Setting it up with AngularJS)

Chutzpah Git: https://github.com/mmanela/chutzpah 

Tags: , , ,

javascript | Visual Studio | Unit Testing

Rename database in MongoDB

by Victor 27. September 2014 00:42

db.copyDatabase('OldDatabaseName, 'NewDatabaseName');

use OldDatabaseName

db.dropDatabase();

Tags:

MongoDB

LINQToExcel OLE DB Excel Provider Column Types

by Kevin 7. August 2014 02:51

Ran into an issue where the Excel OLE DB provider was saying a column type was unable to be set returning null for the columns values.  This was happening because the first 8 values read for the given worksheet were empty so the column type couldn't be set by the OLE DB provider.  Obviously this can happen to anyone, but in my special case of using LINQToExcel if you use the method called ExcelWorkSheetNoHeader() it removes the header row as a type and returns the whole excel file as a text values with the type of strings.

This will allow the provider to properly parse your excel file rather than returning empty columns because a data type couldn't be properly set.

 

That's it problem solved!

Hopefully that helped someone else who was stuck on this problem as well.

Tags: ,

.NET | C# | Visual Studio

Visual Studio javascript extensions

by Victor 23. July 2014 20:39

This one adds AngularJS intelisense:

http://madskristensen.net/post/angularjs-intellisense-in-visual-studio-2012

 


This one adds outlining for regions, brackets, braces, and comments:

 

http://visualstudiogallery.msdn.microsoft.com/4be701d8-af03-40a4-8cdc-d2add5cde46c?SRC=VSIDE

 

Tags: , ,

Powered by BlogEngine.NET 2.5.0.6

About Us

Wuji Touch is a software consulting firm based in Delray Beach, Florida. We specialize in Microsoft technologies, but we also have experience with Progress OpenEdge, iOS, and Android development. This is our blog. These are the tales of the pains and pleasures we experience daily in our journey through 1s and 0s.

Month List