Thursday, 3 October 2013

Remove all hyperlinks and tables from RTF using c#

Remove all hyperlinks and tables from RTF using c#

I have a Winform RichTextBox to which I am programatically loading RTF
documents. But I want to strip/remove all hyperlinks and tables from the
RTF before loading the RTF into the RichTextBox ( but needs to keep the
formatting). Same behavior I need for RTF texts copied from MS Word also.
How do I achive this? Are there any library to parse the RTF and strip
hyperlinks and tables (still keeping the formatting) ?

Wednesday, 2 October 2013

Overriding protected methods in Moq

Overriding protected methods in Moq

I have a class which implements an abstract class. The abstract class has
a protected virtual method as shown:
protected virtual void OnAction(string action, object result);
The class implementing the abstract class has a method which when
completed calls base.OnAction.
I am trying to override the behaviour of the implementation of OnAction in
my unit tests as I am trying to unit test only, not do integration tests.
My Moq call is setup as follows:
mock.Protected().Setup("OnAction", ItExpr.IsAny<string>,
ItExpr.IsAny<object>());
Breakpointing my base abstract classes OnAction method confirms it is
still being called.
I'm essentially wanting Moq to do the equivalent in it's emitted class:
public override OnAction(string action, object result) { // do nothing }

PHP/MySQL SELECT statement with 'variable' ' ' or 'variable' IS NOT NULL not working

PHP/MySQL SELECT statement with 'variable' ' ' or 'variable' IS NOT NULL
not working

I have a SQL routine written that compares a user's input with an existing
value in a table. If the value exists, a green check mark appears next to
the input. If it doesn't, then a red x appears. My SQL statement is as
follows:
$check = $con->prepare("SELECT count(*) FROM emaillist");
$check->execute();
$result = $check->fetchColumn(); //Get no. of columns
$check = $con->prepare("SELECT Username FROM emaillist WHERE Username =
'$Name' AND '$Name' <> '' ");
$check->execute();
$result = $check->fetchColumn(); //Get exact column
if(!$result) {
show red x } else { show green check }
This works fine as long as there is input. The red x appears when the
input doesn't match and the green check appears when it does; however, I
don't want anything to display if the field is left blank. Right now, the
red x appears if the field is empty or is null. Using IS NOT NULL didn't
work, either. What am I missing?

Microsoft Access -- Automation Error

Microsoft Access -- Automation Error

I'm running an ancient macro (circa 2002), and in the VBA code in
Microsoft Access, if I use the function "Excel.Application.NormSDist(mu)",
I get the error:
Automation Error The interface is unknown
Any ideas on how to fix this?

MSSQL server connect to kohana php framework

MSSQL server connect to kohana php framework

I'm new to kohana php framework. I tried to connect sql server 2005 to
it.somebody please help me. this is urgent situation.

Tuesday, 1 October 2013

CSS and html not rendering well on mobile

CSS and html not rendering well on mobile

I have a page i've created which works fine in a desktop but get's messed
up in a mobile browser.

This is the desktop version.

This is the mobile version. I have a header and a .container(the one with
gray background) set to width 100%. Inside .container i've a .wrapper set
to width: 900px; and margin: 0 auto;. Why is the blue background and the
gray background rendering till about half of the page witdh? What is the
best way I can approach the problem to create a page like the desktop
version on the mobile as well?
Codepen link http://codepen.io/tim-hoff/pen/ytGEw

Minimum value of numbers in char array

Minimum value of numbers in char array

I recently ran into this problem in an interview, and I was curious what
the best way to solve it would be. The question is given a char array that
has the ascii characters '0' to '9' make one swap such that the the set of
ascii values in the resultant array forms the lowest possible value. Both
the input array will not have preceding 0s and neither should the
resultant array.
So here is an example: char a[] = {'1','0', '9','7','6'}
The solution: char b[] = { '1','0', '6', '7', '9'}

Backup Server Solution in production environment

Backup Server Solution in production environment

I was looking at setting up a backup server running on a virtualbox with
Windows Server 2008r2 as the host (I have no say here). I was thinking
about using FreeNAS with ZFS, however, I am finding out that some have had
problems with this due to S.M.A.R.T. and windows paging when running
FreeNAS on a virtual Machine.
This Backup Server will be responsible for backing up our whole
infrastructure in increments of a week (already have an on site full
backup solution).
Does Windows have any backup server-client applications that would both be
VM friendly and have the performance to backup TeraBytes of data?
hardware specs are not a problem here.
Thank you in advance!

EC2 backup strategy, 2 EBS volumes

EC2 backup strategy, 2 EBS volumes

i've currently set up a Windows EC2 instance with MySQL installed on the
root/C: drive, with the database files, logs, etc on another volume.
Is it safe to use snapshots to back up the instance? My thinking is that
it would be impossible to take a snapshot of each volume at the exact same
time, so you don't have a consistent snapshot of the entire instance.
If there is such an issue, what other backup options are there? Back up
using AMIs instead?
tia