Skip to content

Instantly share code, notes, and snippets.

View nauzilus's full-sized avatar
💭
🤠

Daniel Flint nauzilus

💭
🤠
View GitHub Profile
@nauzilus
nauzilus / AnonymousPermMask64Test.ps1
Last active August 29, 2015 14:00
Inconvenient AnonymousPermMask64
$web = get-spweb $url
$list = $web.Lists["Documents"]
# get ready for some sneaky backdoor business
$flags=[Reflection.BindingFlags] "NonPublic,Instance"
$arr =[Microsoft.SharePoint.SPList].GetField("m_arrListProps", $flags).GetValue($list)
$i =[Microsoft.SharePoint.SPList].GetField("m_iRow", $flags).GetValue($list)
# make sure we're going to set some new value
$newMask = $null
@nauzilus
nauzilus / plugin.js
Last active August 29, 2015 14:05
setLimitedTimeout
(function() {
if (typeof window.setLimitedTimeout === 'undefined' && typeof window.clearLimitedTimeout === 'undefined') {
var timers={},_id=0;
window.setLimitedTimeout = function(test, reps, interval, cb) {
var attempt = 0;
var intFunc = typeof interval === 'function'
? interval
: function(attempt) { return interval; };
var id = _id++;
timers[id] = setTimeout(function doit() {
using System;
using System.ComponentModel;
public static class Conversion {
public static T TryAs<T>(this string x, T otherwise = default(T))
{
var converter = TypeDescriptor.GetConverter(typeof(T));
if (converter != null && x != null && converter.CanConvertFrom(x.GetType()))
{
try { return (T)converter.ConvertFrom(x); }
@nauzilus
nauzilus / wp_webhost_ranking.js
Last active August 29, 2015 14:13
Naive web host ranking from whirlpool thread
// https://forums.whirlpool.net.au/forum-replies.cfm?t=65599&p=-2
var results={}; [].slice.call(document.querySelectorAll('.replytext.bodytext p')).forEach(function(v) {
var text = [].slice.call(v.childNodes).map(function(c) {
return (
c.textContent.length === 0 || (
c.classList &&
c.classList.contains("wcrep1")
)) ? "\n" : c.textContent;
}).join("");
var host = (text.match(/Name\s*:\s*(\w[\w ]+)/)|| [,''])[1]
@nauzilus
nauzilus / prism-migrate.js
Created April 25, 2015 00:12
Migrate SyntaxHighlighter to Prism
(function() {
var map = {
'html': 'markup',
'xml': 'markup'
};
var lang = /\bbrush:\s*(\w+)\b;?/i;
var convert = function(element) {
var language = (element.className.match(lang) || [,''])[1];
language = map[language] || language;
if ( language && self.Prism.languages[language] ) {
@nauzilus
nauzilus / bookmarklet.js
Last active August 29, 2015 14:21
Destyle
(function(){
var $=function(selector){
return [].slice.call(document.querySelectorAll(selector));
};
$("style,link[rel='stylesheet'],img,video,object").forEach(function(v) {
v.remove();
})
$("[style]").forEach(function(v) {
v.removeAttribute("style")
});
@nauzilus
nauzilus / keyboardnav.js
Created May 27, 2015 23:02
Simple Keyboard Navigation
(function(selector) {
// not handling DOM changes. yet.
var posts = document.querySelectorAll(selector);
var topTollerance = 10;
var multiplier = 0;
function post_nav(e) {
if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return;
var dir = 0;
var key = (""+(e.keyCode || e.code || e.key || "")).toLowerCase();
@nauzilus
nauzilus / bookmarklet.js
Last active August 29, 2015 14:22
Toggle Tables
javascript:(function(){
var id = "df-showtables";
var style=document.getElementById(id);
if (style) {
style.remove();
}
else {
style = document.createElement("style");
style.id=id;
style.textContent = "table { border: 2px solid #BD1DEA; table-collapse: collapse; } td { border: 1px solid #BADA55; }";
@nauzilus
nauzilus / script.js
Last active July 4, 2016 11:20
Generator
var gen = function(str) {
var g_datetime = function(flags) {
var date = new Date();
if (flags["<"] ^ flags[">"]) {
var dayTicks = 86400000,
midnight=new Date(date.getTime() - ( ( date.getTime() - ( date.getTimezoneOffset() * 60000 ) ) % dayTicks )),
mins=~~(date.getTime() - midnight.getTime()),
tOffset=g_number.apply(null, flags.t ? flags["<"] ? [0,mins] : [mins,dayTicks] : [0,dayTicks]),
dOffset=g_number(1,365)*dayTicks*(flags["<"]?-1:1);
date = new Date(midnight.getTime() + (flags.t && !flags.d ? 0 : dOffset) + tOffset);
@nauzilus
nauzilus / bookmarklet-min.js
Last active September 10, 2015 01:35
Prism Custom Themes
javascript:(function(t){t("https://api.github.com/gists/a216f6a5e5e74eec0fde","script.js","customthemes")}(function(t){return function(n,e,c){if(!t.getElementById(c)){var i=function(n){var e=t.createElement("script");n&&n(e),t.head.appendChild(e)},o=c+Math.floor(Date.now()/864e5);window[o]=function(t){i(function(n){n.id=c,n.innerHTML=t.data.files[e].content})},i(function(t){t.src=n+"?callback="+o})}}}(document)));