Author Archives: Adam Z

Starting Xamarin with MVVM binding in Code

Create your view model which implements INotifyPropertyChanged:

public class ViewModel : INotifyPropertyChanged
private string someValue;
public event PropertyChangedEventHandler PropertyChanged;

public string SomeValue
get { return someValue; }
if (someValue!= value)
someValue= value;

protected void OnPropertyChanged(string propertyName)
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));

Bind it to your view:

var searchBar = new SearchBar();
searchBar.SetBinding(SearchBar.TextProperty, new Binding("SearchText", BindingMode.TwoWay));

If you need to retrieve your view model on some action:

var viewModel = BindingContext as ViewModel;
// update your viewModel then reassign to BindingContext
BindingContext = viewModel;

Elixir Data Types Summary

  • Numbers: Integers and Floats
  • Atoms: :named_constant
  • Binaries: strings are binaries. <<104>> is “h”
  • Maps: %{key: value}. Can use strings or atoms for keys. But only atoms allow map.key; else use map[key]
  • Tuples: {value,value…}. To access – elem(tuple, 0). To add: put_elem(tuple, 0, “value”)
  • Lists: [value, value…]
  • Functions: fn(args) -> … end. To call: fn.(args)
  • Character Lists: ‘h’ is [104]
  • Keyword Lists: [{:atom, value}…] == [atom: “value”,…]
  • Structs: %{key: value}
  • Range: 0..42
  • Regex: ~r/pattern/

Setting up Elixir with Atom on Linux

Sublime is a pretty nice editor for working with Elixir, but I just can’t get the autocomplete plugin to work. So, giving Atom a try.

Install the following packages:

atom-elixir –
language-elixir –
linter (apm install linter) –
linter-elixirc –
script –

I use script to build within Atom (shift-ctrl-b). The only issue is that it seems to use the top-level folder of your project as a base path. So, if you try to do something like Code.load_file(“file.exs”) in one of your nested directories, it’ll try to load it from the top level directory.

Addendum for Mac
brew install elixir
brew install erlang

Set elixir path for autocomplete-elixir (if using Atom):

Parsing jQuery Unobtrusive Validation Parameters

Client-side parsing of unubtrusive jQuery validation parameters. Assuming we are setting up an unobtrusive validator named “validatorname” and want to pass “parameterfromserver” from the the server:

$.validator.unobtrusive.adapters.add('validatorname', ['parameterfromserver'], function(options) {
	options.rules['validatorname'] = {
		parameterfromserver: options.params['parameterfromserver']
	options.messages['validatorname'] = options.message;
$.validator.addMethod('validatorname', function(value, element, parameters) {
	var hereIsOurParameter = parameters.parameterfromserver;

MSBuild with C# 6 and UpgradeTemplate.xaml

If you use UpgradeTemplate for your MSBuild, getting it to work with C# 6 can be a little tricky.
First, we need to set the tools version by passing these parameters to MSBuild:
/tv:14.0 /p:VisualStudioVersion=14.0

This, however, may not change the MSBuild version used to run your build. TFS Build server may still use the MSBuild from your .Net framework folder (C:\Windows\Microsoft.NET\Framework64\v4.0.30319). To verify the location of your MSBuild, used by the TFS, open one of your completed builds, and check the Diagnostics tab. It should show the MSBuild.exe forlder in the “Run TfsBuild for Configuration Folder” step.

To fix this, we need to explicitly set the ToolPath for the MSBuild template.
Open the UpgradeTemplate.xaml in Visual Studio
Right click on “Run TfsBuild for Configuration” -> Properties
Set the ToolPath property to point to your msbuild: “C:\Program Files (x86)\MSBuild\14.0\Bin\”
Don’t forget the quotation marks.

While you’re at it, check out Target Framework Migrator – it’s a Visual Studio extension, which helps update all of your projects to target a specific .Net version. Can be quite helpful when you have a lot of projects.

Linting Elixir with Credo

Got excited about Credo on a recent episode of The Elixir Fountain.
Seems to work quite well. Though, I couldn’t get the Atom plugin to work. But the command line works great.

Github repo for Credo provides all of the instructions to install.
I installed it as stand alone:

$ git clone [email protected]:rrrene/credo.git
$ cd credo
$ mix deps.get
$ mix
$ mix archive.install

Also had to install bunt, since it is a dependency:
git clone
cd bunt
mix archive.install

After that, run “mix yourElixirFile.exs” and it will lint your file with something like this:

Credo Output

Analyzing Git with GitInspector

Pretty cool tool for analyzing your Git repos – GitInspector. Thanks to @zachdevelop for discovering, figuring out how to use, and sharing it.

Here’s a sample command for analyzing some C#, JavaScript, .NET web services, ASP.Net, and F#:


py C:\pathToGitInspector\ --format=html -r -m --file-types="cs,js,asax,ascx,asmx,aspx,cshtml,fs" | Out-File C:\git_output.html

Mac: --format=html -f="coffee,rb,js,json,feature,haml,erb,html" -r > inspector.html

Elixir Learning Resources

As I recently started learning Elixir, I stumbled upon some cool learning material. Here are some links:

Some twitter accounts to follow:
@josevalim РJos̩ Valim Рcreator of Elixir