Skip to content

Instantly share code, notes, and snippets.

@mattiasnorell
mattiasnorell / LocalStorage.ts
Created December 5, 2021 11:30
Decorator that sets a Vue property to a value stored in local storage
import { cid, container } from 'inversify-props';
import { ILocalStorageHelper } from '__helpers/storage/LocalStorageHelper';
type LocalStorageOptions = {
storageKey: string;
default?: any;
};
/**
* Decorator to set property values based on values stored in local storage
*
// Helloworld
@mattiasnorell
mattiasnorell / couchpotatoserver.py
Last active July 28, 2021 18:19
Pull and publish .NetCore applications from command line
from flask import Flask
from flask import request, Response
from flask_cors import CORS, cross_origin
from crontab import CronTab
import os
import psutil
import subprocess
import select
import json
from flask import jsonify
@mattiasnorell
mattiasnorell / restore_database_and_owner.sql
Created April 26, 2019 08:35
Restore MSSQL-database and add owners
USE [Master];
DECLARE @databaseName varchar(8000) = 'DATABASE NAME';
DECLARE @backupPath varchar(8000) = 'c:\path\to\database.bak';
DECLARE @databaseOwners varchar(2000) = 'list;of;usernames';
DECLARE @kill varchar(8000) = '';
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), session_id) + ';'
FROM sys.dm_exec_sessions
WHERE database_id = db_id(@databaseName)
@mattiasnorell
mattiasnorell / restore.sql
Created March 12, 2019 11:25
Restore MSSQL database
USE [Master];
DECLARE @databaseName varchar(8000) = 'DATABASE NAME';
DECLARE @backupPath varchar(8000) = 'c:\path\to\database.bak';
DECLARE @kill varchar(8000) = '';
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), session_id) + ';'
FROM sys.dm_exec_sessions
WHERE database_id = db_id(@databaseName)
@mattiasnorell
mattiasnorell / ExportAsExcel.cshtml
Created February 20, 2015 14:13
List all page types from a EPiServer CMS 7.5
@model IEnumerable<EPiServer.DataAbstraction.ContentType>
@{
Layout = null;
}
@Html.Partial("PageTypeTablePartial", Model)
@mattiasnorell
mattiasnorell / ExportPageFilesController.cs
Last active August 29, 2015 14:15
EPiServer CMS 7.5 gadget to export a zip-file containing all files for a specific page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using EPiServer;
using EPiServer.Core;
using EPiServer.Shell.Gadgets;
using Ionic.Zip;
namespace Website.Web.Gadgets.Controllers
#!/bin/sh
message=$SMS_1_TEXT
if test "$message" = "shutdown"; then
/sbin/shutdown -h now
fi
#!/bin/sh
sendto="0123456789"
message=$SMS_1_TEXT
from=$SMS_1_NUMBER
echo "$from\n$message" | sudo gammu sendsms TEXT "$sendto"
#!/bin/sh
from=$SMS_1_NUMBER
message=$SMS_1_TEXT
reply=""
if test "$message" = "Ping"; then
reply="Pong!"
else
reply="Y U NO PLAY PING PONG?"
fi