Skip to main content

Setting folder permissions using Web Deploy

Learn how to set folder permissions to your ASP.NET projects when using Web Deploy

Posted in Web Deploy, Code snippets, Tutorials, ASP.NET, Configuration

I was running into a very odd problem recently: I couldn't upload files to my website because of an error saying that I didn’t have permission to write files into the App_Data folder. I’ve decided to look into it and I realized that it began since I started using Web Deploy.

For those unfamiliar with Web Deploy I will tell you something: This is the best deployment tool for ASP.NET websites so far. It checks the files before you send to the server so it will send only those which had some change, publish entire databases and even pre-populate the tables.

The problem is that Web Deploy resets all folder permissions, which basically broke my file upload. And since ELMAH couldn't log the errors I spent some time thinking that my website was running flawlessly perfect. Silly me...

The solution I found was to create a .targets file in order to set the permissions during the deployment time. Let’s see how to do it:

  1. Create a .wpp.targets file in the root of your web project. You may not find this file in your File -> New window. In that case just create a normal Text File, change the extension and add XML content in it, as you can see in the gist below:
  2. Set the permissions to the folders you want. In my case, the App_Data was just enough but you can add other folders as well (lines 15 to 29).
  3. Deploy through Web Deploy. A very simple explanation of this step: When you deploy the MSBuild will run, pass through the .targets file you’ve created and set the permissions to the folders you’ve defined.

You might keep some things in mind:

  • Visual Studio caches the .targets files, which means that you will have to restart Visual Studio every time you want to make changes and see the effects when you are building the deployment package.
  • The package will not be rebuild unless you actually make changes in the .targets file.
  • Remember to always use Clean Solution in case you want to rebuild the deployment package.

For more information visit the Sayed Ibrahim Hashimi’s website.

Did you like the article?

You can subscribe and get them as soon they are online, share using the buttons bellow or leave a comment.

And you also can share using your favorite social network:

Unprofessional people and the oxymoron effect

Why is it bad to have colleagues like this and how to deal with them?

Posted in Workplace, Career, Czech it out!, Personal life

The first time I heard the word oxymoron was during a job interview in 2010. We were talking about my skills and how it was my previous job when he asked me if I had some difficulties here in Prague, while working. At that time I said that I didn’t notice anything so drastic but, yes, I had some problems. At that time thought it could be culture related since I am from Brazil. When I described which problems he said that I was facing a common oxymoron around here. I asked what is it and he gave me some examples. The last example was “Czech professional”.

Disclaimer: I am not targeting any nationality, but as I live in Prague the percentage of local oxymoron is higher. For sure someone living in a different country will see this pattern in a different nationality.

Oxymoron, if you don’t know, is when contradictory set of words appear in the same sentence. Like civil war, noisy silence, living dead, seriously funny and so on.

The problem I was facing was related with people who were thinking they own the office space and you would break the status quo. We all know people like this, no matter the place in the world they come from. I have 2 examples very vivid in my memory:

  • A person who goes beyond his/her job description and gets activities from other people thinking it’s doing something good, but then blames others when things start to be problematic because of his/her own proactivity (“this was your job!”);
  • A person who treats the office like his/her home and takes everything personally (“I’ll not do anything for him/her because he/she screamed at me last week”).

Of course, there are situations where both examples are in the same person.

When people behave as mentioned above the office starts to become a toxic place. And it’s easy to notice: The team leader (or manager) only needs to pay attention on where is the bottleneck. Sometimes, in some projects, a bottleneck is caused by performance of 1 or more team members. But in a toxic office the performance is not the issue, but the person itself.

If you want to recognize this behavior you should pay attention to:

  1. Self-proclaimed office stars (“Nothing would work without me”);
  2. The one who makes himself/herself busy by getting tasks from other colleagues, and blame them when something goes wrong;
  3. A person who takes everything personal in the office;
  4. The classic apple polishers.

How to deal with them?

If you are not a team leader or manager I’d recommend you to report it. The leader should be responsible for this kind of conversation. But, still, it’s difficult even for the leader as it doesn’t depend only on him. The person should be willing to understand the issues and change. Not everybody has enough self-awareness and also not everybody would be willing to accept that he/she is part of the problem. But as we say back in my country, there is always an old shoe to a tired foot. Which means this person might be a perfect fit in another department or company.

Did you like the article?

You can subscribe and get them as soon they are online, share using the buttons bellow or leave a comment.

And you also can share using your favorite social network:

Leave the office! See what you need to work anywhere you want

Do you know those days you don't want to be in the office? Here is what you need to work anywhere you want!

Posted in Workplace, Misc, Tutorials, Career, Personal life

When I started my career as software developer all I could have was a big desktop computer. It was an Intel Celeron 300 MHz with 32 MB of RAM and a HDD of 4 GB. Such beauty would never let me to have the mobility I am able to have today, although I am still far from being as mobile as I want.

But what do you need to become a “work anywhere professional”?

The basic checklist is this:

  • A nice place
  • Good devices
  • Internet connection
  • Tools
  • Concentration

Now, let’s talk about each item.

Place

The place must be nice, preferably with a table where it's possible to place all your devices (more on that later), and calm unless you have a good concentration level (more on that later). Most of people think of places like Starbucks or McDonalds but, actually, it would depend on the kind of work you do and how connected you must be. For a writer, who doesn’t need to be online all the time, work in the woods would be a nice thing. But for a software developer, who depends on internet connection, it would be a bit more complicated.

Good devices

The very basic is a notebook and a mobile phone with a good data plan. In my particular case I have a 17” Lenovo as main computer and a 10” ASUS Transformer as side computer. If I am traveling or going to a place where I know I will need a computer, I take the ASUS. The keyboard is comfortable enough to write and the touchscreen replaces in a very nice way. In addition, I have Visual Studio Express here and it works fine for me.

Another thing to keep in mind is battery time. My Lenovo can work up to 3h with Wi-Fi turned on while my ASUS works up to 10h in the same conditions. Given that I assume I will not find sockets anywhere I go a good battery time is very important. Not to mention that I can it also to recharge my phone, at least to keep alive for longer time (if necessary).

Internet connection

You have 3 possibilities here: Connect over Wi-Fi, use your mobile data plan and share the internet with your notebook or work offline.

It’s clear that Wi-Fi is the best alternative here. However, you can’t expect to find free Wi-Fi with a good speed anywhere. And I am not even talking about how unsafe that would be. Connect over mobile and sharing the internet to your notebook is to be the best option if you have a good (big and fast) data plan, except if you are on roaming.

Tools

The idea here is to have everything to make the transition from your portable machine to your stationary machine as seamless as possible. Except, of course, for some software you can’t install on both due hardware limitations.

Assuming that you have internet connection, you can make use of tools like a private VPN, online file services (OneDrive, DropBox, Google Drive), online repository (TFS Online, GitHub) and others. As a developer, I consider all of them important, although I don’t have a private VPN. Yet.

Concentration

The best here is to be self-aware: If you know how much concentration you are able to have in the moment you decide to leave the office, you will pick the perfect place for you. For those who can work only in a silent environment a Starbucks would not be the best place.

Conclusion

My case is a very specific one. I love what I do but I am far from being workaholic. But sometimes I need to work on something small or go somewhere where I could use a computer. Today, for example, I started this article watching children play indoor soccer in the morning. It was noisy, messy and I was using my ASUS on my laps. Luckily, that place had a good internet connection and I could save this text in my OneDrive in order to finish on my notebook later.

Keep something in mind: Find balance. It doesn’t matter if you have an outstanding data plan if you are abroad most of the time as you will need to use roaming. Or even, you have the best of everything but you can’t concentrate in a café.

And remember: The best alternative is always the alternative that suits you.

 

Did you like the article?

You can subscribe and get them as soon they are online, share using the buttons bellow or leave a comment.

And you also can share using your favorite social network:

Ship of fools

by Ted Kaczynski (based on Plato's allegory)

Posted in Workplace, Misc

Published by OFF! Magazine, a zine produced by students at SUNY Binghamton and edited by Tim La Pietra.

Once upon a time, the captain and the mates of a ship grew so vain of their seamanship, so full of hubris and so impressed with themselves, that they went mad. They turned the ship north and sailed until they met with icebergs and dangerous floes, and they kept sailing north into more and more perilous waters, solely in order to give themselves opportunities to perform ever-more-brilliant feats of seamanship.

As the ship reached higher and higher latitudes, the passengers and crew became increasingly uncomfortable. They began quarreling among themselves and complaining of the conditions under which they lived.

"Shiver me timbers," said an able seaman, "if this ain’t the worst voyage I’ve ever been on. The deck is slick with ice; when I’m on lookout the wind cuts through me jacket like a knife; every time I reef the foresail I blamed-near freeze me fingers; and all I get for it is a miserable five shillings a month!"

"You think you have it bad!" said a lady passenger. "I can’t sleep at night for the cold. Ladies on this ship don’t get as many blankets as the men. It isn’t fair!"

A Mexican sailor chimed in: "¡Chingado! I’m only getting half the wages of the Anglo seamen. We need plenty of food to keep us warm in this climate, and I’m not getting my share; the Anglos get more. And the worst of it is that the mates always give me orders in English instead of Spanish."

"I have more reason to complain than anybody," said an American Indian sailor. "If the palefaces hadn’t robbed me of my ancestral lands, I wouldn’t even be on this ship, here among the icebergs and arctic winds. I would just be paddling a canoe on a nice, placid lake. I deserve compensation. At the very least, the captain should let me run a crap game so that I can make some money."

The bosun spoke up: "Yesterday the first mate called me a ‘fruit’ just because I suck cocks. I have a right to suck cocks without being called names for it!"

It’s not only humans who are mistreated on this ship," interjected an animal-lover among the passengers, her voice quivering with indignation. "Why, last week I saw the second mate kick the ship’s dog twice!"

One of the passengers was a college professor. Wringing his hands he exclaimed,

"All this is just awful! It’s immoral! It’s racism, sexism, speciesism, homophobia, and exploitation of the working class! It’s discrimination! We must have social justice: Equal wages for the Mexican sailor, higher wages for all sailors, compensation for the Indian, equal blankets for the ladies, a guaranteed right to suck cocks, and no more kicking the dog!"

"Yes, yes!" shouted the passengers. "Aye-aye!" shouted the crew. "It’s discrimination! We have to demand our rights!"

The cabin boy cleared his throat.

"Ahem. You all have good reasons to complain. But it seems to me that what we really have to do is get this ship turned around and headed back south, because if we keep going north we’re sure to be wrecked sooner or later, and then your wages, your blankets, and your right to suck cocks won’t do you any good, because we’ll all drown."

But no one paid any attention to him, because he was only the cabin boy.

The captain and the mates, from their station on the poop deck, had been watching and listening. Now they smiled and winked at one another, and at a gesture from the captain the third mate came down from the poop deck, sauntered over to where the passengers and crew were gathered, and shouldered his way in amongst them. He put a very serious expression on his face and spoke thusly:

"We officers have to admit that some really inexcusable things have been happening on this ship. We hadn’t realized how bad the situation was until we heard your complaints. We are men of good will and want to do right by you. But – well – the captain is rather conservative and set in his ways, and may have to be prodded a bit before he’ll make any substantial changes. My personal opinion is that if you protest vigorously – but always peacefully and without violating any of the ship’s rules – you would shake the captain out of his inertia and force him to address the problems of which you so justly complain."

Having said this, the third mate headed back toward the poop deck. As he went, the passengers and crew called after him, "Moderate! Reformer! Goody-liberal! Captain’s stooge!" But they nevertheless did as he said. They gathered in a body before the poop deck, shouted insults at the officers, and demanded their rights: "I want higher wages and better working conditions," cried the able seaman. "Equal blankets for women," cried the lady passenger. "I want to receive my orders in Spanish," cried the Mexican sailor. "I want the right to run a crap game," cried the Indian sailor. "I don’t want to be called a fruit," cried the bosun. "No more kicking the dog," cried the animal lover. "Revolution now," cried the professor.

The captain and the mates huddled together and conferred for several minutes, winking, nodding and smiling at one another all the while. Then the captain stepped to the front of the poop deck and, with a great show of benevolence, announced that the able seaman’s wages would be raised to six shillings a month; the Mexican sailor’s wages would be raised to two-thirds the wages of an Anglo seaman, and the order to reef the foresail would be given in Spanish; lady passengers would receive one more blanket; the Indian sailor would be allowed to run a crap game on Saturday nights; the bosun wouldn’t be called a fruit as long as he kept his cocksucking strictly private; and the dog wouldn’t be kicked unless he did something really naughty, such as stealing food from the galley.

The passengers and crew celebrated these concessions as a great victory, but the next morning, they were again feeling dissatisfied.

"Six shillings a month is a pittance, and I still freeze me fingers when I reef the foresail," grumbled the able seaman. "I’m still not getting the same wages as the Anglos, or enough food for this climate," said the Mexican sailor. "We women still don’t have enough blankets to keep us warm," said the lady passenger. The other crewmen and passengers voiced similar complaints, and the professor egged them on.

When they were done, the cabin boy spoke up – louder this time so that the others could not easily ignore him:

"It’s really terrible that the dog gets kicked for stealing a bit of bread from the galley, and that women don’t have equal blankets, and that the able seaman gets his fingers frozen; and I don’t see why the bosun shouldn’t suck cocks if he wants to. But look how thick the icebergs are now, and how the wind blows harder and harder! We’ve got to turn this ship back toward the south, because if we keep going north we’ll be wrecked and drowned."

"Oh yes," said the bosun, "It’s just so awful that we keep heading north. But why should I have to keep cocksucking in the closet? Why should I be called a fruit? Ain’t I as good as everyone else?"

"Sailing north is terrible," said the lady passenger. "But don’t you see? That’s exactly why women need more blankets to keep them warm. I demand equal blankets for women now!"

"It’s quite true," said the professor, "that sailing to the north imposes great hardships on all of us. But changing course toward the south would be unrealistic. You can’t turn back the clock. We must find a mature way of dealing with the situation."

"Look," said the cabin boy, "If we let those four madmen up on the poop deck have their way, we’ll all be drowned. If we ever get the ship out of danger, then we can worry about working conditions, blankets for women, and the right to suck cocks. But first we’ve got to get this vessel turned around. If a few of us get together, make a plan, and show some courage, we can save ourselves. It wouldn’t take many of us – six or eight would do. We could charge the poop, chuck those lunatics overboard, and turn the ship to the south."

The professor elevated his nose and said sternly, "I don’t believe in violence. It’s immoral."

"It’s unethical ever to use violence," said the bosun.

"I’m terrified of violence," said the lady passenger.

The captain and the mates had been watching and listening all the while. At a signal from the captain, the third mate stepped down to the main deck. He went about among the passengers and crew, telling them that there were still many problems on the ship.

"We have made much progress," he said, "But much remains to be done. Working conditions for the able seaman are still hard, the Mexican still isn’t getting the same wages as the Anglos, the women still don’t have quite as many blankets as the men, the Indian’s Saturday-night crap game is a paltry compensation for his lost lands, it’s unfair to the bosun that he has to keep his cocksucking in the closet, and the dog still gets kicked at times.

"I think the captain needs to be prodded again. It would help if you all would put on another protest – as long as it remains nonviolent."

As the third mate walked back toward the stern, the passengers and the crew shouted insults after him, but they nevertheless did what he said and gathered in front of the poop deck for another protest. They ranted and raved and brandished their fists, and they even threw a rotten egg at the captain (which he skillfully dodged).

After hearing their complaints, the captain and the mates huddled for a conference, during which they winked and grinned broadly at one another. Then the captain stepped to the front of the poop deck and announced that the able seaman would be given gloves to keep his fingers warm, the Mexican sailor would receive wages equal to three-fourths the wages of an Anglo seaman, the women would receive yet another blanket, the Indian sailor could run a crap game on Saturday and Sunday nights, the bosun would be allowed to suck cocks publicly after dark, and no one could kick the dog without special permission from the captain.

The passengers and crew were ecstatic over this great revolutionary victory, but by the next morning they were again feeling dissatisfied and began grumbling about the same old hardships.

The cabin boy this time was getting angry.

"You damn fools!" he shouted. "Don’t you see what the captain and the mates are doing? They’re keeping you occupied with your trivial grievances about blankets and wages and the dog being kicked so that you won’t think about what is really wrong with this ship --– that it’s getting farther and farther to the north and we’re all going to be drowned. If just a few of you would come to your senses, get together, and charge the poop deck, we could turn this ship around and save ourselves. But all you do is whine about petty little issues like working conditions and crap games and the right to suck cocks."

The passengers and the crew were incensed.

"Petty!!" cried the Mexican, "Do you think it’s reasonable that I get only three-fourths the wages of an Anglo sailor? Is that petty?

"How can you call my grievance trivial? shouted the bosun. "Don’t you know how humiliating it is to be called a fruit?"

"Kicking the dog is not a ‘petty little issue!’" screamed the animal-lover. "It’s heartless, cruel, and brutal!"

"Alright then," answered the cabin boy. "These issues are not petty and trivial. Kicking the dog is cruel and brutal and it is humiliating to be called a fruit. But in comparison to our real problem – in comparison to the fact that the ship is still heading north – your grievances are petty and trivial, because if we don’t get this ship turned around soon, we’re all going to drown.

"Fascist!" said the professor.

"Counterrevolutionary!" said the lady passenger. And all of the passengers and crew chimed in one after another, calling the cabin boy a fascist and a counterrevolutionary. They pushed him away and went back to grumbling about wages, and about blankets for women, and about the right to suck cocks, and about how the dog was treated. The ship kept sailing north, and after a while it was crushed between two icebergs and everyone drowned.

© Ted Kaczynski, 1999

Did you like the article?

You can subscribe and get them as soon they are online, share using the buttons bellow or leave a comment.

And you also can share using your favorite social network:

Adding an external link message to all links with jQuery

Learn how to show a message to the user whenever he clicks in a link pointing to a different website

Posted in Code snippets, Tutorials, jQuery, JavaScript

Sometimes we face some situations where we have to tell the user he is leaving our website. This can be achieved with CSS selector without so much problem. But what if the external link is in a button? For that situation we should use JavaScript.

Let's see how to do it in this very short tutorial.

Objective

We need to create a script where a message will be shown whenever the user clicks in some link which will lead him outside of the website. And this must be done unobtrusively.

The foundation

First we need to prepare the foundation of our code. Given the objective we will need to:

  1. Loop through all "a" elements
  2. Get the href value
  3. Compare if the host matches with the href host
  4. Assign the click button

1. Loop through all "a" elements

Since we are using jQuery we can make use of the jQuery.each(), as seen below, to loop through all "a" elements:

$('a').each(function () {
// something
});

2. Get the href value

This is a bit trickier but, to make it easier, we will create a function to do the job:

var getLocation = function (href) {
	var l = document.createElement("a");
	l.href = href;
	return l;
};

And we will call it like this:

var a = getLocation($(this).attr('href'));

3. Compare if the host matches with the href host

var retValue = a.href && a.hostname !== window.location.hostname && a.href.indexOf('mailto') == -1;

Here you have to use a set of rules which will make the code work properly. For the sake of the example I’ve decided to keep it simple, but you can (and should) extend according to your project. 

4. Assign the click button

For those who are already aware of jQuery this is an easy piece. But I will leave it here anyway.

if (retValue === true) {
	$(this).on('click'function () {
		// something
	});
}

Now that we have the foundation ready you can see it working in this JSFiddle. When you click the links you will see that one of them shows an alert() message. Now the things will get more interesting, by implementing our confirmation message. 

Showing the message

Now that we have everything in place we can start to work with the message. For this example I will keep it simple and use a simple confirm(), as seen below:

return confirm('Do you really want to leave this website and go to ' + a.href + '?');

Conclusion

Here is the whole code:

var getLocation = function (href) {
	var l = document.createElement("a");
	l.href = href;
	return l;
};
$(function () {
 
	$('a').each(function () {
		var a = getLocation($(this).attr('href'));
 
		// IE fix
		a = getLocation(a.href);
 
		var retValue = a.href && a.hostname !== window.location.hostname && a.href.indexOf('mailto') == -1;
 
		if (retValue === true) {
			$(this).on('click'function () {
				return confirm('Do you really want to leave this website and go to ' + a.href + '?');
			});
		}
	});
 
});

As you can see it is very simple to make and even simpler to use. Once you call it in all pages it will scan all your links and check if they should have this extra event or not. Also, for most of the projects we don’t need more than this. And when you have the need of more customization (Bootstrap Modal or jQuery UI Dialog) you can just replace the confirm() by something else.

I will show how to do it in the future articles.

EDIT: I've made a small change on the script (bold, see above) as IE11 had some problems to get the a.hostname.

Did you like the article?

You can subscribe and get them as soon they are online, share using the buttons bellow or leave a comment.

And you also can share using your favorite social network: