Monday, December 11, 2017

Spectrum DNS Servers

I recently discovered that Spectrum is totally incompetent when it comes to DNS servers.

My ISP is Spectrum, and recent speed tests showed I'm getting over 100mps, which is great. But I kept getting random and intermittent drops when connecting over the internet. At first I thought it was the website I was trying to reach, but my mom, also was experiencing similar problems with unrelated sites, and more severely.

I stumbled upon the idea of checking my DNS configuration--and sure enough both mine and my mom's were using servers managed by Spectrum. I changed them to using Google servers (8.8.8.8 for primary, 8.8.4.4 for secondary) and just like that our problems went away.

Which leaves me to wonder why Spectrum even bothers with a DNS server. The nature of this problem can be difficult to diagnose for a non-technical person, and Spectrum's support center is unlikely to consider checking these servers as the source of the problem - - leaving their customers nothing more than pissed at them.

But anyway, if Spectrum is your ISP, I'd recommend you change the DNS servers you use and avoid the headaches of Spectrum's incompetence. A simple Google search will help you if you don't know how to do this.

Wednesday, October 22, 2014

Is it English?

After recently changing jobs, I was given a major project to redo their website, written in Php, picking up where a contractor had left off.  I had warned them that my Php knowledge was all but nonexistent, but I was tasked to it anyhow, successfully deploying in about 100 days.

The experience taught me something--so long as the programming language is founded in English, there is no problem in learning it.  Php has similarities to C, so was pretty easy.

Tuesday, January 14, 2014

Windows 7 Streaming Media--resolution

Okay--I think I jumped the gun a bit.

Researching things, it looked like I should be able to run Windows Media Center and stream the TV data pretty easily.

But I couldn't get it to work, because I couldn't get that stupid "Turn on Media Streaming" button to work.  I tried everything recommended in all the Google search, and nothing worked.

But I finally found the solution, and it was about as stupid as it gets.  Why no one thought to recommend trying this first, I'll never know.

Solution: Run Windows Media Player as an Administrator.  Then select the "Streaming" and "Turn on streaming" selections.  Make sure you had the Network and Sharing Center closed before you started.  The button should work now.

All the other recommendations sounded crazy and nuts--like WMC and WMP simply got hosed up somehow.  But starting as an administrator makes sense--but it would have been nice if Microsoft was smart enough to have realized this necessity, or that their code was bugged and not properly identifying the need to run as administrator.  Yes--this is a bug that seems relatively common and yes--this is Microsoft's screw-up.

Okay--unless something new pops up--then my media streaming project is complete--I didn't really want to do this anyhow as it felt like I was reinventing the wheel.

TV Tuner Card to Media Streaming project, part 1

Okay, I don't use this blog much, and I probably should.  I originally intended this blog as a place to put great tidbits I learn--to make it easier for me to find in the future. If someone else finds this useful, then great--but otherwise, I really don't care.

So, in the interest of keeping track of things I find useful, I've got a new personal project I'm starting.  Maybe it'll come out to something useful, maybe not, and maybe it'll take forever for me to complete.  But here it is.  I've got other projects I've done for personal benefit that I haven't put any notice in my blog--I might start documenting my efforts in those in other blog posts.

Problem

I have a number of computers.  I have one high-end PC I built myself and one low-end laptop, both running Windows 7 64-bit.  My friend was kind enough to sell me his old PC and laptop for pretty cheap, both running Windows Vista.  I don't know much yet about their processing power, but I can already tell they are not any better than my low-end laptop.  But that's okay, and I am considering using the old PC for Linux.

On the high-end PC I have installed a TV Tuner PCI card.  Brand is irrelevant as there is no API for it.  I want to stream live TV from this tuner to any other PC or laptop on my network, and control the channels from the client PC.

Windows Media Center offered promise of being able to do this, but it does not look hopeful--and possibly overly complicated to get to work (although if someone knows a simple solution, I'm all ears).  I've tried enabling network media streaming, but the stupid button Microsoft offers doesn't do anything, and I've tried everything I've found in Google searches (deleting WMP libraries, uninstalling/reinstalling WMP and WMC, messing with the Windows Firewall)--nothing works.  A simple error message would speak volumes, but apparently MS didn't have the time to provide error messages here--better to simply draw users to a button that does nothing.  I found plenty of others experiencing the same problem--but no solution that works for me.

Anyway, that is the problem--stream live TV from the PCI tuner to another PC and control the tuner from the remote PC.

Solution

Doing this all through Windows Media Center would be great.  I found WMC to be a really nice application.  Easy to schedule recording, pleasing user interface, easy to pause (this was nice on live TV--neat new function for me to experience).  All these features are desirable to have on a remote PC.

What gets me is that the technology is all possible--it isn't even that complex compared to other features that are already available.

In fact, had I been smart, I could have purchased a network-based tuner instead of a PCI tuner and not had anything else to do.  But alas--I wasn't aware of the network-based tuners until it was too late, and I'm cheap--I don't spend any more than I have to.  Heck, I don't even have any premium TV service--it's a waste of money.  My TV is all over-the-air broadcast.

But nothing seems premade to do what I want.

And why even do this when there's Netflix and other internet solutions?  Well for one thing--I'm cheap.  I don't use any subscription services.  I'm so cheap that my internet access is limited--I have a good high-speed access, but cannot use more than 10GB a month--and I regularly run out on the last few days of every month.  Video over internet is simply not an option to me.

Maybe I am alone in this need, which would explain why I have not been able to find a pre-made solution.

So, to solve this problem, the best way is to break it up into parts.

Part 1 is the server, the PC with the tuner.  The Tuner video stream needs converted to a network stream.  Simple TCP/IP is easy.  But the true network solution will depend on the client, so the protocol used might not be so simple.

Part 2 is the client on the remote PC.  Ideally, Windows Media Center would be used, but that would mean being able to use a protocol that WMC understood--and at this stage I have no idea what protocols WMC or any other video streaming client uses or is capable of using.  Alternatives to WMC include VLC, or even building one from the ground-up.  I really don't like the idea of this last one, since WMC has such a good user-interface.  I hate building user-interfaces.  They're all grunt-work.  Don't take any brains--just artistic talent (of which I have none, nor any patience for).  I like building the engines.

For part 1, I found this DirectShow.Net library, which has samples for getting to the video stream of a tuner card and for changing channels.  It also has samples of video players that I should be able to build from, it WMC and VLC don't work out.  It doesn't matter if I can't control the card from WMC or VLC if those options work--I can always build a simple client that connects to the DirectShow.net library application I build on the server PC to control the tuner (I'd just invent a simple proprietary protocol for handling that--maybe use WCF, or just use standard System.Net stuff).

All the features that I need include being able to change channels and pausing the live stream.  Recording is moot--I can just use WMC directly on the server PC for that--the remote capability for this is irrelevant (except in the case of an ad hoc decision).  If I can use WMC or VLC on the client, they automatically have the capability of pausing, but they might not have the capability to change channels (which is where a special control client will come in).  If I have to spin my own client, adding pause might not be straight-forward.  To make this possible, then going from network stream to video stream, I really need to cache the network stream first, and a question is, can I cache to disk fast enough for the video stream to not have a problem.  The cache will need opened for read and write.  This will be a bit of new territory--I've only worked with full file streams over FTP protocol--I've never started a read on a stream while it is still being written to.  An additional complexity is to consider when the cache elements should be deleted.  In a worst case scenario, if I am watching one stream for hours--do I keep that stream untouched on disk the entire time (giving me the ability to restart from the beginning), or do I delete viewed parts of the stream after a period of time?  Since it would be easier to not deal with it, and since disk space is not really of concern, I would probably only purge the cache when the channel is changed or the client is closed, or the stream is stopped.  If recording is desired to be added to this custom client, scheduling should not be implemented, since it can be handled better in 
WMC.  Recording can be simply a matter of marking start and stop points in the cache and copying out the parts of the cache between those points.

Okay--a bit of rambling as my brain spills out.  My next task will be to drop the DirectShow library into a C# project and examine the samples.  After that, I need to figure out what the protocol is that WMC can use.  I already know that VLC can use a few different protocols, including HTTP, but its interface wasn't as pleasing, and it seemed a bit more difficult to configure for the stream.  Of course, I am the kind of person the firmly believes that if a manual is needed for basic functionality, then the product was not designed correctly.  You shouldn't have to use a manual to know how to plug a TV into the power outlet and where to put the video cable in and start watching your TV--a manual is okay for more advanced functions, but if the TV were so complex that you had to pull out the manual just to figure out how to give it A/C power, then the designer should face an execution squad.

But anyway, I'll post updates as I make progress on this project.  The updates may come quickly or they may be few and far between--it all depends on my success and how much time I devote to this.

Thursday, October 17, 2013

Hoaxes

I've got a couple of blogs, and I don't really post much on this technical blog.  I use this one mainly for myself--to make it easier for me to find my own little tricks.

But I thought I'd get on a soapbox and speak out against something that has been bothering me lately--Facebook Hoaxes.

Now, I value my privacy, but I also like to remain connected to my friends.  I'm on Facebook as an easy way to keep in touch, but I also don't post much to it.  I don't go posting about what I had for lunch--and get annoyed when others think I care about the minutia of their lives (those are usually the ones I "unsubscribe" to), but I do post little bits here and there that I think might make someone's day a bit better.

Lately, I've seen some of my friends advertise idiocy by perpetuating various hoaxes on Facebook, namely variations of privacy protection.  It's gotten extremely annoying to me because I can tell in an instant that it's a stupid hoax--I don't need to look it up to know that--but I'll look it up to get the reference that proves it.

One hoax, mentioning a "Graphic App", states that you need to uncheck posting options on a the poster, then add the comment "done" so that they will know to do the same to you (Snopes link: http://www.snopes.com/computer/facebook/graphapp.asp).  The stupidity of this is that doing this does NOTHING to protect your privacy, but will instead keep you and your friend from seeing posts each other make.  It will not stop any stranger from looking you up and browsing through any and all information that you have made PUBLIC on Facebook.

The other hoax I've lately seen is one that tries to use legalese and copyright to protect your private information and photos (Snopes link: http://www.snopes.com/computer/facebook/privacy.asp)--something that completely ignores the TERMS OF USE that YOU AGREED TO when you signed up to Facebook.  When I first saw this (there is a reference to the "Rome Statute" in it), I wanted to go right into the person's profile and SHARE everything in it--just to make a point.

My point in this is that if you are concerned about keeping your things private, then DON'T POST THEM WHERE THE WORLD CAN SEE IT!  You want to say something or post a picture that only your friends can see?  There is a setting in Facebook called "Friends".  If it says "Public", then the world can see it.  Change it to "Friends"--you have that control.  If you don't want even your friends to see it, then why are you putting it in Facebook in the first place?  What is wrong with you?

On Facebook, I posted some information I wish to keep private, but I've set it so that only my friends can see it.  They won't be able to share it--but I do trust them not to cut-and-paste it into a post of their own.  But even then--it wouldn't be the end of the world--the information I post IS public information, obtainable by other means (just a bit more difficult).  The things that really matter don't get posted anywhere, except where only I have access to.  Things like my social security number is safely hidden away, and you won't find it even if you get my password to my accounts.  But things like my photos--so what?  If I had any compromising photos of myself, you can rest assured I'd not be stupid enough to post them where anyone in the world could easily obtain them.  If you are concerned that someone might share and spread that naked photo of yourself--don't be stupid by publishing it.

Monday, March 4, 2013

WPF and MessageBox in Dispatcher.Invoke

Painful, painful, painful.

That was my experience when a WPF application I was creating would display a MessageBox on startup.  For efficiency many things were going on simultaneously, and most was tripped off with Dispatcher.BeginInvoke.  If something needed user interaction at startup, a MessageBox would display to get the user's attention.  The problem was, it was not modal, so the user would see the MessageBox flash and disappear, with the default value selected (which was very problematic).

A google search finally revealed the answer.  When using Dispatcher.Invoke, you need to pass the owning window to MessageBox:

MessageBox.Show(this, "message");

Friday, February 1, 2013

Helper for System.Diagnostics.Process

It's one thing to kick off a process from C# using Process.Start out of System.Diagnostics.  Nothing to that.  But what if you want to send the process some input beyond the arguments?  Or you want to perform processing on the output is sends to the console?



This code provides that help.

Just call ProcessHelper.Start.

The delegates for output and error provide a mechanism for processing each line of output.  The delegate will be called for each line produced.


This code below provides a simple example of how to use the ProcessHelper.  Each line of output is simply added to the StringBuilder objects.




StringBuilder outData = new StringBuilder();
StringBuilder errData = new StringBuilder();

System.Diagnostics.Process p = ProcessHelper.Start("MyProcess.exe", "arg1 arg2 arg3", "Standard Input Data",
        delegate(string parm)
        {
            outData.AppendLine(parm);
        },
        delegate(string parm)
        {
            errData.AppendLine(parm);
        }
);

p.WaitForExit();

Friday, May 18, 2012

ClickOnce Hell

This post is just a comment on my basic impression of ClickOnce, after having lived through developing for it for several years.

If your application is relatively small and simple, ClickOnce is great.  Basically, one (maybe two or three) project in the solution, compile size relatively small (to handle slow connections if necessary).

The problems start to arise when your solution starts to get complex.  Multiple projects, with references in XAML crossing the projects, and it gets a bit tricky.  Stuff that works fine in Visual Studio tends to not work once deployed through ClickOnce, unless you are very careful in your reference definitions.  It only takes one misdefined definition, and the whole thing can break--and the error messages received will likely be too generic to easily find it.

So with a complex application, ClickOnce becomes completely unfeasible.  In my opinion, it's a piece of crap, unless you keep your application small and simple--then it's great.

I use it on my small and simple applications as it offers easy deployment.

But on the one complex application I support, originally it was deployed as ClickOnce, but at some point the ClickOnce deployment broke, probably due to an incorrectly defined reference.  The application worked fine in Visual Studio, or when installed using WiX.  But it would go so far in ClickOnce, then blow up, and I never could figure out what ClickOnce didn't like.

So it was easier to give up on ClickOnce and switch to installing with WiX and use our own home-grown mechanism for updating the application.  That home-grown mechanism had its own set of problems, but at least it was under our control.

As a final note: WiX is great.  Being driven by XML allowed automatic update of the project definition through Team Systems Build.  If  I get around to it, I might post the recipe for this.  Leave a comment if this recipe would be valuable to you (to encourage me to post it sooner).

Assembly Unloading

I needed a simple way of checking version information of an assembly that was not loaded into memory.  On System.Reflection.Assembly, there is the Load method, but unfortunately, now the assembly is in memory with no way of unloading it--eating up precious RAM.

However, .NET offers the AppDomain.  Simply create a new AppDomain and load assemblies into that for reviewing information of the assembly, then unload the domain.

Example:


System.AppDomain newdomain = System.AppDomain.CreateDomain("DataVerification");
Assembly assm = newdomain.Load("MyAssembly.dll");
MessageBox.Show("Assembly version: " + assm.GetName().Version.ToString();
System.AppDomain.Unload(newdomain);

Tuesday, April 17, 2012

Perceived Types


Never could figure this one out complete.  We have an application that looks in the ClassesRoot Registry for the extension of a file, looking for the "PerceivedType" entry, and rendering an image if the PerceivedType is "image".  The problem for this particular computer was that its initial configuration was bad, and it had no extensions configured to image.  No idea why, nor how to automatically fix it or prevent it going forward.

Simple solution was to create a Registry merge file that included all extensions and added the "PerceivedType"="image" to all of them.  However, I stumbled onto a Windows Shell API call that would first check some hard-coded extensions for their perceived type, then check the registry, so there was potential that if our application used this call, AssocGetPerceivedType, the problem may not have surfaced in the first place.

But I could not find an example of the call defined in C# anywhere.  What a pain!  You mean no one has written C# that needs this call???????

I found C declaration for the call:

HRESULT AssocGetPerceivedType(
  __in       PCWSTR pszExt,
  __out      PERCEIVED *ptype,
  __out      PERCEIVEDFLAG *pflag,
  __out_opt  PWSTR *ppszType
    );

Now the question was, how to get it to C#?


It wasn't too hard, but did take some digging.  Below is the full code I used to get the perceived type of a file.  Simply check the returned value from the GetPerceivedType function below, passing the extension:






        [DllImport("Shlwapi", EntryPoint = "AssocGetPerceivedType")]
        private static extern int AssocGetPerceivedType(IntPtr extension, out IntPtr PERCEIVED, out IntPtr flag, out IntPtr PerceivedType);
        public string GetPerceivedType(string extension)
        {
            IntPtr result = IntPtr.Zero;
            IntPtr dummy = IntPtr.Zero;
            IntPtr intPtr_aux = Marshal.StringToHGlobalUni(extension);
            AssocGetPerceivedType(intPtr_aux, out dummy, out dummy, out result);
            string s = Marshal.PtrToStringAuto(result);
            return s;
        }