tag:blogger.com,1999:blog-26056952715311164722024-02-19T08:48:17.658+01:00h3mm3's blogStories from behind the keyboardUnknownnoreply@blogger.comBlogger46125tag:blogger.com,1999:blog-2605695271531116472.post-89594754997796867892021-10-30T10:00:00.004+02:002021-11-16T22:11:01.708+01:00hGess has a new homeI'm glad to announce that hGess has a now home: PlayGess.com.You can play gess online or locally with on your device as usual. Just visit playgess.com and have fun!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-6289262687059199702018-12-13T08:24:00.000+01:002018-12-13T08:24:18.946+01:00Play Gess against the AIhGess AI is alive and kicking. Check it out on gess.h3mm3.comUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-62938738323277804492013-12-15T17:48:00.000+01:002013-12-15T20:54:04.629+01:00ScriptCs.Gui is now a standard script pack
ScriptCs.Gui is now a standard script pack for ScriptCS. You can just grab it from NuGet with
C:\scriptcs -install ScriptCs.Gui
..and use it in REPL with:
> var gui = Require<Gui>();
>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-2320657962208247962013-12-12T00:20:00.000+01:002013-12-15T17:46:29.357+01:00ScriptCS-GUI has evolved!
ScriptCS-GUI has evolved a little bit. At the moment the following helpers are declared inside the static class Gui.
Gui.OpenFileDialog(): open a classic Open File Dialog and return the path of the selected file.
Gui.SaveFileDialog(): act similar to OpenFileDialog()...
Gui.PopUp(): open a pop-up and returns a form object. You can use its Sta.Enqueue(action) method to inject code in the form's Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-31867758640564698282013-12-07T10:24:00.000+01:002013-12-12T00:06:32.924+01:00Interact with your C# scriptsScriptCs is a great yet simple to use framework for writing and executing C# scripts.
TL;DR
Chocolatey + NuGet + Roslyn = ScriptCs
ScriptCs + Command Prompt = C# REPL
Beeing able to write and freely execute C# scripts is a great opportunity and can be a time saver. What I lack more at this stage of development of ScriptCs is a simple toolset to implement basic user interactions.
I've Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-57794129499748964332012-03-17T00:00:00.001+01:002012-03-17T00:00:36.820+01:00WP7: creating theme (in-)dependent imagesWhen you develop a Windows Phone 7 application that reflect the user theme, you are practically limited and bound to an handful of color resources: the background color, the foreground color, the accent color and a few more. Referring to these resources in you XAML is super simple: once you know all the various theme resources,  you can apply any resource in your code via the {StaticResourceUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-52546446412462157642012-03-12T21:06:00.001+01:002012-03-12T21:06:00.701+01:00Quick document preview within ExplorerQuick and Dirty: you can enable the Windows Explorer Preview Panel to show the content of various text file format (such as .cs, .inf, .xaml, and so on…). Just open REGEDIT.EXE, browse HKEY_CLASSES_ROOT down to the file extension you want to preview, and add a new string value “PerceivedType” with value “text” and you are done. For instance, here’s how you enable the text preview handler for C#Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-16195514882038832372012-02-26T08:05:00.000+01:002012-03-03T22:26:15.340+01:00WP7: Localization and binding to string resourcesOne straightforward way to localize a Windows Phone 7 application you are writing is the following: Create and edit a .resx file (for instance LocalizedStrings.resx). Build your project, so that Visual Studio (well, the PublicResXFileCodeGenerator tool) generates the .Designer.cs file. This way your assembly is having a nice LocalizedStrings static class that you can use in your XAML. Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-2605695271531116472.post-83589844422588740722012-02-08T18:32:00.000+01:002012-02-11T19:05:38.301+01:00Dynamic CSS with Razor (part 2)Summary When I customize a web site template, I always replace the color palette looking for a consistent set of colors. In this series I’ll tell how I managed to speed up the whole process, by building a set of Razor functions and push the Razor syntax inside a CSS stylesheet. In PART ONE we saw how to create a gradient programmatically in order automate a CSS stylesheet using the Razor Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-72036195333265671602012-02-04T11:40:00.001+01:002012-02-08T21:34:15.938+01:00Dynamic CSS with Razor and no LESS (part 1)Summary When I customize a web site template, I always replace the color palette looking for a consistent set of colors. In this series I’ll tell how I managed to speed up the whole process, by building a set of Razor functions and push the Razor syntax inside a CSS stylesheet. PS: We won’t use LESS. Refreshing a pre-cooked template One of the tasks I have to accomplish anytime I start a new Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-74750981421227779622011-08-02T23:42:00.002+02:002011-08-03T00:05:08.280+02:00Interfaces: proxying wins 1-0 over castingRecently I needed to write some test against an utility class. This class handles an unmanaged type and of course I didn’t want to use this unmanaged type in my tests. I wrote an interface to target the only members of the unmanaged type that were used by my utility class. It turned out that this contract was really simple, having as its only member an indexer:public interface IIndexable<T>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-90690541461359621292011-06-24T01:02:00.000+02:002011-06-24T01:02:07.469+02:00Unsubscribing to events in C#In C# you can easily unsubscribe a handler to an event using an handy (!) syntax. For instance let’s consider the following class, that exposes an event called MyEvent.public class MyClass{
public event EventHandler MyEvent;
public void Fire()
{
if (MyEvent!=null)
MyEvent(this, EventArgs.Empty);
else
Console.WriteLine("Nothing to do");
}
}
You can Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-26210956052240974822011-06-19T22:48:00.000+02:002011-07-28T09:06:03.268+02:0010 reasons why you should not read this postOne post out of ten has a title similar to this one, starting with a number divisible by 5.
This post is totally pointless.
You shouldn’t spend your time reading posts like this.
You’d better send an SMS to an old friend.
You’d better adjourn your résumé.
One post out of twenty has a title similar to this one, starting with «10».
That déjà vu feeling is more concrete than you think.
This post isUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-64193708412188705212011-06-17T22:57:00.001+02:002011-06-17T22:58:10.548+02:00Select, right-click and navigate from IEOne of the feature I miss most when I use Internet Explorer in comparison of Google Chrome, is the contextual menu command “Go to <url>” that appears when you select a text that resembles an URL and then right-click the selection (see picture).In Italy we have a saying: «He who works by himself does the work of three (people)» (Chi fa da sé, fa per tre)that’s to say: if Microsoft hasn’t Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-2605695271531116472.post-67129795889922864702011-06-14T00:11:00.002+02:002011-06-14T00:15:21.779+02:00Welcome www.h3mm3.comA year has passed since I started blogging about C# programming. So long hemme.co.cc domain (and thanks for all the fish). Welcome www.h3mm3.com. Happy programming!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-7273830247874410272011-06-10T21:51:00.001+02:002011-06-10T21:51:30.489+02:00Dynamically counting table rows in T-SQLRecently I was asked to write a T-SQL code to count the rows of any table, given its name. My first attempt was to embed an EXECUTE(…) statement in the body of a stored procedure, and get the table name as an input parameter:CREATE PROC dbo.RecordCount(@tablename nvarchar(128))
AS
EXECUTE('SELECT COUNT(*) FROM '+@tablename)The solution was straightforward, but what if you wanted the record Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-58947566946943460632011-06-01T23:03:00.000+02:002011-06-01T23:03:33.335+02:00NTFS = Never Trust File SecretsSome days ago one trainee of mine asked me how to write an HTML link to «a file hidden inside another file». After my eyebrows jumped high over my head, he explained to me that he was thinking about a feature of the NTFS File System called Alternative Data Streams (ADS) but he couldn’t help building a working HTML code. Meet an Alternative Data StreamIn simple terms, ADS technology lets you storeUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-75883725445286356482011-05-31T23:06:00.003+02:002011-05-31T23:09:18.436+02:00Q’n’D: List the environment variables in WindowsToday a friend of mine was looking for the Windows environment variable that defines the x86 version of Program Files folder inside an x64 Windows OS. After a little search, I found that you can simply open a Command Prompt (cmd.exe) and launch the good old DOS command “SET” in order to list all the environment variables. You can even get the list of all the environment variables starting with a Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-1135502524145048162011-05-25T22:36:00.003+02:002011-05-26T20:59:35.848+02:00The strange case of Dr. ANY and Mr. ALLRecently I meant to demo how to use two T-SQL logical operators: ANY (a.k.a. SOME) and ALL. Tipically these two operators are used in the right-side of a comparison expression, combined with a sub-query. For instance, let’s consider a sample query against AdventureWorksLT database:SELECT * FROM SalesLT.Product WHERE ListPrice < [ALL|ANY] (
SELECT UnitPrice FROM SalesLT.SalesOrderDetails WHERE Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-19748926976871682472011-05-24T00:40:00.000+02:002011-05-25T22:46:12.897+02:00Selective form field validation with WebMatrixASP.NET WebPages, a.k.a. WebMatrix web sites, are built upon the ASP.NET stack and, as a consequence, they are subjected to the so-called ”request validation”. In effect ASP.NET provides a basic anti-XSS form validation service, preventing an user to insert HTML/Javascript code inside HTML fields. Within a WebMatrix project, you can bypass this kind of validation by using the Unvalidated(..) Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-37447120994322304322011-05-08T00:32:00.007+02:002012-02-11T20:48:39.188+01:00Writing a Mandelbrot fractal generator using WebMatrix and Razor (part 2/2)In a previous post I told how I implemented a simple Mandelbrot fractal generator by using WebMatrix. At last the page is accessible to everyone at http://www.hemme.somee.com/MandelPage.cshtml.
The fractal image is computed server-side by a razor C# script. The computation is fired directly by a standard HTTP request (no JSON, just an old- plain-GET-url) like the following one
(you can readUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-64990732100743248962011-05-06T22:08:00.002+02:002011-05-06T22:12:09.620+02:00Automating IDisposable objects disposition inside loopsI recently read an interesting MSDN whitepaper about the correct usage of disposable Windows SharePoint Services object. Simply put, handling SharePoint objects without sufficient care can lead to ugly memory leaks. For instance, one of the subtleties of SharePoint programming best practices is seen in the following sample (taken from the aforementioned article): although the outer object (an Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-32265271056306106002011-04-23T20:09:00.000+02:002011-05-25T22:46:24.192+02:00Implementing the Post-Redirect-Get (PRG) pattern in a WebMatrix websiteThe Post/Redirect/Get (PRG) pattern is a practical remedy against the “refresh-your-page-after-you-sent-form-data” troubles. In this article I present a simple way to implement this pattern in a WebMatrix website.The patternSimply put, in the PRG pattern, the server, after receiving data from a form page P1, answers with a REDIRECT message to a different page (P2). Doing so, the browser will Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-2605695271531116472.post-69376114991530131172011-04-09T16:04:00.018+02:002011-05-22T22:11:41.770+02:00My HTML5 Mandelbrot generatorAfter experimenting the Mandelbrot algorithm inside a Razor web application, I decided to port my code to a standalone Javascript+HTML5 page (i.e. the one you are just reading now). As far as I'm concerned, the most interesting part about this post is loading this page with different browsers and comparing how fast are the various javascript engine implementations. For instance, on my PC, Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-2605695271531116472.post-58984223475910015452011-04-01T21:57:00.000+02:002011-04-02T07:44:41.323+02:00My HTML5 interactive Koch curveAfter I stumbled upon this post about how to draw a Koch curve using turtle graphics, I decided to implement some turtle commands in Javascript and test them inside a <canvas/>. The application Set the width and the number of recursions of the Koch algorithm, and watch a classic Koch fractal! Koch curve parameters: width: -?-100200 300400500600 recursions: -?-12 3456
/*
Unknownnoreply@blogger.com0