Skip to content

Instantly share code, notes, and snippets.

View fishi0x01's full-sized avatar
💾
0x01

Karl Fischer fishi0x01

💾
0x01
View GitHub Profile
FROM tomcat:8.0.38
# Place the code version inside the webapps directory
ARG PACKAGE_VERSION
RUN echo "${PACKAGE_VERSION}" >> /usr/local/tomcat/webapps/version.txt
COPY project.war /usr/local/tomcat/webapps/project.war
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
/*
* A simple client that opens a socket.
*/
#include <stdio.h>
#include <sys/socket.h>
int main(int argc, char *argv[])
{
int sockfd;
@fishi0x01
fishi0x01 / example.html
Last active March 21, 2020 15:23
Functional headless UI testing in Django with Selenium. Code for blog post https://fishi.devtail.io/weblog/2015/03/02/functional-headless-ui-testing-django-selenium/
<!-- Simple webpage for Django UI example test -->
<html>
<head>
</head>
<body>
<p id="test">Hello World!</p>
</body>
</html>
@fishi0x01
fishi0x01 / ConnectWMINamespace.java
Last active March 21, 2020 15:22
Basic j-interop DCOM bridge setup snippets. Code for blog post https://fishi.devtail.io/weblog/2015/01/21/pure-java-dcom-bridge-j-interop/
/**
* Code snippet that tries to create a connection with the given wmiLocator object to the given namespace.
* @return An IJIDispatch object that can be used for WQL queries to the given namesapce of the target machine.
* @Exception In case the ConnectServer method could not be properly executed.
*/
public IJIDispatch createNamespaceServer(IJIDispatch wmiLocator, String nameSpace, String ipAddress) throws Exception
{
// create an instance of the WbemScripting.SWbemLocator object to talk to WMI on the target machine.
// namespace could be for instance "root\\cimv2"
JIVariant results[] =
@fishi0x01
fishi0x01 / deploy.sh
Last active March 21, 2020 15:21
Setting up a Django CI with Jenkins. Code for blog post https://fishi.devtail.io/weblog/2015/02/22/setting-django-ci-jenkins-and-git/
#!/bin/bash
# A simple django project deployment script for jenkins
BUILD_ROOT="/srv/www/django/d_project/"
MNGR=${BUILD_ROOT}"manage.py"
# source python env
echo "Sourcing python env..."
source ${BUILD_ROOT}"py-env/bin/activate"
@fishi0x01
fishi0x01 / fermat_binom.py
Last active March 21, 2020 15:19
Calculating large binomial coefficients modulo prime / non-prime numbers (nCk mod m). Code for blog post https://fishi.devtail.io/weblog/2015/06/25/computing-large-binomial-coefficients-modulo-prime-non-prime/
#!/usr/bin/env python3
"""
Using Fermat's little theorem to calculate nCk mod m, for k < m and m is prime
Two versions:
1. Pre-Compute factorials and multiplicative inverses in O(n*logn) --> later lookup in O(1)
2. Compute directly --> no lookup --> each time O(n)
"""
@fishi0x01
fishi0x01 / power_set.py
Last active March 21, 2020 15:19
Bitwise Techniques for Subset Iterations in Python. Code for blog post https://fishi.devtail.io/weblog/2015/05/18/common-bitwise-techniques-subset-iterations/
#!/usr/bin/env python3
"""
Iterate over each subset of any size (Power set)
"""
def power_set(A):
subsets = []
N = len(A)
# iterate over each subset
#!/usr/bin/env python3
"""
A simple python(3) bf interpreter.
First argument is .bf file with code to execute.
Optionally a file with input arguments can be specified as second argument.
"""
import sys
import re
#!/bin/bash
SENSITIVE_FILES="roles/ssh/templates/sshd_config.j2.enc"
if [ "$1" != "clean" ] && [ "$1" != "decrypt" ]
then
echo "only 'clean' or 'decrypt' are allowed"
exit 1
fi
@fishi0x01
fishi0x01 / defaults-main.yml
Last active March 21, 2020 15:17
Snippets for ansible role structuring. Code for blog post https://fishi.devtail.io/weblog/2016/06/02/ansible-role-structuring/
sshd_port: 5133
sshd_groups:
- name: devops
ssh:
allow_tcp_fwd: True
allow_agent_fwd: True
x11_fwd: True
- name: developers
ssh: