Skip to content

Instantly share code, notes, and snippets.

View netsi1964's full-sized avatar

Sten Hougaard netsi1964

View GitHub Profile
@netsi1964
netsi1964 / chromeExperimantalFeatures.json
Last active August 28, 2015 07:40
Chrome Experimental Features
{
"version": 1,
"chromeVersion": 44,
"generated": "2015-08-28T07:38:43.470Z",
"features": [{
"id": "ignore-gpu-blacklist",
"platform": ["Mac", "Windows", "Linux", "Chrome OS", "Android"],
"name": "Tilsidesæt liste over gengivelse af software"
}, {
"id": "enable-experimental-canvas-features",
@netsi1964
netsi1964 / DynamicwebECommerceRazorShowOrderTotalPrice.cshtml
Created January 31, 2014 17:03
Razor snippet which will show a formated Cart TotalPrice
@{
// Check if cart exists
var cart = "Empty";
if (System.Web.HttpContext.Current.Session["eComCart"]!="")
{
Dynamicweb.eCommerce.Orders.Order order = (Dynamicweb.eCommerce.Orders.Order) System.Web.HttpContext.Current.Session["eComCart"];
// Format like this: 1.299,95
cart = String.Format("{0:0,0.00}", order.TotalPrice);
}
}
@netsi1964
netsi1964 / DynamicwebJSONOrderTotalPrice.aspx
Created February 1, 2014 09:24
Dynamicweb ASPX C# code to return Cart TotalPrice in JSON
<%@ Page Language="cs" AutoEventWireup="false" %>
<%
/* SHO 01/02/2014 10.21: Returns a JSON object containing JSON object with info of Cart TotalPrice formated as 2.999,95
If no cart exists it contains -1
It also has a soloution based counter which can be used to get a unique number.
It sets cache information in header to avoid client side caching of response.
Place it in /Admin/Public/ or use it in Razor
*/
// Clear any previous reponse, importend in Razor scenaries
@netsi1964
netsi1964 / EXAMPLEoutputJavascriptConsolePolyfill.js
Last active August 29, 2015 13:56
Generate window.console polyfill
if (typeof window.console==='undefined') window.console = {'ver':'Fri Feb 07 2014 16:44:36 GMT+0100 (CET)','debug':function(){},'error':function(){},'info':function(){},'log':function(){},'warn':function(){},'dir':function(){},'dirxml':function(){},'table':function(){},'trace':function(){},'assert':function(){},'count':function(){},'markTimeline':function(){},'profile':function(){},'profileEnd':function(){},'time':function(){},'timeEnd':function(){},'timeStamp':function(){},'timeline':function(){},'timelineEnd':function(){},'group':function(){},'groupCollapsed':function(){},'groupEnd':function(){},'clear':function(){}}

System.Collections.Generic.List1[Dynamicweb.Rendering.RazorTemplateBase1+LoopItem[System.Object]]

Dynamicweb, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null

Methods

Name Public? Return
get_Capacity() True System.Int32
set_Capacity(System.Int32 value) True System.Void
get_Count() True System.Int32
@netsi1964
netsi1964 / snippet_convertFormToJSON.js
Created February 8, 2014 13:22
Convert FORM elements to JSON snippet
var json;
function toJSON(selector) {
var elements = document.querySelectorAll(selector+' [name]');
var obj = {};
for(var ele=0;ele<elements.length;ele++) {
var t = elements[ele];
obj[t.name] = t.value;
}
prompt("form "+selector+"", JSON.stringify(obj))
};
@netsi1964
netsi1964 / sameHight.js
Created February 25, 2014 11:16
jQuery sameHeight(selector)
// https://gist.github.com/9207088
function sameHeight(settings) {
var defaults = {
"selector": "",
"ignoreZero": true,
// If minHeight <= 0 and ignoreZero==true, no action taken
"minHeight": -1
};
var usedSettings = $.extend(defaults, settings);

AngularJS making AJAX request using $resource

AngularJS has a module which handles requests using AJAX. In this pen I request data from a Dynamicweb CMS based website.

A Pen by Sten Hougaard on CodePen.

License.

@netsi1964
netsi1964 / bootstrapAngularjs.html
Last active August 29, 2015 13:56
Bootstrap and angularJS
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.css">
<link rel="stylesheet" href="style.css">
<title>Bootstrap/angularjs</title>
</head>
@netsi1964
netsi1964 / redirectIfPIDMissing.cshtml
Created March 13, 2014 08:16
Dynamicweb Razor redirect if missing PID
// Code snippet for request missing PID - say coming from Google search
@using System.Web
@using Dynamicweb.Frontend;
var request = HttpContext.Current.Request;
var response = HttpContext.Current.Response;
var pidFromRequest = Dynamicweb.Base.ChkString(request["pid"]);
var pageviewURL = GetGlobalValue("Global:Pageview.Url");
if (pidFromRequest=="") {