Skip to content

Instantly share code, notes, and snippets.

View SecSamDev's full-sized avatar

Samuel Garcés Marín SecSamDev

View GitHub Profile
@yunga
yunga / Powershell Rosetta Stone.md
Last active July 17, 2025 00:52
Dos/Unix/Powershell Commands

Powershell Rosetta Stone

[CMD] [Unix] [Powershell] Synopsis
HELP [man] [Get-Help] Displays information about commands and concepts.
[apropos] [Get-Command] Gets all commands.
[Show-Command] Displays PowerShell commands in a graphical window.
@SecSamDev
SecSamDev / Quaternion.js
Created July 31, 2019 17:54
Compress quaternions for network transmission
//2^15 => 15 bits
const HALF_STEP = 16384n
const STEP = 32768
const QUATERNION_LIMITS = 2 / (STEP)
/**
* The purpose of this small library is the compression of quaternions
* for transmit them over the network, where the bandwidth is limited.
*/
class Quaternion {
@SecSamDev
SecSamDev / benchmark-hash.js
Last active September 21, 2023 15:15
Performance of native crypto hash algorithms
const crypto = require('crypto')
const myBuff = Buffer.allocUnsafe(1200);
const alg = crypto.getHashes()
for(let i = 0; i < alg.length; i++){
const initTime = new Date().getTime()
for (let j = 0; j < 100000; j++) {
let digBuff = crypto.createHash(alg[i]).update(myBuff).digest()
}
const endTime = new Date().getTime()
console.log(`${alg[i]} - ${100000/((endTime - initTime) / 1000)} hash/s`)
@SecSamDev
SecSamDev / Results.txt
Created July 16, 2019 19:27
Measuring of Nodejs Buffer allocation and copy bytes (performance, benchmark)
Allocating 1000 buffers of 30000 bytes => avg 9.7mils max 33mils min 3mils
Copy 3 buffers of 10000 bytes in 1000 buffers of 30000 bytes: 13.166666666666666 mils max 23mils min 8mils
@krzys-h
krzys-h / UnityWebRequestAwaiter.cs
Created July 20, 2018 22:47
[Unity] Use UnityWebRequest with async/await
public class UnityWebRequestAwaiter : INotifyCompletion
{
private UnityWebRequestAsyncOperation asyncOp;
private Action continuation;
public UnityWebRequestAwaiter(UnityWebRequestAsyncOperation asyncOp)
{
this.asyncOp = asyncOp;
asyncOp.completed += OnRequestCompleted;
}
@ethack
ethack / TypeClipboard.md
Last active June 24, 2025 19:05
Scripts that simulate typing the clipboard contents. Useful when pasting is not allowed.

It "types" the contents of the clipboard.

Why can't you just paste the contents you ask? Sometimes pasting just doesn't work.

  • One example is in system password fields on OSX.
  • Sometimes you're working in a VM and the clipboard isn't shared.
  • Other times you're working via Remote Desktop and again, the clipboard doesn't work in password boxes such as the system login prompts.
  • Connected via RDP and clipboard sharing is disabled and so is mounting of local drives. If the system doesn't have internet access there's no easy way to get things like payloads or Powershell scripts onto it... until now.

Windows

The Windows version is written in AutoHotKey and easily compiles to an executable. It's a single line script that maps Ctrl-Shift-V to type the clipboard.

@justmoon
justmoon / custom-error.js
Last active November 19, 2024 02:40 — forked from subfuzion/error.md
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);