Work

Git

Git: Using repositories/branches for source separation

0

Git Logo

Git is a wonderful and easy way to manage your source code of any kind of project and using GitHub as the central is a smart move. Especially when you developing a web project it is always good to have a staging site where you can see the latest stage of the development in a production-like environment.

But what if your company wants you to separate the source code into development, staging and production stages? You can use branches even completely separated repositories to achieve that.

In my current project I’ve set up this branching system with a single repository:

  • master
  • protected/development
  • protected/staging
  • protected/production
  • [...] all other branches from my team

Note: the prefix protected/ is a valid prefix for branch names

The workflow is:

  • everything that is in master will be pushed periodically to protected/development
  • as soon as changes in protected/development are detected, the development site will be deployed
  • every morning the latest source from protected/development will be pushed to protected/staging and the staging deployment site is started
  • once we are happy with the state of the staging site, we decide to manually start the deployment of the production site by pushing the source from protected/staging to protected/production
  • using the protected/* branches directly by the team members is not allowed

We are using JetBrains Teamcity to manage and execute these steps automatically. One of these steps is a shell script to synchronize the git branches.

you can call this script as following: ./sync_repos.sh [path_to_work_in] [ssh/http-origin] [ssh/http-destination] [origin-branch] [destination-branch]

example: ./sync_repos.sh ~/repos/dev git@github.com:user/project.git git@github.com:user/project.git protected/development protected/staging

Note: The path_to_work_in is necessary to create a bare repository as working base

Have fun setting up your own branching system!

Why you shouldn’t use Entity Framework with Transactions

0

EntityFramework

This is a .net ORM Mapper Framework from Microsoft to help you talking with your Database in an object oriented manner. Wikipedia

Database Transaction

A database transaction, by definition, must be atomic, consistent, isolated and durable. Database practitioners often refer to these properties of database transactions using the acronym ACID. Transactions in a database environment have two main purposes:

  1. To provide reliable units of work that allow correct recovery from failures and keep a database consistent even in cases of system failure, when execution stops (completely or partially) and many operations upon a database remain uncompleted, with unclear status.
  2. To provide isolation between programs accessing a database concurrently. If this isolation is not provided, the program’s outcome are possibly erroneous. Wikipedia

.NET Transactions

A .NET Transaction can be used in different ways by different frameworks to support transactions. The .NET Transaction itself is not connected with the database by any means. MSDN

.NET Transactions and the EntityFramework

If you are using the Entity Framework during an opened TransactionScope, EntityFramework will open a new Transaction right with the next command that will be sent to the Database (CRUD Operation).

Consider this code block:

The database.SaveChanges() call sends your changes to the database and executes them but they are not really persisted because you are in the database transaction scope. transaction.Complete() actually finishes the database transaction and your data is saved.

That behavior is actually cool and very useful, right?

NO. Absolutely not. full stop.

Why not using .NET Transactions along with EntityFramework

The default isolation mode is read committed and fits perfectly to 99% of your needs, eg. reading data. When you want to save the changes you made to the database (Create, Update, Delete), EntityFramework is smart enough to create a transaction without your notice behind the scenes to wrap the changes. You can be sure that everything will be saved or every change will be discarded (Atomicity).

By using transactions in EntityFramework, you change that behavior and force every CRUD operation during a transaction scope to be executed in serializable isolation mode which is the highest and most blocking type. No process will be able to access the tables you have touched (even reading from it) during your transaction. That can lead to Deadlocks pretty fast and you want to avoid them at all costs!

That’s how the code looks like without the explicit usage of transactions:

Rule of Thumb: Save only once per task and don’t use transactions.

Wire Ape Wallpaper

0

Hi there,
just created a Wallpaper, dedicated to the lovely Blender Ape Suzanne.

Hope you like it!

Unique Ball Wallpaper

2

Hi there,
I’ve created a wallpaper in a couple of hours playing around with particles and cycles and that was the outcomming:

I used particles, cycles, glowing materials and the compositor.

how do you like it?

WCF & WebAPI JSON Dictionary

0

Imagine you want to serialize a Dictionary<string, string> for wcf json output.
The JSON output would look like this:

[
    {
        Key: "key1",
        Value: "value1"
    },
    {
        Key: "key2",
        Value: "value2"
    }
]

But you want a correct JSON dictionary format:

{
    "key1": "value1",
    "key2": "value2"
}

(more…)

Automated Web Deployment with MSBuild and MSDeploy

4

If you are looking for an automated web deployment process you will inevitably come to MSBuild.
There are many tutorials out there how to set up a command line call for MSBuild but you wont find a documentation how to publish a generated package with MSDeploy.

But this is especially needed is you want to use “-setParam” for a tokenized (transformed) web.config file and wont / can’t change the SetParameter.xml!
(The names of the parameters for -setParam can be found in the SetParameter.xml file in the same directory as the Package.zip. They are also act as default values if not set in the command line call. )

So I wrote this quick tutorial how to get command line call for MSDeploy.
(Please consider that the paths you will later use are absolute / relative to the working directory.)

 

Step 1: Get the publish ready with MSBuild

Before we will get some further results please get your deployment call working.

msbuild.exe
SomeWebProject.csproj
/P:Configuration=Release
/P:DeployOnBuild=True
/P:DeployTarget=MSDeployPublish
/P:MsDeployServiceUrl=https://TargetServer/MsDeploy.axd
/P:AllowUntrustedCertificate=True
/P:MSDeployPublishMethod=WMSvc
/P:CreatePackageOnPublish=True
/P:UserName=Username
/P:Password=Password
/P:DeployIisAppPath=TargetWebSite/TargetWebApp

Configuration: This is the configuration you will use eg. Debug, Release or a custom one
AllowUntrustedCertificate: You will need this if you do not have a valid certificate on the server
DeployIisAppPath: The name of the target website eg. “Default Web Site/MyWebApp”
TargetWebSite/TargetWebApp: Please consider the different usages below!

 

Step 2: Get the command line for MSDeploy

Append the parameter “/P:UseMsdeployExe=True” to the msbuild.exe call. If you do so, you will see the call in the console like this:

MSDeployPublish:
Start Web Deploy Publish the Application/package to https:/TargetServer/MsDeploy.axd?site=TargetWebSite
Running msdeploy.exe.
msdeploy.exe -source:package=’C:\SomeWebProject\obj\Release\Package\SomeWebProject.zip‘ -dest:auto,ComputerName=’https://TargetServer:8172/MsDeploy.axd?site=TargetWebSite‘,UserName=’Username‘,Password=’Password‘,IncludeAcls=’False’,AuthType=’Basic’ -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -allowUntrusted -retryAttempts=2

Gotcha! This is the important MSDeploy command line call.

 

Step 3: Get the two things together

now we can split the automatic deployment of MSBuild into 1. create only the package with MSBuild and 2. only deploy with MSDeploy.

msbuild.exe
SomeWebProject.csproj
/P:Configuration=Release
/P:DeployOnBuild=True
/P:CreatePackageOnPublish=True

msdeploy.exe
-source:package=’C:\SomeWebProject\obj\Release\Package\SomeWebProject.zip
-dest:auto,ComputerName=’https://TargetServer:8172/MsDeploy.axd?site=TargetWebSite‘,UserName=’Username‘,Password=’Password‘,IncludeAcls=’False’,AuthType=’Basic’
-verb:sync
-disableLink:AppPoolExtension
-disableLink:ContentExtension
-disableLink:CertificateExtension
-allowUntrusted
-retryAttempts=2
-setParam:’IIS Web Application Name’=’TargetWebSite/TargetWebApp

 

Have a nice day.

Screenshot-2011-08-20_07.37.38

Sculpt-Brush Tips

2

With Blender 2.59 we got a very new and stable version to play with.

While exploring the new features i found two new functions!

(more…)

icon_2d

2D Tracking with RotoBezier

0

This was entirely done with Blender 3D.

Addons:
.) 2D Tracking (Tomato Branch)
.) RotoBezier

The free Footage comes from hollywoodcamerawork.us

The whole process lasts ~4 hours:
(30 min 2d tracking, 15 min compositing, the remaining time: first time ever roto scoping^^)
for the first time i think i was realy fast :)

i can provide the .blend file if someone want it.

360 Camera

360° Camera

2

I was looking for a 360 camera attachment and found one, but it is very expensive to ship outside from the US, so i decide to create my own… in blender :)

The .blend file can be downloaded here.

 

Go to Top