Showing posts with label Silverlight. Show all posts
Showing posts with label Silverlight. Show all posts

Wednesday, July 18, 2012

FlashDevelop - "Error Definition starling.core:Starling could not be found." - SOLVED

Go to Project Properties, Classpath tab and add/edit the classpath to Starling classes.  Specify path to the src folder like this:

C:\dev\Starling-1.1\starling\src

Cheers!

Monday, April 30, 2012

How to run sudo application on startup in Ubuntu without asking for password

Option 1 - Startup Applications


Step 1: Use Ubuntu UI for configuring Startup Applications. Depending on the Ubuntu version you can either go to System > Preferences > Startup Applications or type "Startup Applications" in Dash. From there you can simply edit the list of applications that you want to run on startup. More about Startup Application UI.

Step 2: Configure your application to start with sudo without asking for password. For that you need to add your application to the list of sudoers and disable  password just for your app. Let's open the sudoers configuration file. This can be done with visudo command like this:
sudo visudo

The reason visudo commend is recommended over using a regular text editor is because it locks sudoers configuration file while you are editing it.

Now let's say your user name is user1 and app name is my_app.jar, then add the following line to the configuration file:
user1 ALL=NOPASSWD: java -jar /usr/local/my_app.jar

All done. Now you can restart Ubuntu and enjoy your app running.

Option 2 - Add your app to rc.local


Option 1 will start your application only after user has logged in. What if need to start your application before that or regardless if user has logged in or not? The one of the simplest options is to add your application to the rc.local file. Open editor:
gksu gedit /etc/rc.local

And add your command to execute application just before the exit 0 statement.

Option 3 - Run your app as a Service


Most common approach in Linux world is to add your app to the /etc/init.d script. You can do the same in Ubuntu too, but Ubuntu has something even better. It's called Upstart. You can find the mode details on how it work in this blog post and on Ubuntu help page.

The beauty of this approach is that you can easily control your service from command like using start and stop command. It also allows you to configure dependencies on other services.

-=Oleg=-

Friday, June 3, 2011

Sending bulk emails from your web application - the right way

For us, developers, it’s easy to deal with situations when your application needs to send one or two emails at a time, but is it okay to send hundreds of emails from your hosting server? Usually not and here is why.

First of all there are technical challenges. For example you have to make sure you are not exceeding the limits set by hosting providers (which are not always officially advertised).

Second and the most challenging part is getting around spam filters. If high deliverability is important to you (otherwise why would you even bother sending emails) then you need to start thinking about playing by the rules and implementing techniques like double opt-in, unsubscribe functionality and many other little things.

Unfortunately for you and fortunately for users, anti spam filters are very suspicions and it’s not that hard to get blacklisted. So if are interested in your emails being delivered into your users’ inbox, then the safest bet is let the professionals deal with that and focus on other not less important tasks.

So, now, where should you look for professional services if you need to send bulk emails? Such service is usually called email marketing. Pick carefully. There are many variations and different price points. If you don’t know where to start here are the two companies I had very good experience with: AWeber (www.aweber.com) and iContact (www.icontact.com) . As I already mentioned, I like both companies. I’d say they break even in the set of features they provide. AWeber seems to be the most popular choice - not sure why. Pricing wise iContact is a little bit cheaper, but that’s where you have to make your own comparison based on your needs.

If are not bored to death yet, I just want to mention that respectful companies like those mentioned above have API(s) for developer so if you need to send emails from your web site, you can, but now via reliable service.

Hey one more thing to consider is that email marketing companies can collects stats for you so you can actually see how many people opened your newsletter. Isn’t it cool? ;-)

Amazon ES2 Error "Configuration information could not be read from the domain controller" SOLVED

I've got this error when I tried to change the password on Windows Server 2008 running on  Amazon ES2.

The thing is, I never changed this error before even though I had to change my password many times. What was different this time is that I had problem with server and had to Stop and Start the instance. As a result the name of the instance has changed.  The problem is Remote Desktop had saved the name of the previous instance in the username field in a form "instance name\my name".

Soution:  I deleted the instance name in Remote Desktop and the error has gone away. Hurray!

-=Oleg=-

Monday, August 24, 2009

SVN Rollback - restoring deleted files and folders

Preface


I'm not an expert in SVN version control and I don't like using command line. I'm regular Windows user and so it was easy for me to learn how to use "Commit" and "Update" buttons in TortoiseSVN. It was easy until one day when I had to figure out how to restore delete folders.

A day when sources disappeared


One beautiful morning I checked out my sources from SVN and discovered that the most of the files and folders are gone. Apparently the night before one of the developers was cleaning SVN working folder on his machine and ... Well, if you don't know what that big red button is for it might be not a good idea to press it...

So, if don't know what to do - ask Google. Google said - don't worry, it's impossible to lose anything in SVN, just do the reverse merge using following command line params... 

The problem is I didn't want to use command line. I wanted to use beautiful TortoiseSVN UI for that. So, I found "Revert to this revision" and "Revert changes from this revision" and thought my problem is solved, but for some reason SVN was failing this task with an error "'/svn/sources/!svn/bc/373/Test' path not found". Finally, after asking an SVN expert, I figured that there was a small detail which I was missing. The revision of your working copy has to be a "HEAD".

Steps to recover deleted files or undo the submit in SVN:



  1. Get the HEAD revision from SVN it to your working folder. Working folder is the key word here. (I suggest using temporary folder)

  2. Click on Show Log

  3. In the Log window, select revision you want to undo and click on the "Revert changes from this version" in the popup menu. This will execute the merge command of the corresponding revisions.

  4. Wait for SVN to update your working folder. Working folder is the key word again. SVN updates your working folder first, so you can review the change before you commit it to SVN.

  5. Make sure your sources merged correctly and then commit the change to SVN.


Best luck recovering your sources!

-=Oleg=-

Tuesday, July 28, 2009

IIS Performance

Yesterday we had a little debate in the office about the max number or requests IIS can handle per second. So I did a little research and found that majority of the people are not able to go higher than 300-600 requests/sec, however some claim they were able to get 20000 req/sec. I guess it depends on how much processing work your request does i.e. if IIS is simply returning a HTML page or if it processes ASP.NET page doing authentication, making database requests and constructs the HTML page at the end.

Anyhow, I discovered that IIS 7  has some interesting features wich I was not aware of http://blogs.iis.net/bills/archive/2007/05/07/iis-vs-apache.aspx. I especially like the one that allows you to Troubleshooting Failed Requests Using Tracing in IIS 7.0 http://learn.iis.net/page.aspx/266/troubleshooting-failed-requests-using-tracing-in-iis-70/.

-=Oleg=-

Tuesday, July 14, 2009

Silverlight Styling

Changing the styling of the Silverlight controls is simple. It’s somewhat similar to CSS, but it's more robust and syntax is completely different. What is different in Silverlight and WPF is that you can completely re-define control’s UI and behavior using styles. It took me about 20 minutes from absolute zero to the “Aha!” moment and become an expert in styling WPF and Silverlight applications. Here are the 3 links that helped me to clear the mistery behind Silverlight styles:


1.       Using Style Elements to Better Encapsulate Look and Feel – a good example of how to change control’s properties using styles


2.       Using Control Templates to Customize a Control's Look and Feel – a step further that shows how to make control look anyway you want. In other words how to draw control’s UI from scratch or combine several controls into one. All using styles! Pretty amazing yet simple.


3.       MSDN: Customizing the Appearance of an Existing Control by Using a ControlTemplate – the final piece of puzzle is about how to make control to react on events like Pressed or Disabled and change its appearance. Just few more words about this. Basically every control has a list of pre-defined events (they called states in Silverlight) which can be referenced by ControlTemplate. The list of states differs for each control. This information is available in MSDN on control’s Class page as a list of TemplateVisualStateAttribute attributes applied to the class.


-=Oleg=-

Friday, July 10, 2009

Silverlight 3 has been released

Long awaited Silverlight 3 has been released. Here is the download link:

http://www.microsoft.com/silverlight/get-started/install/default.aspx

New features:
  • Media: New codec support (H.264, AAC, MPEG-4), raw bitstream Audio/Video API, and improved logging for media analytics

  • Graphics: GPU Acceleration and hardware compositing, perspective 3D, bitmap and pixel API, pixel shader effects, and Deep Zoom improvements

  • SEO: Deep linking

  • Application development: multi-touch support, 60+ controls available, and library caching support

  • Data: Data-binding improvements, validation error templates, server data push improvements, binary XML networking support, and multi-tier REST data support

  • -=Oleg=-

    Tuesday, June 30, 2009

    How to serialize / deserialize ANY object using XmlSerializer

    There is a lot to say about object serialization. I just want to cover the gray area when you need to serialize object which has references to other objects, but references are not strongly typed. For example, if you have your classes structured like that:

        public class MainClass


        {


            public object Data { get; set; }


        }


        public class ChildClass1


        {


            //some properties


        }


        public class ChildClass2


        {


            //some properties


        }


     


    where Child Classes can be assigned to Data property of the MainClass and if you construct XmlSerializer object like this


    new XmlSerializer(typeof(MainClass));


    Then both serialization and deserialization will fail throwing an error saying that it has no knowledge of ChildClass1 or ChildClass2 classes. To resolve this error you need to provide XmlSerializer with additional class types which serializer may meet on its way when parsing XML string. Here is how to do that:


    new XmlSerializer(typeof(MainClass), new Type[] { typeof(ChildClass1), typeof(ChildClass2) });


    Here is the set of functions I use to serialize / deserialize my objects:


            public static string SerializeToString(object aObject)


            {


                return SerializeToString(aObject, null);


            }


     


            public static string SerializeToString(object aObject, Type[] extraTypes)


            {


     


                XmlSerializer aSerializer;


                if (extraTypes == null)


                    aSerializer = new XmlSerializer(aObject.GetType());


                else


                    aSerializer = new XmlSerializer(aObject.GetType(), extraTypes);


                MemoryStream aMemoryStream = new MemoryStream();


                StreamReader aStreamReader = new StreamReader(aMemoryStream);


     


                XmlWriterSettings aXMLWriterSettings = new XmlWriterSettings();


                aXMLWriterSettings.Encoding = new UTF8Encoding(false);


                aXMLWriterSettings.ConformanceLevel = ConformanceLevel.Document;


                XmlWriter aXMLWriter = XmlWriter.Create(aMemoryStream, aXMLWriterSettings);


     


                aSerializer.Serialize(aXMLWriter, aObject);


                aXMLWriter.Flush();


                aXMLWriter.Close();


                aMemoryStream.Position = 0;


                return aStreamReader.ReadToEnd();


            }


     


     


            public static object DeserializeFromString(string aMessage, System.Type aType)


            {


                return DeserializeFromString(aMessage, aType, null);


            }


     


            public static object DeserializeFromString(string aMessage, System.Type aType, Type[] extraTypes)


            {


                XmlSerializer aXMLSerializer;


                if (extraTypes == null)


                    aXMLSerializer = new XmlSerializer(aType);


                else


                    aXMLSerializer = new XmlSerializer(aType, extraTypes);


                System.IO.StringReader aStringReader = new StringReader(aMessage);


     


                return aXMLSerializer.Deserialize(aStringReader);


            }


     


    -= Oleg =-

    Thursday, June 18, 2009

    Deploying Silverlight - revisited

    An error of the type:

    Parser Error Message: Could not load file or assembly 'System.Web.Silverlight' or one of its dependencies. The system cannot find the file specified.


    ...


    <%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="asp" %>



    Caused by embedding your application on an .aspx page, can be solved in Visual Studio by simply going to the project containing your page, and for the System.Web.Silverlight reference, change "Copy Local = True". After doing this don't forget to copy the .dll file together with your .aspx page.

    alex~

    How to deploy Silverlight application to a Server

    In two words: 1) copy your *.xap files; 2) make sure .xap and .xaml MIME types are registered.

    Here is more information about registering mime types for Silverlight application.

    Warning, if you are deploying your Silverlight application to a Virtual Folder of the existing website, then most likely you need to copy your ClientBin folder to the root of the website, not virtual folder.

    -=Oleg=-

    Wednesday, June 17, 2009

    Silverlight Password Textbox

    Silverlight Textbox is not the same as ASP.NET.  There is no TextMode property that can be set to "password".

    Silverlight has a special control for Password fields. It's called PasswordBox. 

    Here is the sample of XAML with PasswordBox:
    <PasswordBox Password="HelloWorld" x:Name="pbPassword">

     Another surprise from Silverlight development team is that PasswordBox control doesn't have Text property. In order to retrieve the value of the Password field use the Password property instead:
    string sPassword  = tbPassword.Password;

    Recently I had to work on a prototype where TextBox control was originally used for collecting password information. So, I went and replaced TextBox control with Password control and then changing Text property to Password. Guess what, my code compiled fine but when I tried to run it, it crashed. The reason was in Style property.
    <PasswordBox Password="HelloWorld" x:Name="pbPassword"
    Style="{StaticResource myTextBoxStyle}" >

    This style was defined for the TextBox. This style is not compatible with PasswordBox control. I didn't have a chance to look at what exactly in myTextBoxStyle style is causing problems. I will find it out and update this post.

    One more note about PasswordBox is that it has PasswordChar property which can be used to specify the masking character. It's a nice useless feature with no real value. It would be much nicer if PasswordBox was inherited from TextBox so developers won't spend their valuable time building special cases around this control.

    Oleg.

    Silverlight 3 Beta - My first bug

    At first, our encounter with the Silverlight 3 Beta was a good experience. Nice backward compatibility with code compiled in Silverlight 2, and without a re-compile it supported some new Video formats out of the box (that Silverlight 2 didn't support).

    Unfortunately, a day or two after, something really broke down, and now my Internet Explorer will not run Silverlight and Flash in the same window without crashing my app. Currently we have this issue on the Silverlight.net site:

    http://silverlight.net/forums/t/101974.aspx

    Hopefully someone will take a look at it.

    alex~