Archive
GD Library Error: imagecreatetruecolor does not exist (FIX)
1. At the start, all php pages were throwing up a php_via_fastcgi error
Reading some blog posts, the diagnostic step was to do this
%WINDIR%system32inetsrvappcmd.exe list config /section:handlers
/text:* | findstr /i PHP
and I got this result;
path:"*.php"
scriptProcessor:"C:Program Files (x86)phpphp-cgi.exe"
Funnily enough that php-cgi.exe file was missing, even though I appeared to have a partial installation of php on my pc.
So I downloaded the manual installer from PHP, and unzipped the files ontop of my php directory.
Now PHP was working
2. After installing timthumb, I saw that no images were appearing, and navigating directly to the PHP script gave this error
GD Library Error: imagecreatetruecolor does not exist – please contact your webhost and ask them to install the GD library
TimThumb version : VERSION
So, the trick was to open PHP.INI with notepad *IN ADMINISTRATOR MODE*
and add the lines
[PHP_GD2]
extension=php_gd2.dll
IISReset, then it worked!
Use IIS under VS 2008, rather than the development server, Casini
Set up a new application in IIS, point it to the root of your project, and check that it works, by going to a browser, and type localhost/myApp
Then right click your web applicaiton in Visual Studio, select "Property Pages", then "Start Option", set Start URL to localhost/myApp,
check "Use custom webserver", then base URL to "http://localhost/SellSwapBuy".
When you run your app now, you can still debug, but it will be under IIS not Casini.
As String, ToString and (string)
((object)1).ToString() equals "1"
((object)1) as string equals null
(string)((object)1) throws an exception
Basically, "ToString()" calls a method on "object" or in the closest derived class that overrides the ToString() method.
"As string" performs a cast, but returns null rather than an exception is the cast is not implicitly possible.
(string) peroforms the same cast, but throws an exception on failure.
Hash codes for Realex payment processing
// Create an md5 sum string of this string
static public string GetMd5Sum(string str)
{
// First we need to convert the string into bytes, which
// means using a text encoder.
Encoder enc = System.Text.Encoding.ASCII.GetEncoder();
// Create a buffer large enough to hold the string
byte[] unicodeText = new byte[str.Length];
enc.GetBytes(str.ToCharArray(), 0, str.Length, unicodeText, 0, true);
// Now that we have a byte array we can ask the CSP to hash it
MD5 md5 = new MD5CryptoServiceProvider();
byte[] result = md5.ComputeHash(unicodeText);
// Build the final string by converting each byte
// into hex and appending it to a StringBuilder
StringBuilder sb = new StringBuilder();
for (int i = 0; i < result.Length; i++)
{
sb.Append(result[i].ToString("X2"));
}
// And return it
return sb.ToString().ToLower();
}
XmlSerializer Cache
var xs = new XmlSerializer(typeof(DataSet));
On a first call, this generates a cached serialization assembly. On my PC, this takes 0.2 seconds. However, on subsequent calls,
this line executes in 0.00006959 seconds.
This is how I timed this;
private TimeSpan CreateXMLSerializer(int numberOf)
{
var dtStart = DateTime.Now;
var lNumber = Enumerable.Range(1, numberOf);
foreach (var intIteration in lNumber)
{
var xs = new XmlSerializer(typeof(DataSet));
}
var dtEnd = DateTime.Now;
return dtEnd – dtStart;
}
UGFzc3dvcmQ6
I’ve ever seen in my life.
But where is this used?, on a student project?, nope, it forms the bases of SMTP email authentication.
AUTH {blank} 334 UGFzc3dvcmQ6 18 45 noreply@a.com
AUTH c3R1cGlk 235 Authenticated 19 18 noreply@a.com
and the password is base 64 encoded too.
Terrible.
Mathematically determining your max cpc for adwords
I’m no expert, but this is what I’ve come up with:
1) bid on several hundred keywords at 0.03p each, and let google cancel the ones that are over competitive. This normally creates a spike and a rapid tail
off of visitors, so the success of this plan can only be seen after a few days.
I found that this bottom-feeding approach brings in cheap traffic, but not much of it.
2) Pay the maximum you can afford to bring in as many visitors as possible, whilst making sure the cost per conversion does not exceed nor equal your average profit per conversion.
Google is unusual in the sense of the more visitors you purchase, the higher the cost per visitor gets. Economies of scale are somewhat reversed in this situation. However, if you make £1 a conversion, and it costs 50p per conversion for 1,000 visitors, or 40p a conversion for 100 visitors, then you are still better paying £500 for £1000 profit than £40 for £100 profit.
To calculate your maximim CPA (Cost per Action), then it is take a specific period, i.e. January 2010, say P is your gross profit in January 2010, C is your cost of sales, N is the number of conversions in Jan ’10. Then your Maximum CPA is (P-C)/N
Now, not every click on an ad will result in a conversion, depending on the ticket value of your product, this could be anything from 1% to 50%. Check your conversion rate bettween your visitors (V) and conversions (N) , then divide this into your Max CPA i.e. CPA x N/V to get your Max CPC.
Interestingly, combining both equations nullifies your conversion rate: (P-C)/V – But you’ll still need to have your Max CPA to hand to ensure that no individual keyword exceeds your MAX CPA.
Cost breakdown of Amazon Simple DB
I uploaded a 1.6 GB database to Amazon Simple DB, and the bill came to just over $5. The most costly part was the upload which took 34 Hours of processing time.
US-East (Northern Virginia) Region |
||||
$0.00 per Compute-Hour consumed first 25 hours per month |
25 Hrs |
0.00 | ||
$0.14 per Compute-Hour consumed beyond first 25 free hours per month |
36.419 Hrs |
5.10 | ||
$0.00 per GB-Month of storage for first 1 GB-Month |
0.931 GB-Mo |
0.00 | ||
$0.00 per GB – All data transfer in |
1.647 GB |
0.00 | ||
$0.00 per GB – first 1 GB / month data transfer out |
0.821 GB |
0.00 | ||
5.10 |
Complete breakdowns are available, but don’t have a cost associated with each operation
. |
Service | Operation | UsageType | StartTime | EndTime | UsageValue |
. |
AmazonSimpleDB | CreateDomain | BoxUsage | 3/9/2010 16:00:00 |
3/9/2010 17:00:00 | 0.0055590278 |
. |
AmazonSimpleDB | PutAttributes | DataTransfer-Out-Bytes | 3/9/2010 16:00:00 | 3/9/2010 17:00:00 | 2280 |
. |
AmazonSimpleDB | SelectGet | BoxUsage | 3/9/2010 16:00:00 | 3/9/2010 17:00:00 | 0.000041146868 |
. |
AmazonSimpleDB | ListDomains | Requests | 3/9/2010 16:00:00 |
3/9/2010 17:00:00 | 2 |
. |
AmazonSimpleDB | PutAttributes | DataTransfer-In-Bytes | 3/9/2010 16:00:00 | 3/9/2010 17:00:00 | 4668 |
. |
AmazonSimpleDB | ListDomains | DataTransfer-Out-Bytes | 3/9/2010 16:00:00 | 3/9/2010 17:00:00 | 862 |
. |
AmazonSimpleDB | PutAttributes | BoxUsage | 3/9/2010 16:00:00 |
3/9/2010 17:00:00 | 0.0001324322 |
. |
AmazonSimpleDB | DeleteDomain | Requests | 3/9/2010 16:00:00 |
3/9/2010 17:00:00 | 1 |
. |
AmazonSimpleDB | ListDomains | DataTransfer-In-Bytes | 3/9/2010 16:00:00 | 3/9/2010 17:00:00 | 836 |
. |
AmazonSimpleDB | DeleteDomain | DataTransfer-Out-Bytes | 3/9/2010 16:00:00 | 3/9/2010 17:00:00 | 378 |
. |
AmazonSimpleDB | ListDomains | BoxUsage | 3/9/2010 16:00:00 |
3/9/2010 17:00:00 | 0.0000143518 |
. |
AmazonSimpleDB | DeleteAttributes | Requests | 3/9/2010 16:00:00 | 3/9/2010 17:00:00 | 3 |
. |
AmazonSimpleDB | DeleteDomain | DataTransfer-In-Bytes | 3/9/2010 16:00:00 | 3/9/2010 17:00:00 | 426 |
. |
AmazonSimpleDB | DeleteAttributes | DataTransfer-Out-Bytes | 3/9/2010 16:00:00 | 3/9/2010 17:00:00 | 1158 |
. |
AmazonSimpleDB | DeleteDomain | BoxUsage | 3/9/2010 16:00:00 | 3/9/2010 17:00:00 | 0.0055590278 |
. |
AmazonSimpleDB | CreateDomain | Requests | 3/9/2010 16:00:00 |
3/9/2010 17:00:00 | 1 |
Mail enable ME-I0129 error
Authenticating User: a@b.com using Authentication Provider Credentials
04/01/10 12:43:19 ME-I0129: Account b.com Mailbox a@b.com prevented from sending email as a@c.com
04/01/10 12:43:23 ME-I0070: (recv) socket [780] was gracefully closed during [MAIL] command by the remote client xxx.xxx.xxx.xxx
04/01/10 12:43:23 ME-I0074: [780] (Debug) end of conversation
Fix:
Start > Run > mailenable.msc
Open Servers / Localhost / Connectors / SMTP
Right Click
Security
Uncheck "Authenticated senders must use valid sender address"
Restart "MailEnable SMTP Connector" from Control Panel / Administrative tools / Services