Skip to content

Instantly share code, notes, and snippets.

View kamronbatman's full-sized avatar

Kamron Batman kamronbatman

View GitHub Profile
@DrPaulBrewer
DrPaulBrewer / stringifyToStream.js
Last active April 13, 2016 20:10
node,js asyncronous JSON.stringify stringifyToStream ----- Intended for saving JSON of a large object out to a file without using up memory or choking out other activity on the node ----- Caveat: do not modify the object as it is being written out
// Copyright 2013 Paul Brewer
// License: You may copy this file under the same terms as the MIT License
// located at http://opensource.org/licenses/MIT
// This file is provided AS IS WITH NO WARRANTY OF ANY KIND. All use is at your own risk.
//
// Status: July 13, 2013, Paul Brewer: First version. Simple test case passed. It needs to be more extensively tested.
// It lacks escaping for odd characters in strings, though a workaround is possible as described in the comments.
//
// July 14, 2013, Paul Brewer: JSON.stringify() used to stringify basic
// types such as string, number, null/undefined. This provides string
@janikvonrotz
janikvonrotz / Archive-ADUserAndMailbox.ps1
Last active October 26, 2023 07:14
PowerShell: Archive ActiveDirectory and Mailbox #Exchange #ActiveDirectory #PowerShell #EmbededPost
<#
$Metadata = @{
Title = "Archive User ActiveDirectory and Mailbox"
Filename = "Archive-ADUserAndMailbox.ps1"
Description = ""
Tags = "powershell, activedirectory, archive, user, mailbox"
Project = ""
Author = "Janik von Rotz"
AuthorContact = "http://janikvonrotz.ch"
CreateDate = "2013-10-21"
@e1024kb
e1024kb / gist:41bf38fdb1a2cb19a781
Created September 27, 2014 13:29
Country - state list in JSON
{
"countries": [
{
"country": "Afghanistan",
"states": ["Badakhshan", "Badghis", "Baghlan", "Balkh", "Bamian", "Daykondi", "Farah", "Faryab", "Ghazni", "Ghowr", "Helmand", "Herat", "Jowzjan", "Kabul", "Kandahar", "Kapisa", "Khost", "Konar", "Kondoz", "Laghman", "Lowgar", "Nangarhar", "Nimruz", "Nurestan", "Oruzgan", "Paktia", "Paktika", "Panjshir", "Parvan", "Samangan", "Sar-e Pol", "Takhar", "Vardak", "Zabol"]
},
{
"country": "Albania",
"states": ["Berat", "Dibres", "Durres", "Elbasan", "Fier", "Gjirokastre", "Korce", "Kukes", "Lezhe", "Shkoder", "Tirane", "Vlore"]
},
import binascii, sys, random, asn1
from fractions import gcd
def extended_gcd(aa, bb):
lastremainder, remainder = abs(aa), abs(bb)
x, lastx, y, lasty = 0, 1, 1, 0
while remainder:
lastremainder, (quotient, remainder) = remainder, divmod(lastremainder, remainder)
x, lastx = lastx - quotient*x, x
y, lasty = lasty - quotient*y, y
@kamronbatman
kamronbatman / cryptFile.js
Last active January 29, 2019 07:31
Compresses and encrypts text files for exchanging credentials, private keys, and environment variables using Node.
#!/usr/bin/env node
const { promisify } = require('util');
/* eslint-disable import/no-extraneous-dependencies */
const glob = promisify(require('glob'));
/* eslint-enable */
const cryptFile = require('../util/cryptFile');
const handler = async (command, secret, ...filePathArgs) => {
@SciresM
SciresM / spelunky2_extract.py
Created September 30, 2020 11:44
Quick and dirty Spelunky 2 asset extraction. Assets are a weird chacha20 variant, there are at least two cryptographic errors due to typos....
import zstd
from struct import pack as pk, unpack as up
import subprocess as sp
# Quick and dirty Spelunky 2 asset extraction, author SciresM.
# Assets are protected by a weird chacha20 variant.
# The developers made an unfortunate set of typos that
# significantly weakens the asset crypto...
def rotate_left(a, b):