The following JavaScript is used here to rotate the featured product every 30 seconds. I will leave the implementation of the JSON-emitting REST api for another post.
<script src="/Javascript/jquery-latest.min.js" type="text/javascript"><!--mce:0--></script>
<script src="/Javascript/jquery-jtemplates.js" type="text/javascript"><!--mce:1--></script>
<script type="text/javascript"><!--mce:2--></script>
<div id="FeaturedProduct" class="outerbox"></div>
<textarea id="productTemplate" style="display: none;">
<div class="outerbox">
<div class="box featured">
<h2 >
Featured</h2>
<div class="item">
<div class="bord-se">
<div class="bord-ne">
<div class="bord-s">
<a href="/store/Product.aspx?ProductId={$T.ProductId}&utm_source=Homepage&utm_medium=FeaturedProd&utm_term=Widget&utm_campaign=Featured_Widget" mce_href="/store/Product.aspx?ProductId={$T.ProductId}&utm_source=Homepage&utm_medium=FeaturedProd&utm_term=Widget&utm_campaign=Featured_Widget" id="A1">
<img class="FeaturedProduct" src="{$T.ThumbnailUrl}" mce_src="{$T.ThumbnailUrl}" alt="featured" style="border-width:0px;" mce_style="border-width: 0px;" />
</a>
</div>
</div>
</div>
</div>
<h4>
<a href="/store/Product.aspx?ProductId={$T.ProductId}&utm_source=Homepage&utm_medium=FeaturedProd&utm_term=Widget&utm_campaign=Featured_Widget" mce_href="/store/Product.aspx?ProductId={$T.ProductId}&utm_source=Homepage&utm_medium=FeaturedProd&utm_term=Widget&utm_campaign=Featured_Widget">{$T.Name}</a></h4>
<span>Author: </span>
<a href="/store/search.aspx?m={$T.AuthorId}" mce_href="/store/search.aspx?m={$T.AuthorId}">{$T.Author}</a>
<span class="Price">
${$T.Price}</span>
{$T.Summary}
<a class="more" href="/store/New-Products-C52.aspx" mce_href="/store/New-Products-C52.aspx">view all…</a>
</div>
</div>
</textarea>
I did a presentation last week on AES encryption techniques in .Net.
I’ll post some details here later, but for now, I’ve uploaded a zip file with the project code.
Here’s the key bit:
string key = "1234567891123456";
string secret = @"Sometimes I sing Shania Twain's ""I Feel Like A Woman!"" in the shower.";
Console.WriteLine("basic:");
EncryptString(key, secret);
Console.ReadKey();
Console.WriteLine("salt the secret:");
// good when there are multiple machines but a dynamic global shared secret (for example, Profile Create Date or User ID)
string secret2 = secret + " ###" + DateTime.Now.Millisecond;
EncryptString(key, secret2);
secret2 = secret + " ###" + DateTime.Now.Millisecond;
EncryptString(key, secret2);
Console.ReadKey();
Console.WriteLine("salt the key:");
// good when the same machine encrypts/decrepts
string uniqueMachineIdentifier = MachineId.GetProcessorID();
Console.WriteLine("MachineId: " + uniqueMachineIdentifier);
EncryptString(key + uniqueMachineIdentifier, secret);
Console.ReadKey();
Console.WriteLine("SHA1 hash the passphrase with a salt:");
// note: talk about why hashing is good
SHA1 sha = new SHA1CryptoServiceProvider();
// This is one implementation of the abstract class SHA1.
string password = "this is my user password and/or userid";
byte[] saltedKey = Encoding.Default.GetBytes(key + password);
byte[] result = sha.ComputeHash(saltedKey);
EncryptString(Convert.ToBase64String(result), secret);
Console.ReadKey();
I use this code here.
Graphics backgroundGraphics;
backgroundImage = (Bitmap)Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\images\\Header.jpg");
backgroundGraphics = Graphics.FromImage(backgroundImage);
var font = new Font("Perpetua Titling MT", 24F, FontStyle.Regular);
backgroundGraphics.DrawString(authorname.ToUpper(), font, new SolidBrush(Color.FromArgb(100, 0, 0, 0)), 10, 5);Now save – or output to the browser:
backgroundImage.Save(context.Response.OutputStream, ImageFormat.Jpeg);
If you use Response.Redirect to direct users to a new location, you should be aware that it issues a status code of 302, which means that “the resource resides temporarily under a different URI.” If you intend to communicate that the resource has permanently changed locations, you should not use Response.Redirect. This is important for search engines and other crawlers that might need to know the definitive url.
To send a 301 redirect:
Response.Status = "301 Moved Permanently";
Response.StatusCode = 301;
Response.AddHeader("Location", url);
Response.End();Update: ASP.Net 4.0 ads a Response.RedirectPermanent() method.
The following PHP script updates missing post slugs (permalinks) in a WordPress blogs, or reformats them according to your needs:
Read more…
If you use wptexturize, smart quotes will mess you up. This is a quick and dirty fix.
Read more…
While trying to migrate a large blog from Movable Type to WordPress, I found the built-in export and import functionality unable to handle volume of content on the blog or to properly preserve the primary keys needed for permalinks.
With assistance from Alvaro on the MisesDev list, we came up with the following MySql SQL script to import the entries directly from the Movable Type (5.01) database to WordPress (2.9.2). What would take many hours otherwise can be done in a minute or two. This is especially important if you don’t want to lose data during the time it takes to migrate the blog, as the script can be run immediately before the switch. This script also includes additional stuff like IP addresses and url-friendly names.
Read more…
Recent Comments