Skip to content

Instantly share code, notes, and snippets.

@mvark
mvark / EmailwithDynamicAttachment.cs
Created January 8, 2015 10:56
C# code sample to send an email with a Word or Excel file attachment built on the fly. More info - http://mvark.blogspot.in/2007/01/how-to-send-email-with-word-or-excel.html
<%@ Page Language="C#" %>
<script runat="server">
void Page_Load(Object Src, EventArgs E)
{
try
{
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
System.Net.NetworkCredential cred = new System.Net.NetworkCredential("[email protected]", "p@ssword");
@mvark
mvark / DownloadAsDoc.cs
Created January 8, 2015 10:59
C# code sample to implement "Download as Word Document" feature for a web page with content from a data source
<%@ Page Language="C#" %>
<script runat="server">
void Page_Load(Object Src, EventArgs E)
{
try
{
System.Data.DataTable workTable = new System.Data.DataTable();
workTable.Columns.Add("Id");
workTable.Columns.Add("Name");
System.Data.DataRow workRow;
@mvark
mvark / DownloadAsExcel.cs
Created January 8, 2015 11:01
C# code sample to implement "Download as Excel" feature for a web page with content from a data source
<%@ Page Language="C#" %>
<script runat="server">
void Page_Load(Object Src, EventArgs E)
{
try
{
System.Data.DataTable workTable = new System.Data.DataTable();
workTable.TableName = "Customers";
workTable.Columns.Add("Id");
workTable.Columns.Add("Name");
@mvark
mvark / QuotesInInjectedText.html
Created January 14, 2015 14:35
JavaScript function to handle quotes within injected text assigned to Title attribute of a HTML element
Before:
elem.append('<a title="'results[i].title
+ '" href="http://www.youtube.com/embed/' + results[i].id + '?autoplay=1&vq=small&autohide=2&iv_load_policy=3" >' + results[i].title + '</a>');
function htmlEscape(str) {
return String(str)
.replace(/'/g, ''')
.replace(/"/g, '"');
}
@mvark
mvark / zxing.html
Last active March 12, 2016 17:54
HOW TO scan a barcode with Android smartphone camera from a web page (works within an Android browser & smartphone having ZXing Barcode Scanner installed)
<!-- Read related post: http://mvark.blogspot.in/2016/03/how-to-scan-barcode-with-android.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<a href="zxing://scan/?ret=http://example.azurewebsites.net/desc.html?code={CODE}">Scan</a>
</body>
@mvark
mvark / desc.html
Last active March 12, 2016 17:50
The page ZXing Barcode Scanner will send the scanned barcode text
<!-- Read related post: http://mvark.blogspot.in/2016/03/how-to-scan-barcode-with-android.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Desc</title>
</head>
<body>
<script>document.write(location.href);</script>
</body>
@mvark
mvark / BingSearchv5Simple.html
Last active June 9, 2016 09:22
A simple jQuery based sample to show Bing Search v5 API in action
<!DOCTYPE html>
<html>
<head>
<title>Bing Search v5 - Simple, show fewer results</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
// more info: http://mvark.blogspot.com/2016/06/how-to-use-bing-search-v5-api-with.html
@mvark
mvark / BingSearchv5More.html
Last active June 9, 2016 09:20
Fetching results using version 5 of Bing Search API
<!DOCTYPE html>
<html>
<head>
<title>Bing Search v5 - show all results</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script>
// more info: http://mvark.blogspot.com/2016/06/how-to-use-bing-search-v5-api-with.html
javascript:(function()%7Bdocument.getElementById("captchaTexttab1").value%3Ddocument.getElementById("captchaDivtab1").innerHTML.split(" ").join("")%7D)()
<!DOCTYPE html>
<html>
<head>
<title>OCR Sample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
function processImage() {