Skip to content

Instantly share code, notes, and snippets.

@snoj
snoj / gist:298188f165575bd1b926
Created December 24, 2014 10:27
Clear wuauserv SoftwareDistribution folder
Get-Service -DisplayName "Windows Update" | Stop-Service -Force;
rm -force -recurse C:\Windows\SoftwareDistribution -ea silentlycontinue;
Get-Service -DisplayName "Windows Update" | Start-Service;
@snoj
snoj / gist:3231686
Created August 1, 2012 23:59
Charter 6rd Script
#!/bin/bash
##original https://gist.github.com/1016433
#Had issues with this and many scripts as they all assumed that my primary router had ipv6 support and that I wasn't hiding behind something.
#This script sets your Linux (I use Ubuntu) box to function as a 6RD routing device.
#I've left out radvd as I use HE TunnelBroker for my network's addressing.
#Get Charter's 6rd host
HOST6RD=$(nslookup 6rd.charter.com | grep "Address"| awk '{ print $2 }'| tail --lines=1);
@snoj
snoj / gist:ad3da430727c185f8ffb
Created January 20, 2016 16:15
get total hyperv cluster virtual machine vhd size
( get-clusternode | %{ get-vm -ComputerName $_.name } | %{ get-vhd -VMId $_.id -ComputerName $_.computername; } | measure -Sum size).sum / 1TB
@snoj
snoj / cleanboot
Created July 15, 2016 02:12 — forked from anonymous/cleanboot
Cleans the /boot folder of all images that is not what is running.
#!/bin/bash
aptitude search linux-image* -F "%c %p" | grep -E "^i.*" | grep -v -E "\slinux-image-generic\s" | grep -v -E `(uname -r | awk '{split($0, a, "-[a-z]"); print a[1];'})` | awk '{ print $2; }' | xargs aptitude remove -y;
update-grub;
@snoj
snoj / gist:0715f0ee6ff2756cd0fdb06750e3af4d
Last active July 24, 2016 03:24
Rough sketch to save entire contents facebook group/page/community for non-admins
//open dev console of browser
//paste jquery.min.js contents
//https://github.com/jquery/jquery/releases
//load entire page
var scroller = setInterval(function() { window.scrollTo(0,document.body.scrollHeight); }, 1000);
//stop scroller
clearInterval(scroller);
@snoj
snoj / cer2pfx.php
Last active September 2, 2016 15:49
cer/key to pfx
<?php
//package up pem encoded certificate and key into a pfx (PKCS #12) file with your handy-dandy already installed php.exe.
$outpfx = "./out.pfx";
$cert = openssl_x509_read(file_get_contents("./domain.cer"));
$privatekey = file_get_contents("./domain.key");
$passphase = "somepass";
openssl_pkcs12_export_to_file($cert, $outpfx, $privatekey, $passphrase);
@snoj
snoj / encoding-helpers.ps1
Created September 30, 2016 16:35 — forked from jpoehls/encoding-helpers.ps1
Convert-FileEncoding and Get-FileEncoding
<#
.SYNOPSIS
Converts files to the given encoding.
Matches the include pattern recursively under the given path.
.EXAMPLE
Convert-FileEncoding -Include *.js -Path scripts -Encoding UTF8
#>
function Convert-FileEncoding([string]$Include, [string]$Path, [string]$Encoding='UTF8') {
$count = 0
var a = document.getElementsByClassName("_3m9g");
for( var i = a.length-1; i >= 0; i--) { try { console.log(i); a[i].parentElement.removeChild(a[i]); } catch (ex) {} }
a = document.getElementsByClassName("UFIAddComment");
for( var i = a.length-1; i >= 0; i--) { try { console.log(i); a[i].parentElement.removeChild(a[i]); } catch (ex) {} }
@snoj
snoj / download.ps1
Created March 24, 2017 14:00
download all natgeo's topology maps
$root = "http://pdf.quad.download.s3.amazonaws.com/";
$mroot = $root;
if($pdfs -eq $null -or $pdfs.count -eq 0) {
$pdfs = @{};
while(1) {
$mroot;
$res = [xml](iwr $mroot | select -ExpandProperty content);
$res.ListBucketResult.Contents | ?{ [regex]::IsMatch($_.key, "\.pdf`$", "IgnoreCase") } | %{
try {
@snoj
snoj / index.js
Last active March 30, 2017 05:28
hamstrings
function FromRight(str1, str2) {
var longest, tmpshortest, shortest;
if(str1.length != str2.length) {
if(str1.length > str2.length) {
longest = str1;
tmpshortest = str2;
} else {
longest = str2;
tmpshortest = str1;
}