Skip to content

Instantly share code, notes, and snippets.

View fishi0x01's full-sized avatar
💾
0x01

Karl Fischer fishi0x01

💾
0x01
View GitHub Profile
@fishi0x01
fishi0x01 / baseURL.groovy
Last active June 15, 2023 19:55
This is a collection of groovy scripts I gathered and use for bootstrapping Jenkins. Most of this can also be achieved with the CasC Plugin https://github.com/jenkinsci/configuration-as-code-plugin
#!groovy
/*
* This script configures the Jenkins base URL.
*/
import jenkins.model.JenkinsLocationConfiguration
JenkinsLocationConfiguration location = Jenkins.instance.getExtensionList('jenkins.model.JenkinsLocationConfiguration')[0]
location.url = 'https://jenkins-as-code-poc.devtail.io/'
@fishi0x01
fishi0x01 / terraform-0.7.11-experimental-feature-bug
Last active November 22, 2016 13:46
Terraform 0.7.11 Experimental Feature Error on aws_instance resource
While running, Terraform sometimes tests experimental features in the
background. These features cannot affect real state and never touch
real infrastructure. If the features work properly, you see nothing.
If the features fail, this message appears.
The following failures happened while running experimental features.
Please report a Terraform bug so that future Terraform versions that
enable these features can be improved!
You can report an issue at: https://github.com/hashicorp/terraform/issues
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"]
@fishi0x01
fishi0x01 / dcom-access-x64.ps1
Last active March 4, 2021 07:38
Script to configure DCOM remote access on Windows machines. Code for blog post https://fishi.devtail.io/weblog/2015/01/16/enabling-dcom-windows-7-8-and-server-2012/
# Original script taken and modified from http://shrekpoint.blogspot.de/2012/08/taking-ownership-of-dcom-registry.html
#
# Enable remote DCOM access to the WbemScripting.SWbemLocator class on 64-bit Windows 7/8 and Server 2012 machines,
# by setting the necessary keys inside the registry.
# Use this script at your own risk.
# I do not guarantee that it works, nor do I give any kinds of support in case it doesn't
Try {
[void][TokenAdjuster]
} Catch {
@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:
#!/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 / 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 / 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 / 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 / header.sh
Last active November 11, 2021 15:02
Dynamic login messages with update-motd framework. Code for blog post https://fishi.devtail.io/weblog/2015/02/06/dyamic-login-messages-update-motd/
# Simple static header for update-motd framework
COLOR_GREEN="\033[0;32m"
# print personal static banner in green
printf "${COLOR_GREEN}
_____ .__ .__ .__
_/ ____\|__| ______| |__ |__|
\ __\ | | / ___/| | \ | |
| | | | \___ \ | Y \| |