Skip to content

Instantly share code, notes, and snippets.

View alfredodeza's full-sized avatar
:octocat:

Alfredo Deza alfredodeza

:octocat:
View GitHub Profile
@alfredodeza
alfredodeza / zpool_config
Created April 21, 2014 13:23
zpool get all zones
zpool get all zones
NAME PROPERTY VALUE SOURCE
zones size 2.72T -
zones capacity 42% -
zones altroot - default
zones health ONLINE -
zones guid 1181797254408314611 default
zones version - default
zones bootfs - default
zones delegation on default
@alfredodeza
alfredodeza / gist:88ea216f2cd57797b737
Last active August 29, 2015 14:02
Run a Vim command on a bunch of files
# For a bunch of Python files
vim -c "bufdo! set eventignore-=Syntax| %s/original/replacement/gce" *.py
# if you want to save as you go
vim -c "bufdo! set eventignore-=Syntax| %s/original/replacement/gce | update" *.py
# Breaking it down:
# bufdo! -> so that it doesn't complain about erroring
# set eventignore-=Syntax -> so that every buffer gets syntax highlighting
# /gce -> optional, global search in the line with confirmation and eating up the errors
@alfredodeza
alfredodeza / mix_out.py
Created June 27, 2014 13:47
alternating stderr with stdout with subprocess.Popen
# ideally we would have output like:
$ python process.py
this is an stderr line
this is an stdout line
this is an stderr line
this is an stdout line
@alfredodeza
alfredodeza / gist:77e623624246c4b92b9f
Created August 30, 2014 21:31
Trying to use py.test fixtures with Pecan + SQLAlchemy
# app name: ayni
# this works, inheriting from it, committing and re-using the database
#
# ayni model __init__.py file doesn't have anything odd and can be found:
# https://github.com/alfredodeza/ayni/blob/master/ayni/models/__init__.py
#
import os
from unittest import TestCase
from pecan import set_config
from pecan.testing import load_test_app
@alfredodeza
alfredodeza / generate.py
Created November 7, 2014 03:02
a simple markov phrase generator
import random
class Markov(object):
def __init__(self, open_file):
self.cache = {}
self.open_file = open_file
self.words = self.file_to_words()
self.word_size = len(self.words)
@alfredodeza
alfredodeza / new_repo.sh
Created April 7, 2015 16:54
new Ceph release repo
# create the new rpm directory
mkdir rpm-hammer
cd rpm-hammer
# make the directories for the distros we need for x86_64
mkdir -p el6/x86_64/
mkdir -p el7/x86_64/
mkdir -p fc20/x86_64/
mkdir -p rhel6/x86_64/
mkdir -p rhel7/x86_64/
@alfredodeza
alfredodeza / unmask.js
Created April 28, 2015 13:04
Unmask passwords
var els=document.getElementsByTagName('input'); for(var x = 0; x < els.length; x++) { if(els[x].type.toLowerCase() == 'password' ) { var test = els[x].type = 'text'; } }
@alfredodeza
alfredodeza / test_myclass.py
Created February 16, 2011 02:25
A proof of concept for better readability in tests
from testrunner import describe, it, before, after
import MyClass
with describe("My class can add"):
with before:
c = MyClass()
with after:
"clean up goes here"
@alfredodeza
alfredodeza / konira.bat
Created September 5, 2011 17:43
Trying to get a konira executable for MS win
@echo off
rem Windows Driver script for Konira
setlocal
rem Use a full path to Python (relative to this script) as the standard Python
rem install does not put python.exe on the PATH...
rem %~dp0 is the directory of this script
python "%~dp0konira" %*
@alfredodeza
alfredodeza / pecha_kucha.py
Created June 8, 2012 01:15
Pecha Kucha random image driver
# The web server:
import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)