Skip to content

Instantly share code, notes, and snippets.

@tobbbe
tobbbe / Portal.cshtml
Last active August 30, 2021 12:03
create-react-app in umbraco (or any asp.net website)
@{
Layout = null;
}
<!-- OVERWRITE BELOW THIS LINE -->
// https://support.microsoft.com/en-gb/help/307996/how-to-create-an-asp-net-http-module-using-visual-c-net
namespace Cool.Website
{
public class CoolHttpModule : IHttpModule
{
private const string filename = "a.gif";
private const string onePixelGif = @"R0lGODlhAQABAPcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@tobbbe
tobbbe / umbraco-database-connect.md
Last active January 30, 2019 08:03
connect to local umbraco cloud database

if you run .sdf

  1. download and install linqpad https://www.linqpad.net
  2. open linqpad
  3. click "add connection"
  4. dont change anything and click "Next"
  5. under provider, choose "SQL CE 4.0"
  6. under database, click "Browse"
  7. find and choose your database, for umbraco its App_Data/Umbraco.sdf
  8. click TEST. If you get something like "the required DbProvider registration is not present" or "Unable to find Requested .Net Framework Data Provider", make sure SQL CE 4.0 runtime is installed: https://www.microsoft.com/en-au/download/details.aspx?id=17876
  9. click OK
@tobbbe
tobbbe / FileFromWebApi.cs
Created November 29, 2018 14:11
Send file from web api
public class ExampleController : UmbracoApiController
{
[HttpGet]
public IHttpActionResult GetFile()
{
var stream = new MemoryStream(); // well.. a MemoryStream
var result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new ByteArrayContent(stream.GetBuffer())
};
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@tobbbe
tobbbe / excel.cs
Last active June 27, 2018 09:33
Create excel workbook from types/sql https://github.com/ClosedXML/ClosedXML
using ClosedXML.Excel;
using System;
using System.IO;
using System.Linq;
using System.Web.Mvc;
namespace ExcelExample.Api.PrivateControllers
{
public class ExcelController : Controller
{
@tobbbe
tobbbe / gist:b6bf09fe8712d71df2afcf7e16610550
Created June 27, 2018 09:24
Create excel workbook from types
using ClosedXML.Excel;
using GHPHealthApp.Api.Persistence;
using GHPHealthApp.Api.Services;
using System;
using System.IO;
using System.Linq;
using System.Web.Mvc;
using Umbraco.Web.Mvc;
namespace GHPHealthApp.Api.PrivateControllers
@tobbbe
tobbbe / facebook-graph-api.md
Last active June 21, 2018 09:12
get stuff from facebooks api
  1. create an app on facebook
  2. get client_secret and client_id from the app page
  3. get an access_token: https://graph.facebook.com/oauth/access_token?client_id={client_id}&client_secret={client_secret}&grant_type=client_credentials
  4. get something: https://graph.facebook.com/{page_id}/posts?access_token={access_token_from_3}&fields=attachments,message,created_time,type,target,link

Some endpoints require more permissions (manage_pages for page reviews etc). You request these on the app page.

@tobbbe
tobbbe / upgrade-litium.md
Created June 19, 2018 06:58
Upgrade Litium and accelerator

check for breaking changes: https://docs.litium.com/documentation/release-notes

  1. Open "Manage NuGet packages for solution".
  2. Go to Updates tab
  3. Search for "litium"
  4. Check "Update all" (maybe different text?)
  5. Click Update.
  6. Wait. (6.5. Run website\packages\Litium.Setup.Core.6.1.1\tools\Upgrade_PreRequires.sql in SQL studio to check if database update will work)
  7. Open Package Manager Console and execute "Update-LitiumDatabase"