Posts

RTL8723AU Realtek driver fails after linux update fix.

After a recent kernel update my wireless stopped working in Fedora 23. dmesg started showing logs like this: [ 5.508212] usb 1-1.4: Vendor: Realtek [ 5.508218] usb 1-1.4: Product: 802.11n WLAN Adapter [ 5.508222] usb 1-1.4: RTL8723AU rev B (TSMC) 1T1R, TX queues 2, WiFi=1, BT=1, GPS=0, HI PA=0 [ 5.508226] usb 1-1.4: RTL8723AU MAC: 20:16:d8:03:97:c1 [ 5.508229] usb 1-1.4: rtl8xxxu: Loading firmware rtlwifi/rtl8723aufw_B_NoBT.bin [ 5.517062] usb 1-1.4: Firmware revision 31.0 (signature 0x2302) [ 5.539427] Bluetooth: BNEP (Ethernet Emulation) ver 1.3 [ 5.539431] Bluetooth: BNEP filters: protocol multicast [ 5.539435] Bluetooth: BNEP socket layer initialized [ 5.859658] usb 1-1.4: Firmware failed to start [ 5.867382] usbcore: registered new interface driver rtl8xxxu [ 5.891270] r8723au: module is from the staging directory, the quality is unknown, you have been warned. [ 5.892132] usbcore: registered new interface driver rtl8723au [ 5.896855] nf...

Dojo ComboBox with JsonRest store and loading indicator.

I was using a JsonRest store to populate a dijit ComboBox and FilteringSelect with auto complete and needed to display a spinner or loading message while the JsonRest store was querying. I googled around for a built in solution and found a couple people asking but no responses. I am not sure if this is the best approach but a quick and easy enough solution for me was to intercept the functions that are called when a search begins and ends. These functions exist within dijit/form/_SearchMixin.js that the ComboBox and FilteringSelect inherit from: _SearchMixin. _startSearch  -> Called when a search starts _SearchMixin.onComplete -> Called when a search ends. Therefore I did something similar to the following to display a loading indicator during store queries. The only down side to this approach is a missing edge case where if the JsonRest store has an error, the loading indicator will continue to display. <!DOCTYPE html> <html lang="en"> <he...

Lenovo Yoga 13 and Screen Brightness On Fedora 21

Just upgraded to Fedora 21 and the screen brightness controls do not work in Gnome. Before Fedora 21 I had modified the following variable GRUB_CMDLINE_LINUX in the default grub file: /etc/default/grub in order to append `acpi_backlight=vendor` #emacs /etc/default/grub GRUB_CMDLINE_LINUX="...existing vars here... acpi_backlight=vendor" After the upgrade I had to change this from acpi_backlight=vendor to acpi_backlight=intel. Once the file is updated run: #grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg Once done, reboot and the screen brightness controls should work however the screen brightness range goes from 0 to 4882 (/sys/class/backlight/intel_backlight/max_brightness) instead of around 100 to 4882 so if you dim the brightness all the way down, your screen will be completely black.

Understanding DB2 OLAP By Example

The OLAP features in DB2 are very cool however I don't see a lot of people using them. In addition, sometimes reading the docs on these features are overwhelming so hopefully these examples will make it easy to understand. We'll look at the following OLAP features in particular. There are more available if you navigate to the IBM website for your DB2 version. Rollup Cube Grouping Set Rank Dense Rank Row Number  First we need to create a sample table and data: CREATE TABLE sales( item VARCHAR(20), state CHAR(2), store VARCHAR(20), amount DECIMAL); Then lets insert some sample data: INSERT INTO sales VALUES('Watch', 'IL', 'Buymore', 15); INSERT INTO sales VALUES('Watch', 'NY', 'Buymore', 15); INSERT INTO sales VALUES('Watch', 'NY', 'Buymore', 15); INSERT INTO sales VALUES('Watch', 'NY', 'Buymore', 15); INSERT INTO sales VALUES('Watch', ...

Disabling the Lenovo Yoga Touchpad and Keyboard In Fedora

I can't find an easy way to disable the mouse and keyboard on screen flip of the Yoga in Fedora however an easy enough approach is to disable them by hand using xinput. Issue an: xinput --list [richie@localhost ~]$ xinput --list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ Logitech Unifying Device. Wireless PID:1028 id=9 [slave pointer (2)] ⎜ ↳ ELAN Touchscreen id=10 [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics TouchPad id=14 [slave pointer (2)] ⎜ ↳ Microsoft Natural® Ergonomic Keyboard 4000 id=15 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Video Bus ...

MythTV transcoding user job

For some reason I was having trouble with existing online MythTV transcoding jobs. Specifically this and MythBrake were nice but after many attempts I couldn't get HandbrakeCLI to output a decent quality video and opted to write my own using ffmpeg . Please be aware this script will automatically cut out commercials even if mythcommflag is inaccurate. To get started copy the script into a file on your mythbackend box. In the example below it is called transcode.sh. Then `chmod +x` and review the contents of the `./transcode.sh -h` help command like so: [richie@localhost mythtv]$ chmod +x transcode.sh [richie@localhost mythtv]$ ./transcode.sh -h Transcodes a video to .mkv auto cutting commercials. User job example: /home/richie/mythtv/transcode.sh -c %CHANID% -s %STARTTIMEUTC% -v show version -h show usage -l limit CPU usage -s [arg] starttime from mythtv. In user job %STARTTIMEUTC% -c [arg] chanid from mythtv. In user job %CHANID% -u [arg] ...

.Net Listing Classes or Methods With A Particular Attribute.

Whenever I build a website I always like to build an admin section and expose information such as which actions are cached, which controllers require authorization and which fields are required etc. Luckily in .Net MVC most of these things are implemented as attributes. Here is an example of scanning an assembly and listing all the classes and methods with a particular attribute on them. I chose two random attributes for this example: [Obsolete] public class Program { public static void Main(string[] args) { var program = new Program(); var types = program.GetAttributesOnClasses (); foreach (var t in types) { Console.WriteLine("Class: {0} - Attribute: {1}", t.Type.Name, t.Attributes); } var methods = program.GetAttributesOnMethods (); foreach (var method in methods) { Console.WriteLine("Method Name: {0} - Attribute: {1}", method.MethodInfo.Name, method.Attributes);...

Why don't more people use the .Net Settings as opposed to Config settings.

I see a lot of people putting key-value pairs in web.config/app.config files and then using them in their applications via var someConfigKey = ConfigurationManager.AppSettings["someConfigKey"]; int count; if (int.TryParse(someConfigKey, out count)) { //// Do Something } However I rarely see people using application settings. I won't go into depth on what application settings are as the Microsoft website has a pretty good explanation of them here however Settings are strongly typed and so the above lines of code can all be replaced with: var count = Properties.Settings.Default.Count; I might be missing something here but it seems like the latter is much more convenient to use if you are simply using the appSettings section of the .config file. Of course it is a different story if you are using .config sections which are serialized into objects but for the most part what I can figure is that many people don't know about .net Settings. Take this or this s...

VB.Net Gotchas

VB.NET is a very user friendly language however I find its user friendliness to be quite confusing and error prone, especially when switching back and forth between C# and VB. Simple things like VB's handling of null or concatenation can lead to bugs if your not careful. For example: Sub Main() Console.WriteLine("The value of Nothing is also the value of the default type: " & (Nothing = False)) Console.WriteLine("The value of Nothing is also the value of the default type: " & (Nothing = 0)) Console.WriteLine("The value of Nothing is also the value of the default type: " & (Nothing = String.Empty)) Console.WriteLine("The & operator with two integers concats both: " & (3 & 4)) Console.WriteLine("The + operator with two integers adds both: " & (3 + 4)) Console.WriteLine(...

.Net Winforms Basic BackgroundWorker Example

I use a BackgroundWorker a lot when working with WinForms in order to perform database or webservice calls without freezing the UI thread. Of course web services can be called using their built in asynchronously methods however when you have a separate data access or model layer, these asynchronous methods are not readily available.  On a new project I was working on, I was looking for a basic example online for quick reference but there wasn't one amongst the top search results so I thought I'd post one. using System.ComponentModel; using System.Threading; using System.Windows.Forms; public partial class MainForm : Form { private readonly BackgroundWorker backgroundWorker = new BackgroundWorker(); public MainForm() { this.InitializeComponent(); this.backgroundWorker.DoWork += this.BackgroundWorkerDoWork; this.backgroundWorker.RunWorkerCompleted += this.BackgroundWorkerCompleted; t...

Easy .NET MVC Active Directory Attribute Based Authorization

Active Directory based authorization in .NET is fairly easy. Just throw an attribute on a controller as follows: [Authorize (Roles="MyAdGroup")] public class SettingsController : Controller Sometimes though you do not want to hard code a role in an attribute as you may want to add or remove roles at will. You may also want to change the roles based on whether you are in production or not. I like to keep my Active Directory roles either in a database or a web.config file so that others can change authorization on the fly. In order to have greater control over your authorization roles you need to extend the AuthorizeAttribute and override AuthorizationCore. You also need to override HandleUnauthorizedRequest in order to have a custom redirect page. /// <summary> /// Redirects to the unauthorized page. /// </summary> public class AuthorizeSiteRedirect : AuthorizeAttribute { /// <summary> /// Authorization based on roles in...

Common.Net library methods: Querying Active Directory for users and groups

Finding the groups a user belongs to in active directory along with the members of that group is something that comes up a lot when .Net apps use Active Directory for authentication. Here are some common library methods to find members of a group or groups a member belongs to. This code requires a reference to System.DirectoryServices.AccountManagement. using System; using System.Collections.Generic; using System.DirectoryServices.AccountManagement; using System.Linq; public class ActiveDirectoryGateway { private readonly string domain; private readonly ContextType contextType; public ActiveDirectoryGateway(ContextType contextType, string domain) { this.contextType = contextType; this.domain = domain; } /// <summary> /// Retrieves a list of AD groups belonging to an AD User. /// </summary> /// <param name="user">The active directory ...

Common .Net Library Methods: Easy XML Serialization and deserialization

Serializing XML to an object of a given type and back has been very common in a lot of my projects. It may not be allowable when you are working on multiple projects in different groups to import a common class library so I thought I'd post some basic serialization code generic to most projects that I have had to use a lot lately. /// <summary> /// Deserializes an XML document into a given type. /// </summary> /// <typeparam name="T">The type to deserialize.</typeparam> /// <param name="xml"> The xml. </param> /// <returns> An object representative of the XML document. </returns> public T Deserialize<T>(string xml) { var xmlSerializer = new XmlSerializer(typeof(T)); using (var reader = XmlReader.Create(new StringReader(xml))) { if (xmlSerializer.CanDeserialize(reader)) { ...

WCF Logging raw soap requests.

To troubleshoot a contract filter mismatch or other WCF fault message being thrown from  third party consumers, here is the web.config settings that will show the raw soap requests to inspect if the caller is using a malformed request. Please be aware that the first thing to do when troubleshooting a contract filter mismatch is to ensure the web reference is up to date and running. This message can be very deceiving such as if you are calling a web service from a web service, and the latter web service is not running or running on a different virtual etc. Make sure the first section is contained within System.Servicemodel. As you can see I do not show the opening tag tag. <!-------- within the system.servicemodel element --------&gt <diagnostics> <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="false" logMessagesAtTranspo...

Getting Citrix Receiver Working on Fedora 19

Download the Citrix Receiver in RPM format here: http://www.citrix.com/downloads/citrix-receiver/linux.html As sudo or root, issue a `yum install ICAClient*.rpm`. Click on the .ica link in your xenapp citrix website. When prompted to open or download the .ica file, select download. Run `/opt/Citrix/ICAClient/wfica.sh launch.ica` in the directory where launch.ica was downloaded to. If you see error messages like, "Error while loading shared library : libpng12.so.0 : can not open shared object file ", issue a ` yum install libpng12.i686 libpng12-devel.i686`.  Go back to your Citrix website, and click on the .ica link again. This time instead of downloading it, select open with , and choose, "/opt/Citrix/ICAClient/wfica.sh".  The Citrix receiver will now complain about  you not having a trusted certificate. You will need to find the certificate needed and place it in the following folder, "/opt/Citrix/ICAClient/keystore/cacerts/". For example if you n...

VB.Net Cross Thread Events in WinForms

Today I quickly did a proof of concept on integrating a third part component into a winforms application and had to figure out how to raise events on the Windows Forms UI thread from a different one. There are plenty of examples of doing this in C# but they didn't quite translate to VB.Net. Although a BackgroundWorker may have worked I had some more complex requirements. Therefore I slightly tweaked a C# cross thread example on stackoverflow and combined it with another example of building a custom event. Here is what I came out with. I have to investigate better ways of doing this but since there is a lack of any VB.Net examples I thought I would post one. Imports System.ComponentModel Imports System.Threading Public Class CrossThreadingExample Private dummyThread As Thread Private ReadOnly crossThreadEventList As New List(Of CrossThreadEventHandler) Public Delegate Sub CrossThreadEventHandler(sender As Object, e As CrossThreadEventArgs) Public Custom E...

Querying IIS Log File Information Easily

Microsoft has a command line tool called LogParser that can easily be used to execute SQL statements against log files. The tool is extremely handy when there is problem with a web service or site hosted by IIS. For example to see if a rogue consumer of your web service is doing something silly like looping through and flooding it with calls you can query the most called web service by IP address by issuing: .\LogParser.exe -i:W3C " select count(*), date as date, cs-uri-stem, c-ip from \\servername\logs\current\* group by date, cs-uri-stem, c-ip having count(*) > 500000 " -rtp:-1 This will return a nicely formatted result like so: COUNT(ALL *) date cs-uri-stem c-ip ------------ ---------- ----------------------------- ------------- 510832 2013-07-11 /ExampleServices/Test.asmx 10.1.1.1 535199 2013-07-11 /ExampleServices/Example.asmx 10.1.1.2 Log parser...

Getting the Lenovo Yoga wireless driver working in Fedora 18

If you are like me you installed Fedora 18 off the live CD only to find that you can't do anything because the wireless card does not work by default. To get wireless working the first step is to install the build tools needed to install the driver. The easiest way to do this is to download the install DVD to a USB thumb drive. Once you plug it into the Yoga, Fedora will mount the drive automatically. Figure out where it mounted by going to Dolphin or whatever file manager you use and viewing the path to the drive. Now go into your yum repos and temporary change the yum repository to point to the live dvd image. [richie@localhost ~]$ su - Password: [root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# gedit fedora.repo change from [fedora] name=Fedora $releasever - $basearch failovermethod=priority #baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/ mirrorlist=https://mirrors.fedoraproject.org/metalink?...

Selenium 2 Java Quick Setup

I had a seemingly random issue with a website where it would fail one out of x times. Since I haven't used Selenium 2 yet I thought I would run a Selenium test. To get started in Selenium 2 and Java the quickest way is to use Selenium IDE and generate some tests. Then use the File -> Export Test Case As -> Java / JUnit 4 WebDriver Backend. After the test is created then just drop it into Netbeans or Eclipse. The first stumbling block I ran into was that I needed Both Selenium Client and Selenium Server Jars added. Without the Selenium Server Jar, I saw an unhelpful error that stated: "com/google/common/base/Function". After adding those 2 Jars, if you don't use the Eclipse or Netbeans test runners, make sure to add the JUnit Jar. Then you can run your test. Here is a shell that does nothing but run a test that was outputted from Selenium IDE. package webdriversample; import com.thoughtworks.selenium.Selenium; import org.junit.After; import org.junit.Asser...

Setting up Apache To Work with PHP and Zend Framework in Fedora for Development

To get started the first thing we need to do is install Apache and PHP. yum install httpd php You can setup Apache to run in any users public_html directory but I am the only one using my computer and I like to name my websites directory whatever I want so we have to create the folder and give Apache permissions to it: mkdir ~/websites chmod 711 /home/accessrichard chmod 755 /home/accessrichard/websites After that we have to set Apache to redirect our localhost traffic to the above website directory. Create your own Apache config file in /etc/httpd/conf.d touch /etc/httpd/conf.d/accessrichard.conf Add something similar to the following in the file we just created replacing your home directory name and your website folder name as appropriate. In the below example I am setting up 2 different websites, demo.dev and demo2.dev. NameVirtualHost *:80 < VirtualHost *:80 > ServerName demo.dev DocumentRoot /home/accessrichard/websites/demo/public SetEnv APPLICATION...