Skip to content

Instantly share code, notes, and snippets.

View jpic's full-sized avatar
💾
Searching for my Monkey Island II floppy disks

Yacht Shaver jpic

💾
Searching for my Monkey Island II floppy disks
View GitHub Profile
[foo]
hosta ansible_ssh_host=localhost kvm=kvma ansible_python_interpreter=/usr/bin/python2
hostb ansible_ssh_host=localhost kvm=kvmb ansible_python_interpreter=/usr/bin/python2
[kvm]
kvma ansible_ssh_host=localhost ansible_python_interpreter=/usr/bin/python2
kvmb ansible_ssh_host=localhost ansible_python_interpreter=/usr/bin/python2
@jpic
jpic / mitm_script.py
Created April 13, 2015 14:12
HTTP/HTTPS MITM Proxy to WSGI app
from libmproxy.flow import AppRegistry, version
from netlib import wsgi
import requests
def catchall(environ, start_response):
"""Simplest possible application object"""
data = 'Hello, World!\n'
status = '200 OK'
response_headers = [
@jpic
jpic / mitmproxy_cacheanything.py
Created April 21, 2015 10:17
Example generic HTTPS-capable caching proxy script for mitmproxy
import time
import sys
import os
import re
from static.apps import Cling
from libmproxy.flow import AppRegistry, version
from netlib import wsgi
import requests
#!/usr/bin/env python
import time
import sys
import os
import re
from static.apps import Cling
from libmproxy.flow import AppRegistry, version
from netlib import wsgi
import requests
import sys
@jpic
jpic / Vagrantfile
Created June 10, 2015 21:40
Example ruby loops in Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'fileutils'
Vagrant.require_version ">= 1.6.0"
Vagrant.configure(2) do |config|
(1..2).each do |i|
config.vm.define vm_name = "yl%d" % i do |config|
@jpic
jpic / groups.py
Last active August 29, 2015 14:23
SaltStack state TDD
#!py
# Named groups.py for github syntax coloration, but works as groups.sls
def update_groups(available, active):
for group, params in available.iteritems():
name = params.get('name', group)
f = 'absent' if group not in active else 'present'
args = {}
if f == 'present' and 'gid' in params:
@jpic
jpic / groups.sls
Created June 25, 2015 08:51
YAML+Jinja code readability
{%- if something %}
{%- for name, data in groups %}
{{ name }}:
{%- if data.get('absent', False) %}
group.absent:
{%- else %}
group.present:
{%- endif %}
{%- if 'gid' in data %}
- gid: {{ data.gid }}
@jpic
jpic / gist:a50ff3ffca25a1418c84
Created June 29, 2015 11:51
Demonstrate that git submodule tracks submodule per commit
[env] 29/06 2015 13:50:42 jpic@lue /tmp/test_git_submodule
$ git init root_repo
Initialized empty Git repository in /tmp/test_git_submodule/root_repo/.git/
[env] 29/06 2015 13:50:46 jpic@lue /tmp/test_git_submodule
$ git init sub_repo
Initialized empty Git repository in /tmp/test_git_submodule/sub_repo/.git/
[env] 29/06 2015 13:50:51 jpic@lue /tmp/test_git_submodule
$ cd sub_repo/
#!/usr/bin/env python
'''
export JENKINS_BUILD_COMMAND="java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080 build"
export GITHUB_USERNAME=youruser
export CRAZY_JENKINS=owner/repo:job1*3,job2*1
# Note the space here, for the token not to be stored in bash history
GITHUB_TOKEN=yourtoken crazy_jenkins.py
'''
import os
<?php
$fixture = new ArrayObject( array(
'a',
'b',
'c',
) );
unset( $fixture[1] );