by sunil ravulapalli
/27. April 2014 04:30
/windows8
/Comments (0)

Defend the planet from a continues barrage of asteroids. You control a ship which moves around a planet and has an unlimited supply of laser cannons to destroy the incoming asteroids. Don't let the asteroid come too close to the planet or your ship. How many levels can you go without getting destroyed?

by sunil ravulapalli
/20. March 2012 19:58
/windows8
/Comments (0)
This code was tested on Windows 8 consumer preview and may be outdated by the time future versions are released.
(function () {
"use strict";
var lightGray = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXY7h4+cp/AAhpA3h+ANDKAAAAAElFTkSuQmCC";
var mediumGray = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXY5g8dcZ/AAY/AsAlWFQ+AAAAAElFTkSuQmCC";
var darkGray = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXY3B0cPoPAANMAcOba1BlAAAAAElFTkSuQmCC";
var groups = [
{ key: "group1", title: "Featured products", subtitle: "Featured", backgroundImage: lightGray, description: "Bedding products" },
{ key: "group2", title: "Towel", subtitle: "Featured", backgroundImage: lightGray, description: "Towel products" },
{ key: "group3", title: "Knife", subtitle: "Featured", backgroundImage: lightGray, description: "Knife products" }
];
function groupKeySelector(item) {
return item.group.key;
}
function groupDataSelector(item) {
return item.group;
}
function getItemsFromGroup(group) {
return list.createFiltered(function (item) { return item.group.key === group.key; });
}
var list = new WinJS.Binding.List();
var groupedItems = list.createGrouped(groupKeySelector, groupDataSelector);
function downloadError() {
}
function processProducts(requests) {
for (var i = 0; i < requests.length; i++) {
var xml = requests[i].responseXML;
var records = xml.selectNodes("//SearchRecord");
for (var postIndex = 0; postIndex < records.length; postIndex++) {
var record = records[postIndex];
var description = record.selectSingleNode("description").text;
var priceRange = record.selectSingleNode("priceRange").text;
var itemImage = record.selectSingleNode("itemImage").text.replace("/130/", "/230/");
var sku = record.selectSingleNode("sku").text;
var collection = record.selectSingleNode("collection").text;
list.push({
group: groups[i],
title: description,
subtitle: priceRange,
description: description,
itemDescription: description,
content: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
backgroundImage: itemImage
});
}
}
}
var dataPromises = [];
var promise1 = WinJS.xhr({ url: "http://www.samplesite.com/search/searchservice.asmx/Search?searchString=bedding&from=0&blockSize=10" });
dataPromises.push(promise1);
var promise2 = WinJS.xhr({ url: "http://www.samplesite.com/search/searchservice.asmx/Search?searchString=towel&from=0&blockSize=6" });
dataPromises.push(promise2);
var promise3 = WinJS.xhr({ url: "http://www.samplesite.com/search/searchservice.asmx/Search?searchString=knife&from=0&blockSize=6" });
dataPromises.push(promise3);
WinJS.Promise.join(dataPromises).then(processProducts, downloadError);
WinJS.Namespace.define("data", {
items: groupedItems,
groups: groupedItems.groups,
getItemsFromGroup: getItemsFromGroup
});
})();
by sunil ravulapalli
/20. March 2012 19:54
/windows8
/Comments (0)
This code was tested on Windows 8 consumer preview and may be outdated by the time future versions are released.
(function () {
"use strict";
var lightGray = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXY7h4+cp/AAhpA3h+ANDKAAAAAElFTkSuQmCC";
var mediumGray = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXY5g8dcZ/AAY/AsAlWFQ+AAAAAElFTkSuQmCC";
var darkGray = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXY3B0cPoPAANMAcOba1BlAAAAAElFTkSuQmCC";
var groups = [
{ key: "searchResultsGroup", title: "Search Results", subtitle: "Results", backgroundImage: lightGray, description: "Search Results" }
];
function groupKeySelector(item) {
return item.group.key;
}
function groupDataSelector(item) {
return item.group;
}
function getItemsFromGroup(group) {
return list.createFiltered(function (item) { return item.group.key === group.key; });
}
var list = new WinJS.Binding.List();
var groupedItems = list.createGrouped(groupKeySelector, groupDataSelector);
function downloadError() {
}
function processProducts(request) {
var xml = request.responseXML;
var records = xml.selectNodes("//SearchRecord");
for (var postIndex = 0; postIndex < records.length; postIndex++) {
var record = records[postIndex];
var description = record.selectSingleNode("description").text;
var priceRange = record.selectSingleNode("priceRange").text;
var itemImage = record.selectSingleNode("itemImage").text.replace("/130/","/230/");
var sku = record.selectSingleNode("sku").text;
var collection = record.selectSingleNode("collection").text;
list.push({
group: groups[0],
title: description,
subtitle: priceRange,
description: description,
itemDescription: description,
content: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
backgroundImage: itemImage
});
}
}
WinJS.xhr({ url: "http://www.samplesite.com/search/searchservice.asmx/Search?searchString=bed&from=0&blockSize=20" }).
then(processProducts, downloadError);
WinJS.Namespace.define("data", {
items: groupedItems,
groups: groupedItems.groups,
getItemsFromGroup: getItemsFromGroup
});
})();
by sunil ravulapalli
/9. March 2012 17:58
/windows8
/Comments (0)
I have a Samsung Series 7 Chronos laptop with the Express cache feature(8GB on board SSD) for faster boot. For several days I wasn't able to load set up a dual boot on a VDH, using this technique from Scott Hanselman.
http://www.hanselman.com/blog/GuideToInstallingAndBootingWindows8DeveloperPreviewOffAVHDVirtualHardDisk.aspx
I always got this errror
"Setup was unable to create a new system partition or locate an existing system partition. See the Setup log files for more information".
I think it has to do with the fact that this laptop is considered to have two hard disks and there is some discussion on the internet that recent versions of windows has a problem with two hard disks attached to the computer at the same time. The resolution was to just detach one of them before installing windows. However, this was not an option on the laptop.
So, I used VirtualBox and loaded Windows 8 Preview as Virtual Machine.But, it killed the joy of the new UI. It was okay to do some Window 8 Application Coding. But the UI was very jerky. I hated it.
Then one fine day, on my quest to resolve this issue, I bumped into this aticle
http://www.howtogeek.com/75286/how-to-dual-boot-windows-7-and-8-without-re-partitioning-using-vhd/
It involves some powereshell, but it is just running some commands.
Now, I am dual booting Wndows 8 Consumer Preview and it is FAST and BEAUTIFUL.
by sunil ravulapalli
/28. February 2012 03:38
/windows8
/Comments (0)
Error DEP1000 : Cannot copy file "C:\Users\Username\Grid\Debug\resources.pri" to layout "resources.pri" for the following reason: The requested operation cannot be performed on a file with a user-mapped section open.
How to get rid of it?
Uninstall the app from the metro desktop, and rerun the app. This will get rid of this error.
by sunil ravulapalli
/13. January 2012 20:17
/windows8
/Comments (0)
This code was tested on Windows 8 developer preview and may be outdated by the time future versions are released.
Following is the function which takes filename and content and writes content into the file.
function saveStuff(fileName, contentText) {
var sampleFile;
// Create file in user's Document library, overwriting the existing file if there is one
Windows.Storage.KnownFolders.documentsLibrary.createFileAsync(fileName,
Windows.Storage.CreationCollisionOption.replaceExisting).then(function (file) {
sampleFile = file;
// Have file and text to write
if (sampleFile != null && geoCode != null) {
// Open file as stream with read/write access
sampleFile.openAsync(Windows.Storage.FileAccessMode.readWrite).then(function (stream) {
// File opened
// Prepare and write to the file stream
var outputStream = stream.getOutputStreamAt(stream.size);
var writer = new Windows.Storage.Streams.DataWriter(outputStream);
writer.writeString(contentText);
// Save stream to file
writer.storeAsync().then(function () {
outputStream.flushAsync().then(function () {
writeContent('Geocode saved.');
});
});
});
}
});
}
You can call it as following:
saveStuff('settings.txt', 'blue');
by sunil ravulapalli
/13. January 2012 19:53
/windows8
/Comments (0)
This code was tested on Windows 8 developer preview and may be outdated by the time future versions are released.
Currently I am using promises[0]._value.responseText to access by response. But it doesn't feel right at all. I could not yet find any documentation to do it correct way.
var urls = [
"http://dev.virtualearth.net/REST/v1/Locations?q=07008&key=abcdef",
"http://dev.virtualearth.net/REST/v1/Locations?q=08830&key=abcdef"
];
var promises = urls.map(function (url) {
return WinJS.xhr({ url: url });
});
WinJS.Promise.join(promises).then(function () {
contentPara.innerHTML += promises[0]._value.responseText+ '
';
contentPara.innerHTML += promises[1]._value.responseText+ '
';
}, handleError);
function handleError() {
writeContent('Error geocoding, please try again later.');
}
by sunil ravulapalli
/13. January 2012 17:57
/windows8
/Comments (0)
This code was tested on Windows 8 developer preview and may be outdated by the time future versions are released.
The contents of default.html are as show below. Just include a div called "contentHost".
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>TTips</title>
<!-- WinJS references -->
<link rel="stylesheet" href="/winjs/css/ui-dark.css" />
<script src="winjs/js/base.js"></script>
<script src="winjs/js/ui.js"></script>
<script src="winjs/js/binding.js"></script>
<script src="winjs/js/controls.js"></script>
<script src="winjs/js/animations.js"></script>
<script src="winjs/js/wwaapp.js"></script>
<!-- TTips references -->
<link rel="stylesheet" href="/css/default.css" />
<script src="/js/default.js"></script>
</head>
<body>
<h1>Traffic Tips</h1>
<div id="contentHost">
</div>
</body>
</html>
In default.js, include the navigated as it is. Don'f forget to include this line WinJS.Navigation.addEventListener('navigated', navigated); as shown. When onmainwindowactivated all you have to do is call WinJS.Navigation.navigate('main.html').
(function () {
'use strict';
// Uncomment the following line to enable first chance exceptions.
// Debug.enableFirstChanceException(true);
document.addEventListener("DOMContentLoaded", function () {
WinJS.UI.processAll();
}, false);
WinJS.Application.onmainwindowactivated = function (e) {
if (e.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
WinJS.Navigation.navigate('main.html');
}
}
function navigated(e) {
WinJS.UI.Fragments.clone(e.detail.location, e.detail.state)
.then(function (frag) {
var host = document.getElementById('contentHost');
host.innerHTML = '';
host.appendChild(frag);
document.body.focus();
WinJS.Application.queueEvent({
type: 'fragmentappended',
location: e.detail.location,
fragment: host,
state : e.detail.state
});
});
}
WinJS.Navigation.addEventListener('navigated', navigated);
WinJS.Application.start();
})();
by sunil ravulapalli
/29. December 2011 22:08
/windows8
/Comments (0)
This code was tested on Windows 8 developer preview and may be outdated by the time future versions are released.
Once you create a Blank solution your default.html should look like the code below.
The new parts are the scripts tags and the control div as highlighted.
The scripts files are needed for the App Bar control to work. The actual control is the div with the attribute data-win-control="WinJS.UI.AppBar".
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>MyAppBar</title>
<!-- WinJS references -->
<link rel="stylesheet" href="/winjs/css/ui-dark.css" />
<script src="/winjs/js/base.js"></script>
<script src="/winjs/js/wwaapp.js"></script>
<script src="winjs/js/ui.js"></script>
<script src="winjs/js/binding.js"></script>
<script src="winjs/js/controls.js"></script>
<script src="winjs/js/animations.js"></script>
<!-- MyAppBar references -->
<link rel="stylesheet" href="/css/default.css" />
<script src="/js/default.js"></script>
</head>
<body>
<div id="mybar" data-win-control="WinJS.UI.AppBar" data-win-options="{position:'bottom', transient:true, autoHide:0, lightDismiss:true}">
<div class="win-right">
<button class="win-command" id="settingsButton">
<span style="background-image: url('images/smalllogo.png')" class="win-commandicon"></span>
<span class="win-label">Settings</span>
</button>
</div>
</div>
</body>
</html>
The default.js file should like below. The highlighted(6 to 8) lines are required for WinJS controls to work.
Lines 13 to 16 are used to wire up the button in the App Bar button with a function.
(function () {
'use strict';
// Uncomment the following line to enable first chance exceptions.
// Debug.enableFirstChanceException(true);
document.addEventListener("DOMContentLoaded", function () {
WinJS.UI.processAll();
}, false);
WinJS.Application.onmainwindowactivated = function (e) {
if (e.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
// TODO: startup code here
var settingsButton = document.getElementById('settingsButton');
settingsButton.addEventListener('click', function () {
WinJS.Navigation.navigate('settings.html');
});
}
}
WinJS.Application.start();
})();