Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# dnspoxy setup for mac
sudo networksetup -setdnsservers Wi-Fi 127.0.0.1
sudo python dnsproxy.py -s 192.168.0.1
sudo networksetup -setdnsservers Wi-Fi "Empty"
#!/usr/bin/env python
# coding: utf-8
from SocketServer import BaseRequestHandler, ThreadingUDPServer
from cStringIO import StringIO
import os
import socket
import struct
import time
'''
#!/bin/bash
# define the variables
INSTANCE_NAME=iap-demo
ZONE=europe-west3-c
# add firewall rule
gcloud compute firewall-rules create allow-echo-ingress-from-iap \
--direction=INGRESS \
--action=allow \
#!/bin/bash
# define the variables
INSTANCE_NAME=iap-demo
ZONE=europe-west3-c
# connect to the vm
gcloud compute ssh $INSTANCE_NAME-vm --tunnel-through-iap --zone $ZONE
# download the source file
curl https://gist.githubusercontent.com/gabihodoroaga/a64ed25b69939b54a38a30d36affe2c9/raw \
#!/bin/bash
# enable IAP
gcloud services enable iap.googleapis.com
# define the variables
INSTANCE_NAME=iap-demo
ZONE=europe-west3-c
# create vm
#!/bin/bash
# setup variables
INSTANCE_NAME=iap-demo
ZONE=europe-west3-c
PROJECT_ID=$(gcloud config get-value project)
PROJECT_NUMBER=$(gcloud projects list --filter="$PROJECT_ID" --format="value(PROJECT_NUMBER)")
SERVICE_ACCOUNT="[email protected]"
# delete firewall rule
import socket
import sys
# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Connect the socket to the port where the server is listening
server_address = ('localhost', 5555)
print >>sys.stderr, 'connecting to %s port %s' % server_address
sock.connect(server_address)
# simple echo server
import socket
import sys
# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Bind the socket to the port
server_address = ('0.0.0.0', 5555)
print >>sys.stderr, 'starting up on %s port %s' % server_address
sock.bind(server_address)
#!/bin/bash
set -e
INSTANCE_NAME=ps-media
ZONE=europe-west3-c
PRESTASHOP_WEBSITE=http://www.example.com
MEDIA_SERVER_NAME=cdn.example.com
# download vm-stratup-script.sh
curl https://gist.githubusercontent.com/gabihodoroaga/43731b8ad9c63f3fe54913acff5e79c2/raw \
#!/bin/bash
set -e
# variable
INSTANCE_NAME=ps-media
ZONE=europe-west3-c
# delete the forwarding-rule aka frontend
gcloud -q compute forwarding-rules delete $INSTANCE_NAME-forwarding-rule --global