Skip to content

Instantly share code, notes, and snippets.

@tobbbe
tobbbe / autohotkey reload
Created October 9, 2013 13:54
autohotkey reload page on save visual studio
$^s:: ; only capture actual keystrokes
SetTitleMatchMode, 2 ; match anywhere in the title
IfWinActive, Sublime Text 2 ; find Sublime Text
{
Send ^s ; send save command
IfWinExist, Mozilla Firefox ; find firefox
{
WinActivate ; use the window found above
Send ^r ; send browser refresh
WinActivate, Sublime Text 2 ; get back to Sublime Text
@tobbbe
tobbbe / add MIME typer IIS
Created October 14, 2013 10:52
add MIME typer IIS
Gå in på sidan på IISen så finns en MIME-typ hanterare. Lägg till
Detta skapar också en web.config fil! NICE!
@tobbbe
tobbbe / localstorage size
Created October 14, 2013 17:31
show size of localstorage + bookmarklet
Bookmarklet:
javascript: var x,log=[],total=0;for (x in localStorage){log.push(x + " = " + ((localStorage[x].length * 2)/1024/1024).toFixed(2) + " MB"); total+=localStorage[x].length * 2}; log.push("Total = " + (total/1024/1024).toFixed(2)+ " MB"); alert(log.join("\n"));
Console:
for(var x in localStorage)console.log(x+"="+((localStorage[x].length * 2)/1024/1024).toFixed(2)+" MB");
@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 / google maps iframe
Created July 10, 2014 09:24
google maps iframe
@{
var longitude = Location.Longitude.ToString() ?? null;
var latitude = Location.Latitude.ToString() ?? null;
var googlemapSource = "https://www.google.com/maps/embed/v1/";
if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude))
{
// map mode
googlemapSource += "place?";
@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)));