Skip to content

Instantly share code, notes, and snippets.

View Nihhaar's full-sized avatar
🎯
Focusing

Nihhaar_RC Nihhaar

🎯
Focusing
View GitHub Profile

Port-forwarding JMX

Proof of concept:

  • Terminal 1:
    • SSH to remote host
    • Start a Java process with JMX registry port 50004, RMI callback port 50005, and RMI hostname pinned to localhost: java -Dcom.sun.management.jmxremote.port=50004 -Dcom.sun.management.jmxremote.rmi.port=50005 -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -cp /some/jar/file main.class
  • Terminal 2:
@Nihhaar
Nihhaar / attributes.rb
Created April 22, 2019 10:47 — forked from lizthegrey/attributes.rb
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@Nihhaar
Nihhaar / min-char-rnn.py
Created March 31, 2019 19:04 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@Nihhaar
Nihhaar / memory_check.cpp
Created January 19, 2019 09:11 — forked from thirdwing/memory_check.cpp
C++ code to print out runtime memory usage
#include <iostream>
#include <fstream>
#include <unistd.h>
void process_mem_usage(double& vm_usage, double& resident_set)
{
vm_usage = 0.0;
resident_set = 0.0;
// the two fields we want

http://andrewgelman.com/wp-content/uploads/2012/11/frequentists_vs_bayesians.png

Question 1

There are three types of coins which have different probabilities of landing heads when tossed.

  • Type A coins are fair, with probability .5 of heads
  • Type B coins are bent and have probability .6 of heads
  • Type C coins are bent and have probability .9 of heads
@Nihhaar
Nihhaar / tornadosse.py
Created July 9, 2018 00:23 — forked from mivade/tornadosse.py
Tornado server-sent events
"""Demonstration of server-sent events with Tornado. To see the
stream, you can either point your browser to ``http://localhost:8080``
or use ``curl`` like so::
$ curl http://localhost:8080/events
"""
import signal
from tornado import web, gen
@Nihhaar
Nihhaar / ca.md
Created June 29, 2018 09:18 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@Nihhaar
Nihhaar / remove_punc.py
Created June 7, 2018 22:39 — forked from kissgyorgy/remove_punc.py
Python: Remove punctuation from string
#http://stackoverflow.com/questions/265960/best-way-to-strip-punctuation-from-a-string-in-python
import re, string
table = string.maketrans("","")
regex = re.compile('[%s]' % re.escape(string.punctuation))
def test_re(s): # From Vinko's solution, with fix.
return regex.sub('', s)
def test_trans(s):
@Nihhaar
Nihhaar / 10-Bit H.264
Created May 27, 2018 18:19
10-Bit H.264 explanation
10-Bit H.264
For all those who haven’t heard of it already, here’s a quick rundown about the
newest trend in making our encodes unplayable on even more systems: So-called
high-bit-depth H.264. So, why another format, and what makes this stuff
different from what you know already?
First off: What is bit depth?
In short, bit depth is the level of precision that’s available for storing color
information. The encodes you’re used to have a precision of 8 bits (256 levels)
@Nihhaar
Nihhaar / extract android kernel.md
Created May 10, 2018 12:03 — forked from azureru/extract android kernel.md
How to Extract Android Kernel And Modify The Boot Ramdisk (Android 4.4)

Extracting Existing Kernel + Ramfs

Enter the machine using adb shell

Run cat /proc/partitions

  #  Path                     Purpose        Size
  0 /dev/block/mmcblk0                       7761920
  1 /dev/block/mmcblk0p1      data           6085631