Skip to content

Instantly share code, notes, and snippets.

View AdamCaviness's full-sized avatar

Adam Caviness AdamCaviness

View GitHub Profile
[WebGet]
public IQueryable<Setting> GetSettings(Guid userId, Guid platformContextId)
{
return DataSource.GetSettings(userId, platformContextId).AsQueryable<Setting>();
}
[WebInvoke]
public void UpdateSetting(Guid userId, string serializedSetting)
{
var serializationService = new SerializationService();
var existingSetting = _settings.Where(s => s.SettingKey == setting.SettingKey).FirstOrDefault();
if (existingSetting == null)
throw new ArgumentException("Attempting to update Setting with name '{0}' but the setting is not cached and cannot be updated.");
existingSetting.Value = setting.Value;
var parameters = new UriOperationParameter[] {
new UriOperationParameter("userId", _userSession.User.UserID ),
new UriOperationParameter("serializedSetting", _serializationService.SerializeAsString<Setting>(existingSetting)) };
var context = _dataContextFactory.Create(MergeOption.AppendOnly);
// Perform WCF Data Services ServiceOperation call.
var parameters = new UriOperationParameter[] {
new UriOperationParameter("userId", _userSession.User.UserID ),
new UriOperationParameter("platformContextId", _appSession.PlatformContextId) };
var context = _dataContextFactory.Create(MergeOption.AppendOnly);
_settings = context.Execute<Setting>(new Uri("GetSettings", UriKind.Relative), "GET", false, parameters).ToList();
@AdamCaviness
AdamCaviness / crockfordClass.js
Created March 23, 2015 01:57
Douglas Crockford class
/*jslint node: true*/
'use strict';
Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
function Parenizor(value) {
this.setValue(value);
@AdamCaviness
AdamCaviness / crockfordInheritance.js
Created March 23, 2015 02:22
Douglas Crockford classical inheritance
/*jslint node: true*/
'use strict';
var Parenizor = require('./crockfordClass').Parenizor;
Function.method('inherits', function (parent) {
this.prototype = new parent();
var d = {},
p = this.prototype;
this.prototype.constructor = parent;
@AdamCaviness
AdamCaviness / boxstarter
Last active August 29, 2015 14:20
Boxstarter script
Set-ExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
cinst fiddler4
cinst git
cinst nodejs
cinst Brackets
cinst kdiff3
cinst jre8
cinst redis-desktop-manager