Thursday, October 31, 2019
Monday, October 31, 2016
SQL to Excel - Cleanup tabs, new lines, ect...
DECLARE @CrLf CHAR(2);
SET @CrLf = CHAR(13) + CHAR(10); -- CarriageReturn + LineFeed
SELECT [PROB_TYPE]
,[CONTACTNAME]
,[TECHNITION]
,[NUMBER]
--,[DESCRIPTION]
,REPLACE(REPLACE(SUBSTRING([DESCRIPTION],1,DATALENGTH([DESCRIPTION])),@CrLf,'-'), CHAR(9), '') AS [DESCRIPTION]
,[OPENED]
,[CLOSED]
,[CLOSINGREMARKS]
,[STATUS]
,[ENTERED_BY]
,[CONT_PHONE]
,[CONT_ADDRESS]
,[CONT_EMAIL]
,[TAG_NO]
,[SERIAL_NO]
,[MODEL]
,[PRIORITY]
,[SHOW]
,[CODE]
,[CLOSEID]
,[EMERGENCY_CHANGE]
,[ENTERED_ID]
,[HRS_EST]
,[HRS_ACTUAL]
FROM [problems]
where status not in ('closed')
order by prob_type
SET @CrLf = CHAR(13) + CHAR(10); -- CarriageReturn + LineFeed
SELECT [PROB_TYPE]
,[CONTACTNAME]
,[TECHNITION]
,[NUMBER]
--,[DESCRIPTION]
,REPLACE(REPLACE(SUBSTRING([DESCRIPTION],1,DATALENGTH([DESCRIPTION])),@CrLf,'-'), CHAR(9), '') AS [DESCRIPTION]
,[OPENED]
,[CLOSED]
,[CLOSINGREMARKS]
,[STATUS]
,[ENTERED_BY]
,[CONT_PHONE]
,[CONT_ADDRESS]
,[CONT_EMAIL]
,[TAG_NO]
,[SERIAL_NO]
,[MODEL]
,[PRIORITY]
,[SHOW]
,[CODE]
,[CLOSEID]
,[EMERGENCY_CHANGE]
,[ENTERED_ID]
,[HRS_EST]
,[HRS_ACTUAL]
FROM [problems]
where status not in ('closed')
order by prob_type
Thursday, May 26, 2016
MS SQL Tables to C# objects
I am putting this here so I don't have to search for it later.
http://stackoverflow.com/questions/5873170/generate-class-from-database-table
Tuesday, April 19, 2016
SQLITE NHibernate DateTime2
While working on a project I was using a MsSQL 2012 database for my persistence layer but wanted to use a SQLITE in memory database for my unit/integration testing. As part of my mapping setup I used an NHibernate Version column which used DateTime2:
NHibernate Mapping Code:
Unforntuently SQLITE doesn't support DateTime2. After searching around and not finding a good solution, I ended up extending SQLiteDialect class to map it to TEXT per the following link: http://stackoverflow.com/a/16597386/2544235
SQLiteDialect Code:
NHibernate Mapping Code:
Unforntuently SQLITE doesn't support DateTime2. After searching around and not finding a good solution, I ended up extending SQLiteDialect class to map it to TEXT per the following link: http://stackoverflow.com/a/16597386/2544235
SQLiteDialect Code:
Friday, January 23, 2015
Monday, October 6, 2014
Windows 10 "element not found" - explorer.exe error
I recently installed windows 10 preview on an old laptop (Dell Precision) which has an Nvidia Quadro 3000M video card. After running windows update i was getting an error every time i tried to load any metro app including the feedback app.
Error: The error popped up a box saying Explorer.exe with text "element not found".
Fix: Disable the Optimus feature in the bois.
It appears to be a Nvidia optimus problem similar to the one that initially affected Windows 8 and most likely will not be fixed till the vendor puts out windows 10 specific drivers.
More info:
http://answers.microsoft.com/en-us/windows/forum/windows_tp-hardware/nvidia-optimus-not-working-properly/a059390d-dfc1-44aa-9a47-d2172d70933e
https://forums.geforce.com/default/topic/779669/nvidia-optimus-doesnt-work-with-windows-10-tech-preview/?offset=2
http://en.wikipedia.org/wiki/Nvidia_Optimus
Error: The error popped up a box saying Explorer.exe with text "element not found".
Fix: Disable the Optimus feature in the bois.
It appears to be a Nvidia optimus problem similar to the one that initially affected Windows 8 and most likely will not be fixed till the vendor puts out windows 10 specific drivers.
More info:
http://answers.microsoft.com/en-us/windows/forum/windows_tp-hardware/nvidia-optimus-not-working-properly/a059390d-dfc1-44aa-9a47-d2172d70933e
https://forums.geforce.com/default/topic/779669/nvidia-optimus-doesnt-work-with-windows-10-tech-preview/?offset=2
http://en.wikipedia.org/wiki/Nvidia_Optimus
Thursday, July 24, 2014
Recurly Credit Card Processing - True Metered Billing
Overview: I have a client that wants to simply bill a transaction fee at the end of each month. After doing my due diligence, Recruly appeared to be the best solution for the problem as they assured me that what was i doing was not only possible but simple.
To make a long story short, technical support couldn't provide me with an example nor would they tell me anything but "look at our website" which was less then helpful as it contradicted itself. Sometimes it would say to modify the plan subscription itself, sometimes it would say to create an addon. None of this is correct.
The correct way to do metered billing with Recurly using is to use the following procedure:
To make a long story short, technical support couldn't provide me with an example nor would they tell me anything but "look at our website" which was less then helpful as it contradicted itself. Sometimes it would say to modify the plan subscription itself, sometimes it would say to create an addon. None of this is correct.
The correct way to do metered billing with Recurly using is to use the following procedure:
- Create an account without a subscription plan
- At the end of each month simple add an adjustment to the account and invoice the pending charges.
Code (C#):
private void CreateAccount(RecurlyAccount recurlyAccount)
{
var account = new Account(recurlyAccount.AccountCode)
{
FirstName = recurlyAccount.FirstName,
LastName = recurlyAccount.LastName,
Email = recurlyAccount.Email,
CompanyName = recurlyAccount.CompanyName,
};
account.BillingInfo = new BillingInfo(account)
{
LastName = recurlyAccount.RecurlyBillingInfo.FirstName,
FirstName = recurlyAccount.RecurlyBillingInfo.LastName,
Address1 = recurlyAccount.RecurlyBillingInfo.Address1,
Address2 = recurlyAccount.RecurlyBillingInfo.Address2,
City = recurlyAccount.RecurlyBillingInfo.City,
State = recurlyAccount.RecurlyBillingInfo.State,
Country = "US",
PostalCode = recurlyAccount.RecurlyBillingInfo.PostalCode,
CreditCardNumber = recurlyAccount.RecurlyBillingInfo.CreditCardNumber,
CardType = recurlyAccount.RecurlyBillingInfo.CardType,
ExpirationMonth = recurlyAccount.RecurlyBillingInfo.ExpirationMonth,
ExpirationYear = recurlyAccount.RecurlyBillingInfo.ExpirationYear,
Company = recurlyAccount.RecurlyBillingInfo.Company
};
account.Create();
}
public virtual void BillCreditCard(Account account, int quantity, int amountInCents)
{
account.NewAdjustment("USD", amountInCents, "Orders", quantity).Create();
account.InvoicePendingCharges();
}
Wednesday, May 14, 2014
Scaling Agile Across the Enterprise
Microsoft put out some videos about "Scaling Agile Across the Enterprise". I particularly like the video which talks about how the waterfall method is not a good way to design software anymore and how businesses struggle with that.
It can be found here: https://www.youtube.com/watch?v=n79fJUiQ-PU
It can be found here: https://www.youtube.com/watch?v=n79fJUiQ-PU
Wednesday, March 12, 2014
Nhibernate, Abstract Base Classes and JSON.NET
While working on a project I ran into an issue where JSON.NET was not serializing and deserializing my nhibernate entities that used polymorphism. I found plenty of examples that showed how to do this with objects directly but none with Lists and Collections. This code isn't generic like it should be but worked for my purposes.
So here is my code:
POCO:
JsonConverter:
POCO:
[JsonConverter(typeof(LineItemConverter))] public virtual ICollectionLineItems { get; set; }
JsonConverter:
public class LineItemConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return typeof(LineItem).IsAssignableFrom(objectType);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var lineitems = JArray.Load(reader);
var lineItemObjects = new List();
foreach (var lineitem in lineitems)
{
switch (EnumUtil.ParseEnum(lineitem["lineItemType"].Value()))
{
case LineItemType.Assessorial:
lineItemObjects.Add(lineitem.ToObject());
break;
case LineItemType.DeficitWeight:
lineItemObjects.Add(lineitem.ToObject());
break;
case LineItemType.Discount:
lineItemObjects.Add(lineitem.ToObject());
break;
case LineItemType.FloorAdjustment:
lineItemObjects.Add(lineitem.ToObject());
break;
case LineItemType.Freight:
lineItemObjects.Add(lineitem.ToObject());
break;
case LineItemType.Fuel:
lineItemObjects.Add(lineitem.ToObject());
break;
case LineItemType.Other:
lineItemObjects.Add(lineitem.ToObject());
break;
default:
break;
}
}
return lineItemObjects;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var lineitems = value as ICollection;
serializer.Serialize(writer, lineitems.ToArray());
}
Tuesday, January 28, 2014
Angluar JS + c# Web API decimals not routing
For some reason when i would put/get decimal values with the angularjs $resource i would get a 404. After lots of research i found out that this is due to $resource dropping trailing slashes (more info here: http://stackoverflow.com/questions/14533117/angular-trailing-slash-for-resource ). There is talk that in angular 1.3 they will add this as an option but for now we need to use a hack.
HACK: Add "\\/" to the end of your url in the $resource. For example: return $resource('/api/pricingAgreementItem/:id/:action/:value\\/', { id: '@id' },... See below for a more complete example.
Javascript: C#:
HACK: Add "\\/" to the end of your url in the $resource. For example: return $resource('/api/pricingAgreementItem/:id/:action/:value\\/', { id: '@id' },... See below for a more complete example.
Javascript: C#:
Wednesday, November 20, 2013
Simple Membership + WebMatrix.Data & WebMatrix.WebData
In order to use simple membership roles with an MVC5 project you need WebMatrix.WebData reference. To obtain this Reference you need to use nuget and install Microsoft.AspNet.WebHelpers. I am documenting it here so i don't forget.
Non-MVC projects need Microsoft.AspNet.WebPages.OAuth (Install-Package Microsoft.AspNet.WebPages.OAuth)
http://stackoverflow.com/questions/13324544/how-to-add-asp-net-membership-provider-in-a-empty-mvc-4-project-template/13325883#13325883
Sunday, November 17, 2013
Visual Studio 2013 + Angularjs + JasmineJS + Resharper 7/8 (or Chutzpah)
I recently started a project which used the following technologies: Visual Studio 2013 + Angularjs + JasmineJS + Resharper 7/8 (or Chutzpah).
I was having a rough time getting JasmineJS to work with Resharper/Chutzpah. The strange thing was that it would work in the specrunner but not in the actual resharper or chutzpah interfaces which directly integrate into Visual Studio (which is what i wanted).
After spending a couple hours of research i came upon this blog: http://microsoftwindowsblogger.blogspot.com/2013/10/best-unit-testing-angularjs-with.html
Basically you have to inject the script references into the unit test files (which i knew) but they must ALSO BE RELATIVE PATHS TO THE TEST FILE!
Here is an example of a working Jasmine Unit Test which integrates angularjs and works with both Chutzpah and Resharper 7+:
I was having a rough time getting JasmineJS to work with Resharper/Chutzpah. The strange thing was that it would work in the specrunner but not in the actual resharper or chutzpah interfaces which directly integrate into Visual Studio (which is what i wanted).
After spending a couple hours of research i came upon this blog: http://microsoftwindowsblogger.blogspot.com/2013/10/best-unit-testing-angularjs-with.html
Basically you have to inject the script references into the unit test files (which i knew) but they must ALSO BE RELATIVE PATHS TO THE TEST FILE!
Here is an example of a working Jasmine Unit Test which integrates angularjs and works with both Chutzpah and Resharper 7+:
Wednesday, October 9, 2013
SQL Express 2012 Automated Backup Script
SQL Express doesn't come with the SQL Server Agent and so you can not use the Full SQL server backup maintenance plans. To get around this I am using the following script which is executed once a day by the task scheduler.
sp_BackupDatabases can be found here: http://support.microsoft.com/kb/2019698
database_backup.bat
sp_BackupDatabases can be found here: http://support.microsoft.com/kb/2019698
database_backup.bat
md c:\temp_database_bak
sqlcmd -S {{MACHINE_NAME}}\SQLEXPRESS -Q "EXEC sp_BackupDatabases @backupLocation='c:\temp_database_bak\', @backupType='F'"
FOR %%A IN (%Date%) DO (
FOR /F "tokens=1-3 delims=/-" %%B in ("%%~A") DO (
SET Today=%%D%%B%%C
)
)
"C:\Program Files\7-Zip\7z.exe" a c:\backup_mssql\Database_BAK.%TODAY%.7z "C:\temp_database_bak\"
rmdir c:\temp_database_bak /S /Q
Thursday, June 13, 2013
Visio Alternative
If you are a developer you
probably have Visio but if you don’t https://www.draw.io/ is a great alternative and its free.
Thursday, May 2, 2013
Orchard CMS, Magelia WebStore & Credit Card Processing
I recently became the project manager for a fully integrated CMS and eCommerce solution. After reviewing possible options, I selected Orchard CMS(www.orchardproject.net) with a Magelia WebStore (http://www.magelia.org/) integration.
I was able to get both solutions installed without to much trouble using Microsoft Web Platform Installer. Magelia provides some decent documentation on their website on how to integrate both solutions but their credit card processing documentation is non-existent.
After emailing back and forth with the Magelia CEO and development team, I now have a good understand of how it works and have documented their undocumented API which i am posting here including an overview of the solution.
Overview:
Once complete you will need to log into orchard and apply the theme to your site.
I was able to get both solutions installed without to much trouble using Microsoft Web Platform Installer. Magelia provides some decent documentation on their website on how to integrate both solutions but their credit card processing documentation is non-existent.
After emailing back and forth with the Magelia CEO and development team, I now have a good understand of how it works and have documented their undocumented API which i am posting here including an overview of the solution.
Overview:
- Once you have installed both Magelia and Orchard and have integrated both products via the Magelia website tutorial (Found Here) you should be able to see products, add them to your cart and begin the checkout process.
- Once you get to the end of the process you will get the following error: "Override this view (DisplayTemplates\Checkout\ProceedToPayment.cshtml) in your theme in order to submit payment data to the payment provider of your choice/". see example below:
![]() |
| ProceedToPayment.cshtml |
- Magelia provides an Orchard theme based off the default theme to make Paypal the payment gateway for the stores (Found Here). If we want to use any other payment gateway we will need to override this theme. It can be downloaded or install manually using the link above OR you can goto the theme gallery in Orchard and install it using the interface (recommend).
- At this point you can edit the theme directly in notepad. I have Visual Studio and so i wanted to create a VS project. Orchard has a great system for generating theme templates which visual studio project solutions. To do so you need to use the Orchard Command Line interface (More Info).
- Once the Orchard CLI is running execute the following command
- codegen theme MyTheme /BasedOn:TheThemeMachineWithPaypalForMageliaWebStore /CreateProject:true /IncludeInSolution:true
- This will create a new theme with a visual studio project file in it.
- modify {IIS SERVER}\Orchard\Themes\MyTheme\Views\DisplayTemplates\Checkout\ProceedToPayment.cshtml and implement your credit card processing logic using Razor syntax.
Magelia API: https://dl.dropboxusercontent.com/u/7774960/Magelia_API.html
Code Example 1 (ProceedToPayment.cshtml): https://dl.dropboxusercontent.com/u/7774960/ProceedToPayment.cshtml
Code Example 2 (Extract Billing Address): https://dl.dropboxusercontent.com/u/7774960/billingAddress.cshtml
Code Example 1 (ProceedToPayment.cshtml): https://dl.dropboxusercontent.com/u/7774960/ProceedToPayment.cshtml
Code Example 2 (Extract Billing Address): https://dl.dropboxusercontent.com/u/7774960/billingAddress.cshtml
Once complete you will need to log into orchard and apply the theme to your site.
Post questions below
Friday, April 12, 2013
Combining mp3 files.
recently i was trying to combine a bunch of mp3 files from an audio book i purchased so i could play them on my phone. The files were all 4mb and separated into folders by which of the 10 discs they came from. Originally i looked for opensource software to do this but then discovered that this can be doing using the windows command prompt.
Command: copy /b *.mp3 Disc1.mp3
This worked great but i had to keep traversing a monster directory structure in the command line to get to were the next group of mp3's were. In ubuntu there is a feature were you can right click in a folder from the GUI and it would open the command prompt in that directory. I remember windows not initially having it but it appears that they have finally implemented this great feature though they hid it pretty well.
To open a command prompt in a specific folder from the OS GUI open the folder then hold down the shift key while right clicking. This will give you an extra option which says "Open command window here".
UPDATE:
This process can have issues with variable bit rate mp3 files. To fix them use vbrfix and it worked great.
http://windowsfreeware.net/files/vbrfix.zip
Command: copy /b *.mp3 Disc1.mp3
This worked great but i had to keep traversing a monster directory structure in the command line to get to were the next group of mp3's were. In ubuntu there is a feature were you can right click in a folder from the GUI and it would open the command prompt in that directory. I remember windows not initially having it but it appears that they have finally implemented this great feature though they hid it pretty well.
To open a command prompt in a specific folder from the OS GUI open the folder then hold down the shift key while right clicking. This will give you an extra option which says "Open command window here".
UPDATE:
This process can have issues with variable bit rate mp3 files. To fix them use vbrfix and it worked great.
http://windowsfreeware.net/files/vbrfix.zip
Monday, March 18, 2013
Github
Github recently pushed a windows client worth looking at. Coming from an SVN world, i have had a hard time adjusting to the git methodology but using the Windows client has taken away most of the mystery without losing functionality.
Check out the Windows client for Github here: http://windows.github.com/
Check out the Windows client for Github here: http://windows.github.com/
Thursday, February 28, 2013
Bootable AntiVirus Apps
Found this article (http://www.thewindowsclub.com/bootable-antivirus-rescue-cd-windows-free-download) which outlines some of the major players. In the past i have found Kaspersky to be the most thorough (http://support.kaspersky.com/4162).
Instead of "wasting" a CD\DVD i would suggest using the rufus bootable thumbdrive application. It is the simplest one i have found and works great! It can be found here: http://rufus.akeo.ie/
Instead of "wasting" a CD\DVD i would suggest using the rufus bootable thumbdrive application. It is the simplest one i have found and works great! It can be found here: http://rufus.akeo.ie/
Wednesday, February 27, 2013
Vmware Copy/Paste (Clipboard)
While working with ESXi 5 vSphere Client i noticed that i couldnt copy and paste into a VM. After some searching i found the below article on the vmware website which resolved the issue.
Summary:
Note: VMware Tools must be installed for Copy and Paste to work.
- Log into a vCenter Server system using the vSphere Client and power off the virtual machine.
- Select the virtual machine and click the Summary tab.
- Click Edit Settings.
- Navigate to Options > Advanced > General and click Configuration Parameters.
- Click Add Row.
- Type these values in the Name and Value columns:
Name Valueisolation.tools.copy.disable falseisolation.tools.paste.disable false
- Click OK to close the Configuration Parameters dialog, and click OK again to close the Virtual Machine Properties dialog.
- Power on the virtual machine.
Thursday, January 31, 2013
Simple Firewall Overview
I found this blog entry which explains what a firewall does in every simple, easy to understand terms. I highly recommend it as a starting point.
http://coding.smashingmagazine.com/2013/01/30/introduction-to-firewalls/
enjoy!
http://coding.smashingmagazine.com/2013/01/30/introduction-to-firewalls/
enjoy!
Subscribe to:
Posts (Atom)
-
While working on a project I was using a MsSQL 2012 database for my persistence layer but wanted to use a SQLITE in memory database for my u...
-
I recently became the project manager for a fully integrated CMS and eCommerce solution. After reviewing possible options, I selected Orch...
-
Redmine Install Process -- Download and install turnkey linux's redmine appliance http://www.turnkeylinux.org/redmine -- install up...



