Skip to content

Instantly share code, notes, and snippets.

Björn Ali Göransson bjorn-ali-goransson

View GitHub Profile
@bjorn-ali-goransson
bjorn-ali-goransson / test.php
Created Mar 7, 2018
List orphaned and missing media (attachments)
View test.php
<?php
require 'wp-blog-header.php';
if(isset($_GET['delete_post'])){
wp_delete_post($_GET['delete_post']);
die;
}
?>
@bjorn-ali-goransson
bjorn-ali-goransson / adminer.php
Last active Mar 6, 2018
Automatic login to Adminer using Wordpress DB credentials (wp-config.php)
View adminer.php
<?php
function define_find( $filename = 'wp-config.php' ) { // https://github.com/interconnectit/Search-Replace-DB/blob/master/index.php#L726
if ( $filename == 'wp-config.php' ) {
$filename = dirname( __FILE__ ) . '/' . basename( $filename );
// look up one directory if config file doesn't exist in current directory
if ( ! file_exists( $filename ) )
$filename = dirname( __FILE__ ) . '/../' . basename( $filename );
@bjorn-ali-goransson
bjorn-ali-goransson / Example.csproj
Created Jul 4, 2017
Sample csproj for classic .NET apps
View Example.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputType>Library</OutputType>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<RuntimeIdentifier>win7-x86</RuntimeIdentifier>
<OutputTypeEx>library</OutputTypeEx>
<BuildOutputTargetFolder>lib\net461</BuildOutputTargetFolder>
</PropertyGroup>
@bjorn-ali-goransson
bjorn-ali-goransson / LoginTest.aspx
Created Jun 16, 2017
This file can help by debugging "user cannot log in" problems when in EPiServer the user is just redirected back to the login page when logging in. Probably you are authenticated but not authorized.
View LoginTest.aspx
<%@ Page Language="C#" %>
<script runat="server">
protected override void OnInit(EventArgs e){
Response.Write(User.Identity.Name);
Response.Write("<br>");
foreach(var role in System.Web.Security.Roles.GetRolesForUser()){
Response.Write(role);
Response.Write("<br>");
}
}
@bjorn-ali-goransson
bjorn-ali-goransson / HttpUtility.cs
Created Jul 3, 2016
Standalone HttpUtility for using ParseQueryString without dependency on System.Web
View HttpUtility.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@bjorn-ali-goransson
bjorn-ali-goransson / AwsAuthenticator.cs
Created May 4, 2016
Authenticate to AWS with RestSharp (nicked from minio-dotnet / V4Authenticator with minor modifications)
View AwsAuthenticator.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
namespace Rest.Authentication
{
public class AwsAuthenticator : RestSharp.Authenticators.IAuthenticator
{
public string AccessKeyId { get; }
View jquery.hasattr.js
/* HAS ATTRIBUTE */
$.fn.hasAttr = function(attrName){
var element = this[0];
if(element.hasAttribute){
return element.hasAttribute(attrName);
@bjorn-ali-goransson
bjorn-ali-goransson / arabic-alphabet.htm
Created Nov 5, 2015
Generation of all arabic alphabet + harakah combinations in one A4
View arabic-alphabet.htm
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link href='https://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'>
<style>
body,
td,
th {
font-family: Arial;
@bjorn-ali-goransson
bjorn-ali-goransson / caret.less
Created Oct 24, 2015
CSS-only caret inheriting from text-color
View caret.less
.caret(@width: @caret-width-base) {
display: inline-block;
content: '';
width: 0;
height: 0;
margin-left: 10px;
vertical-align: middle;
border-top: @width dashed;
border-top: @width solid ~"\9"; // IE8
border-right: @width solid transparent;
@bjorn-ali-goransson
bjorn-ali-goransson / Remove.aspx
Created Sep 15, 2015
Remove EPiServer content programmatically
View Remove.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
You can’t perform that action at this time.