Skip to content

Instantly share code, notes, and snippets.

View ThorstenHans's full-sized avatar
:octocat:

Thorsten Hans ThorstenHans

:octocat:
View GitHub Profile
@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')
# install sass on windows
gem install sass
# ensure root permissions on -ix systems using sudo
sudo gem install sass
# check the installation by querying for the current SASS version
sass -v
@ThorstenHans
ThorstenHans / ArraysAndObjects.coffee
Last active August 29, 2015 13:56
Introduction to CoffeeScript
myObject =
foo: 'bar'
isThisAwesome: true
requiresLessKeystrokes: true
complex:
ifYouAreInterestedIn: true
stillReadable: true
caption: 'CoffeeScript'
compilesTo: 'JavaScript'
cost: 0
@ThorstenHans
ThorstenHans / InstallAndCreateAddOn.bash
Last active August 29, 2015 13:55
Installing yeoman and generator-sharecoffee-addon
# Ensure that nodejs is installed on your system
# Install yeoman globally
npm install yo -g
# on unix systems or macs you should use sudo when installing global packages
sudo npm install yo -g #MAC/LINUX
# Install generator globally
npm install generator-sharecoffee-addon -g
@ThorstenHans
ThorstenHans / GetFormDigestValue.coffee
Last active January 4, 2016 20:39
Obtain ContextInfo using ShareCoffee
$http(ShareCoffee.REST.build.create.for.angularJS {url: 'contextinfo'})
.success((data)->
# great for single time use
formDigestValue = data.d.GetContextWebInformation.FormDigestValue
# use this for page instace wide usages
ShareCoffee.Commons.formDigestValue = data.d.GetContextWebInformation.FormDigestValue
).error((error)->
console.log "error while loading contextinfo"
)
@ThorstenHans
ThorstenHans / Default.html
Last active January 4, 2016 19:50
ShareCoffee.Search
<!-- for the minified version -->
<script type='text/javascript' src="~/Scripts/ShareCoffee/ShareCoffee.min.js"></script>
<script type='text/javascript' src="~/Scripts/ShareCoffee.Search/ShareCoffee.Search.min.js"></script>
<!-- or for the debug version -->
<script type='text/javascript' src="~/Scripts/ShareCoffee/ShareCoffee.js"></script>
<script type='text/javascript' src="~/Scripts/ShareCoffee.Search/ShareCoffee.Search.js"></script>
@ThorstenHans
ThorstenHans / App.js
Last active December 31, 2015 22:29
ShareCoffee and ChartJS.org
// the next line of code brings somple IntelliSense within VS
/// <reference path="ShareCoffee/ShareCoffee.js"/>
$(document).ready(function () {
var onLoaded = function (data) {
var ctx = document.getElementById("myChart").getContext("2d");
var chartData = {
labels: [],
datasets: [{
fillColor: "#3399cc",
@ThorstenHans
ThorstenHans / ChromeSample.js
Last active December 31, 2015 06:09
ShareCoffee ChromeControl
var iconUrl = 'https://www.example.com/myappicon.png';
var appChromeSettings = new ShareCoffee.ChromeSettings(iconUrl, 'SharePoint ChromeControl Sample',
// Settings links are displayed within the AppChrome.
// 1. Parameter = 'TargetURL'
// 2. Parameter = 'Title'
// 3. Parameter = AppendCurrentQueryString (true|false)
new ShareCoffee.SettingsLink('foo.html', 'Foo', true),
new ShareCoffee.SettingsLink('bar.html', 'Bar', true));
var onSuccess = function(){
console.log('SharePoint App Chrome and CSS loaded');
@ThorstenHans
ThorstenHans / UDF.js
Created November 11, 2013 20:54
Creating an JavaScript UDF for SharePoint 2013 Excel Services
window.ExpertsInside = {
makeUpperString: function(input){
return input.toUpperString();
}
};
if(window.attachEvent){
window.attachEvent("onload", registerUserDefinedFunction);
}else{
window.addEventListener("DOMContentLoaded", registerUserDefinedFunction, false);
@ThorstenHans
ThorstenHans / AppChrome.js
Created October 29, 2013 15:43
ShareCoffee Samples for my blog
var chromeSettings = new ShareCoffee.ChromeSettings("", "My AutoHosted SharePoint App",
new ShareCoffee.SettingsLink("foo.html", "Foo", true),
new ShareCoffee.SettingsLink("bar.html", "Bar", true)
);
var onAppChromeLoaded = function () {
console.log("chrome should be loaded now!");
};
ShareCoffee.UI.loadAppChrome("chrome-placeholder-id", chromeSettings, onAppChromeLoaded);