Skip to content

Instantly share code, notes, and snippets.

View manuel-delverme's full-sized avatar
😀

Manuel manuel-delverme

😀
View GitHub Profile
@manuel-delverme
manuel-delverme / jax_utils.py
Created November 23, 2021 20:18
jax_plot_graph
# @title Helper functions (execute this cell)
import functools
import traceback
import jax
_indentation = 0
def _trace(msg=None):
import jax.config
import jax.numpy
import jax.ops
jax.config.update("jax_debug_nans", True)
with jax.disable_jit():
x0 = jax.numpy.zeros(1)
jax.value_and_grad(lambda x: jax.scipy.special.logsumexp(x))(x0)
def closure():
output = model(data)
loss = F.nll_loss(output, target)
layer_norm = torch.mean(torch.tensor([p.norm() for p in model.parameters()]))
ineq_defect = [
(layer_norm - 0.025).reshape(1, -1),
]
return loss, None, ineq_defect
import torch
import torch.autograd
import torch.functional
import torch.nn
import torch.nn.functional as F # noqa
import torch.optim
import torch.utils.data
import tqdm
import config
from scapy.all import rdpcap, DNSQR, DNSRR
f = ""
last = ""
for p in rdpcap('doNotSnoop.pcapng'):
if p.haslayer(DNSQR) and not p.haslayer(DNSRR):
qry = p[DNSQR].qname.replace(".jz-n-bs.local.", "").strip().split(".")
qry2 = []
for q in qry:
�[��!command (corgi-ThinkPad-T460)� �[ꅡV��c�sh (corgi-ThinkPad-T460)� �[ꅯ�����V�V��c�sh (corgi-ThinkPad-T460)�V��c�� �[ꅯ�����V�V��c�� �[�V��c�� �[�V��c�� �[�V��c�� �[�V��c�� �[�V��c�� �[�V��c�� �[�V��c�� �[�V��c�� �[�V��c�� �[�V��c�� �[�V��c�� �[�V��c�� �[�V��c��/home/corgi/Documents/0x0g-2021/pcap/dnscat2/client
V����� �[�V����� �[�V����� �[�V�����V����� �[�V�����V�����controller
dnscat
dnscat.c
dnscat.o
drivers
libs
Makefile
Makefile.win
tcpcat.c
@manuel-delverme
manuel-delverme / jaxpr_graph.py
Last active August 4, 2021 13:52 — forked from niklasschmitz/jaxpr_graph.py
visualizing jaxprs
import jax
from jax import core
from graphviz import Digraph
import itertools
styles = {
'const': dict(style='filled', color='goldenrod1'),
'invar': dict(color='mediumspringgreen', style='filled'),
'outvar': dict(style='filled,dashed', fillcolor='indianred1', color='black'),
def hlo_graph(f, *args, **kwargs):
comp = jax.xla_computation(f)(*args, **kwargs)
graph = graphviz.Source(comp.as_hlo_dot_graph())
return graph
styles = {
'const': dict(style='filled', color='goldenrod1'),
'invar': dict(color='mediumspringgreen', style='filled'),
'outvar': dict(style='filled,dashed', fillcolor='indianred1', color='black'),
@manuel-delverme
manuel-delverme / clean_code.md
Last active December 11, 2020 14:39 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


House rules

  1. Convfig variables should become parameters at the highest level of abstraction possible, config.device should be replaced by type inference.

General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
[1, 3, 2] achieved fit 26.0
[0, 4, 0] achieved fit 6.0
[-0.39568418 1.01307049 -1.04464656]
==RESULTS==
[0, 4, 0] achieved fit 0.0
[0, 4, 0] achieved fit 0.0
[-0.48153435 1.04255481 -1.08245629]
==RESULTS==