Skip to content

Instantly share code, notes, and snippets.

@scovetta
scovetta / django-admin-autoregister.py
Created August 3, 2012 17:56
Django Automatic Model Registration for Django Admin
"""
This gist allows you to automatically register all models in a given app
for use in the Django Admin application.
Change (your-app-name) to your application name.
"""
import inspect
from django.contrib.admin.sites import AlreadyRegistered
from (your-app-name) import models
@scovetta
scovetta / Nginx-Optimized
Last active September 1, 2021 07:30
Optimized Nginx configuration, from http://dak1n1.com/blog/12-nginx-performance-tuning
# This number should be, at maximum, the number of CPU cores on your system.
# (since nginx doesn't benefit from more than one worker per CPU.)
worker_processes 24;
# Number of file descriptors used for Nginx. This is set in the OS with 'ulimit -n 200000'
# or using /etc/security/limits.conf
worker_rlimit_nofile 200000;
# only log critical errors
error_log /var/log/nginx/error.log crit
Ingredients :
1/2 stick of butter
6-8 cloves of garlic sliced thinly
1 1/2 bottle of Franks
1/2 to 3/4 bag (5;b) of frozen or fresh wing parts
Procedure :
Add 3/4 of Franks, 1/4 stick of butter and garlic in skillet and simmer on low for 10 minutes.
Add wings and flip them to coat thoroughly. Cover and simmer on low for appx. 20 minutes (for frozen).
After 10 minutes, preheat your girll on high.
After 20 minutes, transfer wings from skillet into big bowl and bring to grill.
@scovetta
scovetta / urlencoder
Created September 16, 2014 06:03
Caching URL encoder for Perl
#!/usr/bin/perl -w
use strict;
use warnings;
use feature (qw/state/);
sub encode {
state %hashMap;
if (not %hashMap) {
%hashMap = ();
test()

foo bar baz

@scovetta
scovetta / NuGetList.cs
Created October 31, 2016 04:31
NuGet.Core Parsing Bug
using System;
using System.Linq;
using NuGet;
namespace NuGetListNamespace
{
class NuGetList
{
static void Main(string[] args)
{
@scovetta
scovetta / applicationHost.config
Created September 18, 2017 22:31
Enable TLS Protocol Logging in IIS
<!--
Source:
https://blogs.microsoft.com/microsoftsecure/2017/09/07/new-iis-functionality-to-help-identify-weak-tls-usage/
-->
<site name="Default Web Site" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot" />
</application>
<bindings>
@scovetta
scovetta / create-sed-script
Last active September 28, 2019 17:10
Replacing HTTP with HTTPS links in a large repository
#!/bin/bash
# Takes a list of URLs (output from ishttps) and turns them into a massive sed replacement script.
FILENAME="$1"
echo "sed -i '"
while read -r url; do
ESC_IN=$(echo "$url" | sed -e 's/[]\/$*.^[]/\\&/g')
ESC_OUT=$(echo "$ESC_IN" | sed -e 's/http:/https:/')
#!/usr/bin/python
# License: MIT
# Author: Michael Scovetta <michael.scovetta@gmail.com>
import re
import sys
"""
Usage:
# Download JSON files for CVEs from https://nvd.nist.gov/vuln/data-feeds
# Extract JSON
# Fire up WSL or a Linux terminal. Make sure you have jq installed.
# Run this, send to a CSV file and then open/sort/whatever in Excel.
cat nvdcve-1.1-2021.json | jq '.CVE_Items[].cve | .CVE_data_meta.ID + ", " + .problemtype.problemtype_data[].description[].value' | cut -d\" -f2