CodeWrapper.com RSS - Code Snippets http://www.CodeWrapper/Snippets Presenting 20 latest Code Snippets. en-US CodeWrapper.com RSS Feed Dynamically changing log4net file name. http://www.CodeWrapper.com/Snippets/View/108/dynamically-changing-log4net-file-name 129283770770540866 marko This code snippet shows how to set log4net file name. First, let us have a look at the configuration section: andlt;appender name=andquot;MyRollingFileAppenderandquot; type=andquot;log4net.Appender.RollingFileAppenderandquot;andgt; andlt;file type=andquot;log4net.Util.PatternStringandquot; value=andquot;\%property{Name}andquot; /andgt; andlt;appendToFile value=andquot;trueandquot; /andgt; andlt;rollingStyle value=andquot;Sizeandquot; /andgt; andlt;maxSizeRollBackups value=andquot;-1andquot; /andgt; andlt;maximumFileSize value=andquot;10MBandquot; /andgt; andlt;staticLogFileName value=andquot;trueandquot; /andgt; andlt;layout type=andquot;log4net.Layout.PatternLayoutandquot;andgt; andlt;conversionPattern value=andquot;%d | %t | %m%nandquot; /andgt; andlt;/layoutandgt; andlt;/appenderandgt; Now we need to dynamically change the "Name" property. ASP.NET MVC - writing HTML Helper for rendering partial view into string using C#. http://www.CodeWrapper.com/Snippets/View/107/asp-dot-net-mvc-writing-html-helper-for-rendering-partial-view-into-string-using-c-sharp 129283770770658046 Davido While searching the web in order to find a way to render partial view from a controller, I found a code snippet example who does exactly what I want - rendering ASCX file into a string. ASP.NET MVC - writing HTML Helper for creating image link html tag in C#. http://www.CodeWrapper.com/Snippets/View/106/asp-dot-net-mvc-writing-html-helper-for-creating-image-link-html-tag-in-c-sharp 129283770770804521 Davido It is very common when you need to use HTML helper in ASP.NET MVC framework to create an image link. The default set of HTML helpers do not include such HtmlHelper. This code shows how to write HTML Helper for linking image or just the image tag. Using Speech Recognition Engine in C# for speech to text. http://www.CodeWrapper.com/Snippets/View/105/using-speech-recognition-engine-in-c-sharp-for-speech-to-text 129283770770902171 lior_gr This code example shows a simple example of using SpeechRecognitionEngine in .NET 3 and later in order to convert voice to text. The grammar is a DictationGrammar but you can also specify a of optional choices. Get information about threads in current process in C#. http://www.CodeWrapper.com/Snippets/View/104/get-information-about-threads-in-current-process-in-c-sharp 129283770770990056 Philipo This code snippet shows how one can get threads information of all threads process. You may get thread's ID, priority, state and more. For more information see ProcessThread. How to receive a SMS message in Android. http://www.CodeWrapper.com/Snippets/View/103/how-to-receive-a-sms-message-in-android 129283770771068176 Davido Receiving SMS message in Android application is very easy task. First, we will add receiver tag to our application.menifest: andlt;receiver android:name=andquot;.SmsReceiverandquot;andgt; andlt;intent-filterandgt; andlt;action android:name=andquot;android.provider.Telephony.SMS_RECEIVEDandquot; /andgt; andlt;/intent-filterandgt; andlt;/receiverandgt; Also, we need to add permissions to receive SMS: andlt;uses-permission android:name=andquot;android.permission.RECEIVE_SMSandquot;andgt;andlt;/uses-permissionandgt; WCF Dicovery according to WS-Discovery protocol. http://www.CodeWrapper.com/Snippets/View/102/wcf-dicovery-according-to-ws-discovery-protocol 129283770771156061 lior_gr .NET framework 4 introduces the WCF service discovery method. The service host can also add the discovery support in the application config file (MSDN). For more information about WCF discovery - read in MSDN IPhone - show simple alert using objective C. http://www.CodeWrapper.com/Snippets/View/101/iphone-show-simple-alert-using-objective-c 129283770771243946 iphoneman This simple objective C code illustrates how to show alert with OK button. Getting Last Known Android GPS Location with Java. http://www.CodeWrapper.com/Snippets/View/100/getting-last-known-android-gps-location-with-java 129283770771322066 Davido Using Android API to get the last known GPS location. In order to get the last known location, we need to use the LocationManager in order to get the location provider which we can use to get the actual GPS location. You can read more about the android.location package here Send Twitter status update using LinqToTwitter in C#. http://www.CodeWrapper.com/Snippets/View/99/send-twitter-status-update-using-linqtotwitter-in-c-sharp 129283770771400186 Kobo_t The following example will show you how to authenticate into Twitter using LINQ To Twitter (LinqToTwitter) API and send simple status update. The source code from CodePlex includes a lot of examples of how to use LINQToTwitter API. Using .NET 4.0 MemoryMappedFile for inter process communication in C#. http://www.CodeWrapper.com/Snippets/View/98/using-dot-net-4-0-memorymappedfile-for-inter-process-communication-in-c-sharp 129283770771468541 lior_gr .NET 4.0 Framework introduces System.IO.MemoryMappedFile for sharing memory between different processes on the same machine. You can create multiple views of the memory mapped file, including views of parts of the file. Read more on the MSDN Load file into FTP server using FtpWebRequest in C#. http://www.CodeWrapper.com/Snippets/View/97/load-file-into-ftp-server-using-ftpwebrequest-in-c-sharp 129283770771556426 Davido This code snippet will show you how to use System.Net.FtpWebRequest to upload file into a FTP server. It is also possible to get list of directory from FTP and download files using FtpWebRequest. For the code below, add the following directives: using System.Net; using System.IO; Example of Dynamic ExpandoObject in C# 4.0. http://www.CodeWrapper.com/Snippets/View/96/example-of-dynamic-expandoobject-in-c-sharp-4-0 129283770771663841 lior_gr The ExpandoObject enables to create new members for an object in runtime. The ExpandoObject was introduced in C# version 4.0. In order to use ExpandoObject , you will have to add reference to System.Dynamic. Writing your first JQuery plugin with options. http://www.CodeWrapper.com/Snippets/View/95/writing-your-first-jquery-plugin-with-options 129283770771761491 lior_gr This tutorial will show you how to create very simple jQuery plugin including passing options to the plugin. This plugin will give you the same functionality of $(selector).css() (it is just for the sake of the example). Install and uninstall X509Certificate in personal certificates store. http://www.CodeWrapper.com/Snippets/View/94/install-and-uninstall-x509certificate-in-personal-certificates-store 129283770771849376 Davido This code snippet will show you how to install and uninstall a X509Certificate in personal certificates store. Validate X509Certificate according to a chain policy. http://www.CodeWrapper.com/Snippets/View/93/validate-x509certificate-according-to-a-chain-policy 129283770771937261 Davido This code snippet will show you how to validate a X509Certificate according to X509ChainPolicy. If the code return true, it means that the certificate is valid according to the specific X509ChainPolicy but can be not valid for other usages such as SSL, SMIME etc. You can specify the revocation (Certificate Revocation List) mode - Offline, Online or not to check. How to add and remove cookie with JQuery. http://www.CodeWrapper.com/Snippets/View/92/how-to-add-and-remove-cookie-with-jquery 129283770772054441 mordec This code will show you how to add/remove a cookie using Klaus Hartl JQuery plugin. Active Directory - check if a user exists - C#. http://www.CodeWrapper.com/Snippets/View/91/active-directory-check-if-a-user-exists-c-sharp 129283770772122796 mordec This code snippet, shows how to query active directory and search if a specific username exists. Serialize and Deserialize object in C# with a specific Encoding. http://www.CodeWrapper.com/Snippets/View/90/serialize-and-deserialize-object-in-c-sharp-with-a-specific-encoding 129283770772200916 Philipo This code snippet shows how to Serialize and Deserialize object with a specific encoding. The main idea is to use memory stream along with XmlTextWriter by specifying the encoding type. When using StringBuilder, it will always be translated into UTF-16 (unicode). Adding onKeyUp event to TinyMCE editor. http://www.CodeWrapper.com/Snippets/View/89/adding-onkeyup-event-to-tinymce-editor 129283770772279036 Phosty This code snippet will show you how to register to onKeyUp event in TinyMCE editor.