Skip to content

Instantly share code, notes, and snippets.

View haraldfianbakken's full-sized avatar

Harald S. Fianbakken haraldfianbakken

View GitHub Profile
@haraldfianbakken
haraldfianbakken / gist:5115075
Created March 8, 2013 08:47
Device management for IBUDDY
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace GenericHid
{
internal sealed partial class DeviceManagement
{
@haraldfianbakken
haraldfianbakken / gist:5115090
Created March 8, 2013 08:50
Buddy interface
namespace ibuddylib {
public enum TorsoYaw { Middle, Left, Right };
public enum WingPosition { Low, High };
public enum HeadColor { Off, White, Cyan, Purple, Blue, Yellow, Green, Red };
public enum HeartLight { Off, On };
/// <summary>
/// The interface that both physical and virtual i-Buddies respond to
/// </summary>
public interface IBuddy {
@haraldfianbakken
haraldfianbakken / gist:5115121
Created March 8, 2013 08:57
IBuddyCommands (REST)
using System.Web.Mvc;
namespace SharePirates.BuddyWeb.Controllers
{
public interface IBuddyCommands
{
ActionResult Flash(string color);
ActionResult Twist();
ActionResult HeartBeat(int ms=-1);
ActionResult HeadColor(string color);
@haraldfianbakken
haraldfianbakken / gist:5115132
Created March 8, 2013 08:58
Buddy commands - REST API
using System;
using System.Web.Mvc;
using ibuddylib;
namespace SharePirates.BuddyWeb.Controllers
{
public class BuddyController : Controller, IBuddyCommands
{
private static BuddyAnimator _animator;
@haraldfianbakken
haraldfianbakken / gist:5115167
Last active December 14, 2015 16:29
Powershell wrapper - Admin job
while($true){
$error = Get-SPLogEvent -StartTime ([DateTime]::Now).Subtract([Timespan]::FromHours(1))|? { $_.Level -eq "Error" -or $_.Level -eq "Critical"}
if($error){
[ibuddylib.BuddyManager]::Global.AnyBuddy.HeadColor = "Red";
Start-Sleep -Minutes 5;
[ibuddylib.BuddyManager]::Global.AnyBuddy.HeadColor = "Off";
} else{
@haraldfianbakken
haraldfianbakken / gist:5378460
Created April 13, 2013 13:44
Allowed inheritance - Structuremap
public class SecureController : Controller
{
public SecureController(IMemberService memberService, ISecurityContext securityContext) : base(memberService, securityContext)
{
}
}
public class AccountController : SecureController
{
public AccountController(IMemberService memberService,ISecurityContext securityContext) : base(memberService,securityContext)
@haraldfianbakken
haraldfianbakken / gist:5378465
Created April 13, 2013 13:45
Not allowed inheritance by structuremap
public class SecureController : Controller
{
protected SecureController(IMemberService memberService, ISecurityContext securityContext) : base(memberService, securityContext)
{
}
}
public class AccountController : SecureController
{
public AccountController(IMemberService memberService,ISecurityContext securityContext) : base(memberService,securityContext)
@haraldfianbakken
haraldfianbakken / controller-example
Created April 10, 2014 08:42
controller-example
controller : function ($scope, $log, $stateParams, init, service) {
var ctrl = new slideController($scope,$log,$stateParams,init);
$scope.addInsuranceCard = function(){
$scope.data.items.push({});
}
$scope.removeInsuranceCard = function(card){
var confirmed = confirm('Do you want to remove this item?');
if(confirmed){
@haraldfianbakken
haraldfianbakken / workaround
Last active August 29, 2015 13:58
transition-workaround
$scope.removeInsuranceCard = function(card){
var confirmed = confirm('Do you want to remove this item?');
if(confirmed){
$log.debug("Removing item @"+$scope.data.selectedIndex);
$scope.data.items.splice($scope.data.selectedIndex,1);
$scope.selectedItem = $scope.data.items[$scope.data.selectedIndex];
$stateParams.index = $scope.data.selectedIndex;
// Force GUI TO be updated when removing the item bug in the carousel
$state.transitionTo($state.current, $stateParams, {