Skip to content

Instantly share code, notes, and snippets.

View joeriks's full-sized avatar
💭
I may be slow to respond.

Jonas Eriksson joeriks

💭
I may be slow to respond.
View GitHub Profile
@joeriks
joeriks / MyHub.cs
Created February 3, 2014 14:53
SignalR and FnX.EsentStore
using System;
using System.Web;
using Microsoft.AspNet.SignalR;
using System.Collections.Generic;
namespace SignalRChat
{
public class ChatHub : Hub
{
@joeriks
joeriks / parallell.cs
Created February 4, 2014 10:14
Don't forget to test parallell actions
/* Lock dictionary between read and write */
public T Do(string key, Func<T,T> func){
lock (_dictionary) {
var originalValue = get<T>(key);
var newValue = func(originalValue);
set(key, newValue);
return newValue;
}
}
@joeriks
joeriks / jamp.md
Last active August 29, 2015 13:56
thoughts about a web fw

(1) = exists in preview state (2) = planned next (3) = planned

main stuff

  • completely free and open source
  • convention over configuration
  • simple to use
  • reliable
@joeriks
joeriks / OrigoGettingStarted.cs
Last active August 29, 2015 13:56
OrigoDb Gettingstarted
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OrigoDB.Core;
using System.Collections.Generic;
using System.Linq;
namespace PlayingWithOrigoDB
{
[TestClass]
public class QuickStartGuide
@joeriks
joeriks / math_in_jquery
Created February 13, 2014 08:02
Excel like calculations are horrible with jquery - time to move to knockout/angular
function flt(fieldName) {
var parsedValue = parseFloat($('#' + fieldName).val().replace(",", "."));
if (isNaN(parsedValue)) parsedValue = 0;
$('#' + fieldName).val(parsedValue);
return parsedValue;
}
function recalculate(reset) {
var r1 = (flt("i1") * 1000 - 2 * flt("i4"));
$("#r1").val(Math.round(r1));
@joeriks
joeriks / TaskRun.cs
Last active August 29, 2015 13:56
C# async await the most basic example
void slowTask(){
Console.WriteLine("Prints after");
}
void Main()
{
Task.Run(()=>slowTask());
Console.WriteLine("Prints immediately");
}
@joeriks
joeriks / gist:9639731
Created March 19, 2014 11:24
necessary fixes in fsproj to make it build in azure deployment
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')"/>
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')" />
@joeriks
joeriks / gist:11247871
Created April 24, 2014 09:21
the lazy first impressions nodejs from webstorm
1) tried to run the express project got the error
Error creating Node.js Express App. Wrong express generator
http://devnet.jetbrains.com/message/5513598#5513598
2) tried to run the nodejs boilerplate and then the initproject.bat
Fails as mongodb "Not compatible with your operating system or architecture.. x64"
3) tried to run a basic nodescript created from outside webstorm. No packages installed. Runs nicely, but no intellisense "Unresolved function require()"
@joeriks
joeriks / web.config
Created June 19, 2014 13:46
the mvc forum web config for use within virtual directory application inside umbraco application
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth.Core">
<section name="messaging" type="DotNetOpenAuth.Configuration.MessagingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true"/>
<section name="reporting" type="DotNetOpenAuth.Configuration.ReportingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true"/>
@joeriks
joeriks / output.txt
Last active August 29, 2015 14:05
Experimenting with DocumentDb - basic write and read (from ScottGu example) - and timing from local pc
Time to create connection and get collection 2513 ms
Time to perform simple query 448 ms
Andersen family:
{
"id": "AndersenFamily",
"lastName": "Andersen",
"parents": [
{
"firstName": "Thomas"
},