Skip to content

Instantly share code, notes, and snippets.

@feczo
feczo / zshrc
Created May 19, 2013 04:40
oh my ZSH rc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
#ZSH_THEME="robbyrussell"
ZSH_THEME="blinks"
appengine_config.py
def webapp_add_wsgi_middleware(app):
from google.appengine.ext.appstats import recording
app = recording.appstats_wsgi_middleware(app)
return app
appstats_SHELL_OK = True
app.yaml
[..]
@feczo
feczo / unmounted.py
Last active August 29, 2015 14:02
unmounted disks on compute engine GCE using gcutil
#!/usr/bin/env python
import os
os.system("gcutil listinstances --filter='status eq RUNNING' --columns=disks --format=csv 2>&1 | grep '/' >/tmp/gcutil.mounted;"
"gcutil listdisks --columns=name --format=names >/tmp/gcutil.disks")
disks = set(open("/tmp/gcutil.disks").read().split())
mounted = set(open("/tmp/gcutil.mounted").read().split())
uniques = disks.difference(mounted).union(mounted.difference(disks))
@feczo
feczo / clone-win-gce.md
Last active August 29, 2015 14:02
How to clone a windows compute engine (GCE) instance from command line using gcutil
  1. gcutil addinstance --image=windows-server-2008-r2-dc-v20140609 --zone=europe-west1-windows --machine_type=n1-standard-1 source-windows

  2. Provide a password for the gceadmin account of your Windows instance(s):

  3. wait about 10-15 minutes

  4. confirm that the instance is completely up: gcutil getserialportoutput source-windows output should end with: ```

@feczo
feczo / large-gce-win-disk.md
Last active August 29, 2015 14:02
Create a large disk for Windows instances on Google Compute Engine - GCE
  1. Take a snapshot of your existing instance. Go to console.developers.google.com/project/[Project Number]/compute/snapshots and click "New snapshot" Name your snapshot (e.g. windows-snapshot) and select the disk of your Windows instance under "SOURCE DISK" Click "Create" to create the instance.
  2. Create a bigger disk and apply the snapshot e.g. gcutil --service_version="v1" --project="modelity-wp" adddisk "mybigwindows" --zone="us-central2-windows" --source_snapshot="windows-snapshot" --disk_type="pd-standard" --size_gb="1300"
  3. Create a new instance and attach the bigger disk e.g. gcutil --service_version="v1" --project="modelity-wp" addinstance "mybigwindows" --zone="us-central2-windows" --machine_type="n1-standard-1" --network="default" --external_ip_address="ephemeral" --disk="mybigwindows,deviceName=mybigwindows,mode=READ_WRITE,boot"
@feczo
feczo / api-clone-gce-instance.md
Last active August 29, 2015 14:02
Clone a GCE instance directly through the API

Section A = cloning the disk

  1. go to the cloud console https://console.developers.google.com
  2. go to snapshots and click on 'New snapshot'
  3. select your source disk
  4. Take note of the Name field and click 'Create'
  5. go to disks click on 'New disk'
  6. flip Source Type to Snapshot
  7. make sure you define the zone matching where the instance is going to be hosted
  8. select source snapshot created at step 4
@feczo
feczo / putty-gce.md
Last active July 23, 2020 13:14
How to use Compute Engine - GCE with putty
@feczo
feczo / service-account-dev-prod.py
Created July 3, 2014 13:26
Example of using a service account in both production and development with a .pem key converted from devconsole
import webapp2
from apiclient.discovery import build
from apiclient.errors import HttpError
import httplib2
from oauth2client.client import SignedJwtAssertionCredentials
# Enter your Google Developer Project number
PROJECT_NUMBER = "XXXXXXXXXX"
@feczo
feczo / gcutil_delete.md
Last active August 29, 2015 14:04
Delete ALL your compute engine instances from the default project

delete EVERY instance

gcutil --format=names listinstances | while read inst; do gcutil deleteinstance $inst -f --delete_boot_pd&; done;

Only Unused ones

gcutil listinstances --filter="status ne RUNNING" --format=names | while read inst; do gcutil deleteinstance $inst -f --delete_boot_pd&; done;

apt-get -y update
apt-get -y install nginx; 
echo "<center><h2>Welcome to $HOSTNAME</h2></center>" | sudo tee /usr/share/nginx/www/index.html;
service nginx start

eg.: