Skip to content

Instantly share code, notes, and snippets.

@ukoloff
ukoloff / cmdize.bat
Last active October 31, 2023 14:04
Wrap (almost) any language into batch file
:: USAGE
:: cmdize name [...]
::
:: This tool converts a supported code into a batch file that can be
:: executed without explicit invoking the executable engine. The script
:: creates new file and places it under the same directory as the original
:: one with the same name, replacing the original extension with ".bat".
:: The content of the new file consists of the original file and the
:: special header that being the "polyglot" and having some tricks to be a
:: valid code in batch file and the wrapped code at the same time.
@ukoloff
ukoloff / scoop.ps1
Last active September 20, 2023 14:17
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
iwr -useb get.scoop.sh
scoop install git
scoop bucket add extras
scoop bucket add versions
@ukoloff
ukoloff / admin.js
Last active June 25, 2023 20:07
WMI samples using JScript
// Check Admin rights
var out = GetObject("winmgmts://./root/default:StdRegProv") .EnumKey(1 << 31 | 3, "S-1-5-20")
WScript.Echo("Admin =", !out)
@ukoloff
ukoloff / cpt.cmd
Last active October 18, 2022 04:07
Stop auth for Cisco Packet Tracer
netsh advfirewall firewall add rule name="Cisco Packet Tracer" dir=out program="C:\Program Files\Cisco Packet Tracer 8.0\bin\PacketTracer.exe" action=block
@ukoloff
ukoloff / vboxips.js
Created September 26, 2014 09:00
Enumerate VirtualBox IPs
var
vbox = "C:/Program Files/Oracle/VirtualBox/VBoxManage.exe"
var
sh = new ActiveXObject('WScript.Shell'),
fso = new ActiveXObject("Scripting.FileSystemObject")
var
ms=[],
f = sh.Exec(vbox+' list runningvms').StdOut
@ukoloff
ukoloff / Z.js
Last active April 12, 2019 06:16
Z-combinator
//
// Z-combinator
// https://habr.com/ru/post/322052/
//
const Z = f => (f => f(f))(z => f(x => z(z)(x)))
@ukoloff
ukoloff / kth.cpp
Last active April 12, 2019 06:16
Various algorithms
// Order Statistic
// https://stepik.org/lesson/12564/step/8?unit=2992
#include <utility>
#include <vector>
template <typename T>
T kth(std::vector<T>& v, size_t k) {
size_t L = 0, R = v.size();
while (L + k < R) {
@ukoloff
ukoloff / async-generator.js
Last active April 7, 2019 17:09
Hand made JS generators
function range(from, to) {
return { next: nextPromise, [Symbol.asyncIterator]: iterator }
function next() {
return from <= to
? { done: false, value: from++ }
: { done: true }
}
function iterator() {
@ukoloff
ukoloff / fib.cpp
Last active December 18, 2018 14:07
C++ snippets for Algorithms/C++ course
// Числа Фибоначчи
#include <ctime>
#include <iostream>
#include <vector>
int fib(int n);
int fibM(int n);
int fibM(int n, std::vector<int>&);
int fibSM(int n);
int fibF(int n);