Skip to content

Instantly share code, notes, and snippets.

View EricAtMSFT's full-sized avatar

Eric Langland EricAtMSFT

  • Microsoft
  • Vashon Island, WA
View GitHub Profile
$.ajax({
url: 'https://dealpigs.com/svc/productline',
type: 'GET',
success: function (data) {
alert(JSON.stringify(data))); //show JSON of deals array
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
/// <summary>
/// Checks if the defined document database and collection exists
/// and initializes them if they don't.
/// </summary>
public async Task InitializeDatabaseIfNotExisting(string serverPath)
{
var database = _documentClient.CreateDatabaseQuery()
.Where(db => db.Id == _documentDataBaseId)
.AsEnumerable()
.FirstOrDefault();
@EricAtMSFT
EricAtMSFT / DocumentDbRepository.cs
Last active March 15, 2016 06:51
DocumentDB query using simple lambda expressions
/// <summary>
/// Fetches the photo stream data for a specified user.
/// </summary>
/// <param name="userId">The user id.</param>
/// <param name="continuationToken">Last captured ticks in the form of a string.</param>
/// <returns>List of photos up to the page size.</returns>
public async Task<PagedResponse<PhotoContract>> GetUserPhotoStream(string userId, string continuationToken)
{
var feedOptions = new FeedOptions
{
// Store Procedure for getting the most recent photos for each category
// @param numberOfPhotos - The number of photos to return per category
// @param currentDocumentVersion - The current document version number that the service is using
function getRecentPhotosForCategories(numberOfPhotos, currentDocumentVersion) {
let catCount = 0;
let catIndex = 0;
let existingPhotos = [];
getAllCategories(function (allCategories) {
for (var i = 0; i < allCategories.length; i++) {
// Stored Procedures
private const string TransferGoldStoredProcedureScriptFileName = @"Models\DocumentDB\js\transferGoldStoredProcedure.js";
private const string TransferGoldStoredProcedureId = "transferGold";
private const string GetRecentPhotosForCategoriesStoredProcedureScriptFileName = @"Models\DocumentDB\js\getRecentPhotosForCategoriesStoredProcedure.js";
private const string GetRecentPhotosForCategoriesStoredProcedureId = "getRecentPhotosForCategories";
private async Task InitializeStoredProceduresInDocumentDb()
{
// Initialize GoldTransaction Sproc
var sproc = new StoredProcedure
@EricAtMSFT
EricAtMSFT / PageHeader.xaml
Last active March 17, 2016 18:23
Add a logo....
<UserControl
x:Class="PhotoSharingApp.Universal.Controls.PageHeader"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PhotoSharingApp.Universal.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:valueConverters="using:PhotoSharingApp.Universal.ValueConverters"
VerticalAlignment="Top"
VerticalContentAlignment="Top"
@EricAtMSFT
EricAtMSFT / Styles.xaml
Created March 10, 2016 00:40
Change the main style colors for the app
<Color x:Key="AppAccentColor">#3498db</Color>
<SolidColorBrush x:Key="AppAccentColorBrush" Color="{StaticResource AppAccentColor}" />
<Color x:Key="AppAccentLightColor">#2980b9</Color>
<SolidColorBrush x:Key="AppAccentLightColorBrush" Color="{StaticResource AppAccentLightColor}" />
<Color x:Key="AppAccentForegroundColor">#333333</Color>
<SolidColorBrush x:Key="AppAccentForegroundColorBrush" Color="{StaticResource AppAccentForegroundColor}" />
<Color x:Key="AppAccentBackgroundColor">#FFE6E6E6</Color>
<SolidColorBrush x:Key="AppAccentBackgroundColorBrush" Color="{StaticResource AppAccentBackgroundColor}" />
<Color x:Key="BusyIndicatorBackgroundColor">#7F000000</Color>
<SolidColorBrush x:Key="BusyIndicatorBackgroundColorBrush" Color="{StaticResource BusyIndicatorBackgroundColor}" />