Skip to content

Instantly share code, notes, and snippets.

View ThorstenHans's full-sized avatar

Thorsten Hans ThorstenHans

View GitHub Profile
@ThorstenHans
ThorstenHans / products.controller.js
Created December 4, 2017 11:43
restify demo - products.controller.js
class ProductsController {
constructor() {
this._storage = [];
}
_findProductById(id) {
const product = this._storage.find(product => product.id === id);
if (!product) {
throw new Error('Product not found.');
@ThorstenHans
ThorstenHans / observer.ts
Created January 5, 2017 07:53
Observer Pattern in TypeScript
class Subjekt {
private _beobachter: Array<IBeobachter> = [];
constructor(){
this._beobachter = [];
}
public register(beobachter: IBeobachter): void {
this._beobachter.push(beobachter);
}
@ThorstenHans
ThorstenHans / main.css
Created May 11, 2015 12:57
saarcamp win fix
a{
margin-right:0px;
}
@ThorstenHans
ThorstenHans / Search.Sample.js
Last active August 29, 2015 14:08
ShareCoffee Search Sample
// pass querytext, selectproperties, querytemplate to the ctor
var properties = new ShareCoffee.QueryProperties();
// or set them directly on the properties object
properties.queryText = "Office 365";
properties.rowLimit = 100;
properties.startRow = 50;
// either set on properties Object or use jQuery's API chain
properties.onSuccess = function(data){
@ThorstenHans
ThorstenHans / AppDelegate.cs
Last active August 29, 2015 14:06
Xamarin.Forms MasterDetailPage
using Xamarin.Forms;
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
UIWindow window;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
Forms.Init ();
@ThorstenHans
ThorstenHans / myspcontext.js
Last active August 29, 2015 14:02
MVC SharePointContext
(function (window, undefined) {
"use strict";
var $ = window.jQuery;
var document = window.document;
// SPHostUrl parameter name
var SPHostUrlKey = "SPHostUrl";
internal class ContactsRepository : IContactsRepository<IContact>
{
private ExchangeClient _exchangeClient;
private const string ExchangeResourceId = "https://outlook.office365.com";
private const string ExchangeServiceRoot = "https://outlook.office365.com/ews/odata";
private const int PageSize = 50;
private async Task<ExchangeClient> EnsureExchangeClient()
{
if (_exchangeClient != null)
@ThorstenHans
ThorstenHans / CalendarAPISample.cs
Last active June 28, 2019 16:45
O365 API Sample
using Microsoft.Office365.Exchange;
using Microsoft.Office365.OAuth;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WebApplication2
{
@ThorstenHans
ThorstenHans / appweburl.js
Last active August 29, 2015 13:56
ShareCoffee0011
// Load the AppWebUrl (default implementation)
var appWebUrl = ShareCoffee.Commons.getAppWebUrl();
// provide a custom load function for loading the AppWebUrl
ShareCoffee.Commons.loadAppWebUrlFrom = function(){
$.ajax({url: 'Context/AppWebUrl', type: 'GET', async: false}).responseJSON;
};
var appWebUrl = ShareCoffee.Commons.getAppWebUrl();
@ThorstenHans
ThorstenHans / Sample.coffee
Last active August 29, 2015 13:56
ShareCoffee.UserProfiles
window.MyAngularApp.service 'userProfilesService', ['$http', ($http) ->
loadMyProfile: (onSuccess, onError) ->
$http ShareCoffee.REST.build.read.for.angularJS
url: ShareCoffee.Url.GetMyProperties
.success onSuccess
.error onError
loadProfilePropertiesForUser: (accountName, onSuccess, onError) ->
properties = new ShareCoffee.UserProfileProperties(ShareCoffee.Url.GetUserProfileProperty, accountName, 'WorkEmail')