Skip to content

Instantly share code, notes, and snippets.

View vishvananda's full-sized avatar

Vish (Ishaya) Abrams vishvananda

  • Heroku
  • United States
View GitHub Profile
#!/usr/bin/env bash
ENDPOINT_TYPE=${3:-$ENDPOINT_TYPE}
KEYSTONE_HOST=${4:-$KEYSTONE_HOST}
function die {
echo $1
echo "usage: $0 <username> <password>" \
"<type=\$ENDPOINT_TYPE> <host=\$KEYSTONE_HOST>"
exit 1
}
@vishvananda
vishvananda / rc.sh
Created September 23, 2011 13:39 — forked from anonymous/gist:1237339
function git_branch {
git branch --no-color 2> /dev/null | egrep '^\*' | sed -e 's/^* //'
}
function git_dirty {
# only tracks modifications, not unknown files needing adds
if [ -z "`git status -s | awk '{print $1}' | grep '[ADMTU]'`" ] ; then
return 1
else
return 0
#!/usr/bin/python3.1
import struct
class BootRecord:
def __init__(self):
self.rootdir_cluster = 0
def unpack(self, data):
offset = 0
(self.boot_instructions,
@vishvananda
vishvananda / running-openstack-nova-with-pypy.md
Last active April 14, 2021 14:45
Running OpenStack Nova with PyPy

Overview

For those that are unfamiliar with the project, PyPy is an implementation of the Python language that features a JIT Compiler. I have noticed a huge performance benefit in some personal projects by switching to PyPy. I have always been curious how it would perform on a large and complex project like OpenStack, but my early experiments ran into massive roadblocks around broken dependencies.

It has been six months since I last looked, so I figured it was time to try it again. Support has come a long way and, now that lxml is working, we are close enough to get a Proof-of-Concept running. Read on for instructions on running nova with PyPy.

Preparation

Start out with a base ubuntu 12.04 (precise) install and run devstack. I won't go through the details of getting devstack running here, because there are already instructions on the devstack site.

@vishvananda
vishvananda / using-openssl-from-python-with-python-cffi.md
Last active September 9, 2020 16:11
Using OpenSSL from Python with python-cffi

Introduction

A few weeks ago I stumbled across a thread on hacker news that referenced the Matasano Cyrpto Challenge. I find myself unable to resist this type of problem so I decided to make an attempt. It teaches you to find vulnerabilities in crypto systems by starting with simple attacks and building up to more complex ones. Early on in the project it has you start breaking ecryption that uses the AES cypher in ECB mode. It specifically asks you not to implement the cypher yourself but to use a known-correct implementation like OpenSSL.

I tend to try to solve programming challenges in python, because the coding goes much more quickly. I checked the pyOpenSSL docs (which I have used before) to determine the call for encryption in ECB mode.

@vishvananda
vishvananda / keybase.md
Created January 4, 2019 19:20
keybase.md

Keybase proof

I hereby claim:

  • I am vishvananda on github.
  • I am vish (https://keybase.io/vish) on keybase.
  • I have a public key ASDJQdb6cmnHPgDREMp0elvm7IeX-yGsiggaGpyb-v9wUgo

To claim this, I am signing this object:

Vagrant::Config.run do |global_config|
aptdir = (ENV['APTCACHE'] or "#{ENV['HOME']}/aptcache/")
checkout = (ENV['COOKBOOKS'] or "#{ENV['HOME']}/openstack-cookbooks")
ip_prefix = (ENV['IP_PREFIX'] or "192.168.76.")
mac_prefix = (ENV['MAC_PREFIX'] or "080027076")
fixed = (ENV['FIXED'] or "10.0.76.0/24")
global_config.vm.define :chef do |config|
suffix = "100"
ip = "#{ip_prefix}#{suffix}"
config.vm.box = "base"
@vishvananda
vishvananda / sumproduct.py
Created October 25, 2013 18:15
Solution for the sum product puzzle
answers = set()
MAX = 100
for a in xrange(2, MAX):
for b in xrange(a, MAX):
answers.add((a, b))
print len(answers)
# sum knows product doesn't know the answer so potential a, b can't have one product solution
products = {}
@vishvananda
vishvananda / git.sh
Created May 8, 2013 00:42
show me all commits since we added the debian directory that don't modify the debian directory, aren't cherry-picks (as identified by having the word 'cherry' in the commit message), and aren't merge commits. (The since 2011-01-01 is to ignore really old commits when searching for the debian directory addition since really old commits of nova ha…
git log --no-merges --pretty=oneline `git rev-list HEAD --since "2011-01-01" -- debian | tail -n1`..HEAD | grep -v -F "`git rev-list HEAD -- debian`" | grep -v -F "`git rev-list HEAD --grep cherry`"
@vishvananda
vishvananda / vim
Created February 5, 2013 20:45
script for starting conole vim in homebrew with the Valloric/YouCompleteMe plugin . Put this in your path, for example as /usr/local/bin/vim
#!/bin/bash
DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=/usr/local/Cellar/python/2.7.3/lib/libpython2.7.dylib /usr/local/Cellar/macvim/7.3-*/MacVim.app/Contents/MacOS/Vim "$@"