Skip to content

Instantly share code, notes, and snippets.

@AyrA
AyrA / square.js
Created October 18, 2017 14:52
You no longer need an npm module to calculate squares of numbers
//Calculates x² of an integer up to ±1 million
var square = (function () {
var s = "if(A==B){return C;}";
var func = "var A=Math.abs(D|0);";
for (var i = 0; i <= 1000000; i++) {
func += s.replace(/B/, i).replace(/C/, i * i);
}
return new Function("D", func + "return Infinity;");
})();
@AyrA
AyrA / manual_windows_update.md
Created October 30, 2017 02:58
How to get manual Updates back in Windows 8 and later

Create the two files below. Keep whitespace as is. You can now use the Task scheduler (taskschd.msc) to create an update schedule that fits your computer usage. Microsoft usually publishes updates on the second tuesday of every month unless they are extremely critical. The files need to be run with administrative privileges.

stop_update.bat

net stop wuauserv
sc config wuauserv start= disabled
@AyrA
AyrA / SEARCH_README.md
Last active October 30, 2017 03:33
Fast Windows search

Put the 3 batch files somewhere on your Desktop.

cache.bat

Use this to create/renew the cache. Depending on the number of files on your drives and the number of drives this might run for a few minutes.

If you prefer it would not index certain drives, remove the letters from the list.

search.bat

@AyrA
AyrA / guid.php
Last active November 1, 2017 20:09
PHP UUID Generator
<?php
//Generates cryptographically safe UUIDv4 (sometimes called GUID)
function guid()
{
$data=random_bytes(16);
assert(strlen($data)===16);
$data[6]=chr(ord($data[6])&0x0f|0x40); //set version to 0100
$data[8]=chr(ord($data[8])&0x3f|0x80); //set bits 6-7 to 10
@AyrA
AyrA / BypassCmdGpo.bas
Created November 2, 2017 03:33
Bypass GPO Restriction on CMD.exe with Excel
Option Explicit
'Copyright 2017 /u/AyrA_ch
'Open Excel, Press ALT+F11, add new "module" (not Class module) and paste this entire code in it.
'To use you can either place a button on your excel sheet and hook up these functions to it
'Or you place the cursor inside the Button function you want to use and press F5
'After one successful launch you find the executable on your Desktop.
'You then no longer need this file.
@AyrA
AyrA / where.bat
Created November 2, 2017 22:02
where command on Windows
@ECHO OFF
REM Store this anywhere in your PATH.
SETLOCAL
SET FULL=%~$PATH:1
IF "%FULL%"=="" GOTO NF
GOTO PRINT
:PRINT
ECHO %FULL%
GOTO END
@AyrA
AyrA / search.js
Created February 18, 2018 16:35
Find and count multiple words on a website
(function (x) {
var text = document.body.textContent;
return x.map(function (v) {
var m = text.match(new RegExp("\\s(" + v + ")[\\s.,!?]", "gi"));
return m ? m.length : 0;
});
})(["add", "all", "your", "words", "here"]);
@AyrA
AyrA / KDF.cs
Created February 20, 2018 07:45
C# Custom Key derivation
using System;
using System.Linq;
using System.Security.Cryptography;
/*
I am in no way claiming that this is secure.
It merely serves as an example on how a key derivation function could work.
Features:
@AyrA
AyrA / bfjsf.js
Last active October 24, 2020 15:07
Brainfuck interpreter in JSFuck
//Brainfuck Interpreter in JSFuck by /u/AyrA_ch
(typeof(window)==="undefined"?global:window).bf=
//Put your code in the line below
'-[----->+<]>----.-[--->++<]>+.-[++>---<]>+.---[-->+++<]>-.----[->++<]>-.-------.+[->+++++<]>++.-[-->+++<]>-.++++.+++++.';
/*
Text input is done using 'prompt' function
Text output is shown at the end of the script, because console.log adds linebreaks
The interpreter has 1000000 bytes of memory
@AyrA
AyrA / http.ps1
Last active April 13, 2024 14:21
Powershell HTTP Server
# Portable HTTP file server
# Should be somewhat safe but please don't actually use it.
# You can't exit this with CTRL+C directly and need to use the shutdown command below a directory listing,
# or you can kill the powershell process of course, but this causes the port to stay used sometimes.
# Features
# - Directory Browser
# - Can handle UTF8 URLs
# - Delivers unknown file types
# - /../ attack prevention