Skip to content

Instantly share code, notes, and snippets.

@mmartinez
mmartinez / removeGhost.ps1
Created August 8, 2020 06:57
removeGhost.ps1
<#
.SYNOPSIS
Removes ghost devices from your system
.DESCRIPTION
This script will remove ghost devices from your system. These are devices that are present but have an "InstallState" as false. These devices are typically shown as 'faded'
in Device Manager, when you select "Show hidden and devices" from the view menu. This script has been tested on Windows 2008 R2 SP2 with PowerShell 3.0, 5.1, Server 2012R2
with Powershell 4.0 and Windows 10 Pro with Powershell 5.1. There is no warranty with this script. Please use cautiously as removing devices is a destructive process without
an undo.
@mmartinez
mmartinez / check-author-mixin.py
Created March 28, 2016 22:23
This mixin checks if the object being updated belongs to the current user.
# -*- coding: utf-8 -*-
from django.http.response import HttpResponseForbidden
class AuthorRequiredMixin(object):
def dispatch(self, request, *args, **kwargs):
obj = self.get_object()
if obj.user != self.request.user:
return HttpResponseForbidden()