Replace as in batch replace
So I once again needed to replace several patterns in multiple files with something new... Instead of doing this all in my favorite text editor by using repeatedly find/replace, I decided that something more handy was needed. Of course I could have done all that replace stuff with xslt, but hey, who actually likes xslt.
The result of my disapproval of the above mentioned options is the Batch Replacer. As always it is released under the gpl. I also used git for the first time and published the source code on github.
Navigate to those... out of the box with firefox
Ok well, this doesn' seem to be new at all, but nevertheless I missed that. Firefox has the great functionality to assign shortcuts to certain bookmarks and supply a parameter to the URL. This leads to really great quick searches (aka. the art of bookmarking).
What I have now are shortcuts to all my often used search sites. To search in wikipedia e.g. I type CTRL + L (shortcut for placing the cursor in the URL bar in firefox), then type wp asdf and there I go.
I guess this fact renders my previously posted quick link access tool obsolete...
Navigate to those URLs over and over again...
I've written a tool that allows to define commonly used URLs for repeated access, varying only by a defined parameter-part. When you call one of those URLs, you just need to pass a parameter and it opens in the browser. That way you get quick access to often used URLs, e.g. your preffered search engine, your ticketing system or whatever. For even faster access the URLs are bound to predefined global hotkeys.
More infos can be found on the project page.
SharePoint list item and its ItemAdding event
I've found many solutions and discussions trying to find one about the ItemAdding event for a SharePoint list item on the internet, neither of which fixed my problem. Actually I've had two.
The first one was that you have to set the changes made to the ChangedProperties property that belongs the AfterProperties property. If you try to set them on the AfterProperties directly (why you can do this I don't know) the changes will be ignored when creating the item.
The second problem was that all values at the point of that event are stored as strings, they are not yet converted to their respective classes. In my case I needed to set the end date of an event list item 45 minutes after the event date. The following code snippets shows how to achive this. Basically you first have to convert the string into a DateTime object, add the 45 minutes to it and convert the DateTime object back to a valid string representation.
public override void ItemUpdating(SPItemEventProperties properties)
{
base.ItemUpdating(properties);
DateTime eventDate =
SPUtility.CreateDateTimeFromISO8601DateTimeString(properties.AfterProperties["EventDate"].ToString());
properties.AfterProperties.ChangedProperties["EndDate"] =
eventDate.AddMinutes(45).ToString("o");
}
Nullable average in LINQ
The following code is one possibility (there may be more elegant solutions to this) to handle a nullable average from a linq query. The problem arises when the linq query does not return a result, thus the average being null. If you don't use a nullable type, you'll get an exception. To get a nullable average from an integer value you'll need to provide a transform function to the Average funtion.
double? nullableAverage = (from m in dataContext.Moods join g in dataContext.Groups on m.GroupGUID equals g.GUID where g.GUID == groupGUID select m.Level) .Average<int>(x => new double?(x)); int average = (int)Math.Round(nullableAverage.HasValue ? nullableAverage.Value : 0, 0); // ...
- 0 comments
Fatal error: Cannot redeclare getpagecooserlinkhtml() (previously declared in /home/www/web261/html/koffeinfrei5/modules/Blogs/action.showblog.php:11) in /home/www/web261/html/koffeinfrei5/modules/Blogs/action.showblog.php on line 11