Skip to content

Instantly share code, notes, and snippets.

@tobbbe
tobbbe / add 404 page Umbraco fel
Created May 7, 2014 13:31
add 404 page Umbraco fel
1. create a node and name it 404
2. in umbracoSettings.config add the id of the node you just created to <errors><error404>
3. add <httpErrors existingResponse="PassThrough"/> to <system.webServer> in web.config
@tobbbe
tobbbe / Get absolute root path
Created June 5, 2014 08:23
Get absolute root path
@HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority)@Url.Content("~/" + img.Url + "?h=1000&q=90")
@tobbbe
tobbbe / chrome cors
Last active August 29, 2015 14:05
chrome cors
1. download chrome canary (like chrome beta)
2. create a alias/.bat-file (if you want)
MAC:
open terminal and do:
~/.bash_profile
navigate to a new line and add:
alias corsdev=’open -n -a /Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --args --disable-web-security’
@tobbbe
tobbbe / terminal default alias location
Created September 10, 2014 12:00
terminal default alias location
~/.bash_profile
ex:
alias utv2='cd /Volumes/Utv/Umb/'
alias mobildev='open -n -a /Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --args --disable-web-security'
@tobbbe
tobbbe / JSON in razor view
Last active August 29, 2015 14:09
JSON in razor view
@using Newtonsoft.Json
Response.Clear();
Response.Buffer = true;
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Write(JsonConvert.SerializeObject(new {
Fraktkostnad = @shop.Basket.FormattedShippingAmount,
Total = @shop.Basket.FormattedRowTotalAmount,
Moms = @shop.Basket.FormattedRowTotalVatAmount
function getWatchers(root) {
root = angular.element(root || document.documentElement);
var watcherCount = 0;
function getElemWatchers(element) {
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
var scopeWatchers = getWatchersFromScope(element.data().$scope);
var watchers = scopeWatchers.concat(isolateWatchers);
angular.forEach(element.children(), function (childElement) {
watchers = watchers.concat(getElemWatchers(angular.element(childElement)));
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
}
return "";
}
@tobbbe
tobbbe / new_gist_file_0
Created September 21, 2015 09:30
group list distinct each property c#
var groupedPerCountry = resellersNode.Children()
.Where(c => !string.IsNullOrWhiteSpace(c.GetPropertyValue<string>("dealerCountry")))
.ToList()
.ToLookup(c => c.GetPropertyValue<string>("dealerCountry").CleanUpper());
foreach (var group in groupedPerCountry)
{
@shopscontainer(group, group.Key)
}
@tobbbe
tobbbe / new_gist_file_0
Last active November 4, 2015 10:13
cordova-whitelist-plugin
install plugin
ionic plugin add https://github.com/apache/cordova-plugin-whitelist.git
in config.xml
<access origin="https://foo.se/api/*"/>
in index.html
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com foo.se https://foo.se; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval';">
<!--http://www.raymondcamden.com/2015/05/25/important-information-about-cordova-5-->
<!--http://content-security-policy.com/-->
@tobbbe
tobbbe / remove non-english chars, remove swedish chars
Created November 18, 2015 15:46
remove non-english chars, remove swedish chars, å ä ö, space Umbraco extensionmethod
public static Regex rgx = new Regex("[^a-zA-Z0-9-]");
public static string CreateProductUrl(this UmbracoHelper umbraco, IPublishedContent product)
{
var prodname = product.Name.ToLower()
.Replace(" ", "-")
.Replace("å", "a")
.Replace("ä", "a")
.Replace("ö", "o");