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 / UmbracoRazorLogin.cshtml
Created March 17, 2011 11:44
Umbraco member login script (razor)
@using System.Web
@using System.Web.Security
@helper LoginForm()
{
<form method="post">
<div><label for="name">Username:</label>
<input type="text" id="username" name="username"/></div>
<div><label for="password">Password:</label>
<input type="password" id="password" name="password"/></div>
<div><input type="submit" id="submit" name="submit" value="login"/></div>
@joeriks
joeriks / Comment.cshtml
Created March 19, 2011 16:51
Basic Umbraco Razor commentary form
@using umbraco.cms.businesslogic.web
@* A Razor script to add a basic comment function to Umbraco pages
You need a document type called Comment with a textstring property
called commentName and a textbox multiple property called commentMessage
You also need to allow the Comment document type as child document type
to your textpage document type.
Create this script with a macro and add it below the bodyText in your
template(s) *@
@joeriks
joeriks / madmimi.cshtml
Created March 21, 2011 20:57
Helper function to send Mad Mimi promotional email
@using System.Text
@using System.Reflection
@functions {
private const string Username = "your email";
private const string APIKey = "your api-key";
private const string Sender = "your email";
public static string ToYaml(object o)
{
@joeriks
joeriks / dncollab.cs
Created March 23, 2011 02:33
Umbraco DynamcNode Extensions
///
/// This is a first attempt to make some useful extension methods to dynamic node and dynamic node list
/// Comments and collab is more than welcome!
///
/// Ref (Gareth Evans):
/// http://umbraco.com/follow-us/blog-archive/2011/2/28/umbraco-razor-feature-walkthrough-%E2%80%93-part-3
///
using System;
using System.Collections.Generic;
@joeriks
joeriks / NancyStart.cs
Created April 6, 2011 09:47
First try with NancyFx and SisoDb - form insert and list product names
using System;
using System.Collections.Generic;
using System.Web;
using System.Linq;
using SisoDb;
/// <summary>
/// Requires the NuGet packages Nancy.Hosting.Aspnet and SisoDb
/// and a local Database in .\Sqlexpress called sisodemo
/// </summary>
@joeriks
joeriks / HtmlFormHelpers.cs
Created April 7, 2011 13:14
Using a generic html form builder with client side and server side validation (Fluent Validation)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FluentValidation;
using System.Collections.Specialized;
namespace HtmlFormHelpers
{
@joeriks
joeriks / Example.cshtml
Created April 8, 2011 06:14
HtmlFormsHelper
EDIT : HtmlFormsHelper has evolved to https://github.com/joeriks/DynaForms
@using HtmlFormHelpers
@{
var form = new HtmlFormDescriptor("project-form", project);
// Create a new project, or get it from the database (using PetaPoco in this example).
Project project;
@joeriks
joeriks / testurls.js
Created May 15, 2011 15:05
Google Sheet script: test urls
var sendEmailTo = "me@mysite.com";
var emailErrorSubject = "ERROR on your web site";
function isCellEmpty(cellData) {
return typeof(cellData) == "string" && cellData == "";
}
function autotest_hourly() {
checkUrls("Autotest");
}
@joeriks
joeriks / jsonsample.cs
Created June 12, 2011 13:31
Sample JSon array with c# anonymous objects (Webmatrix)
@{
var arry = new[] {
new {
id=Guid.NewGuid(),
name="one",
done=false
},
new {
id=Guid.NewGuid(),
name="two",
@joeriks
joeriks / callback.cs
Created June 13, 2011 08:12
Javascript like send callback function in C#
static void Main(string[] args)
{
// sample Callback in C#
string message = "Done!";
startRunner(finished, message);
}
static public void finished(string message)
{
Console.Write(message);
}