Skip to content

Instantly share code, notes, and snippets.

View rgbkrk's full-sized avatar
🌎
Think globally, act locally

Kyle Kelley rgbkrk

🌎
Think globally, act locally
View GitHub Profile
@rgbkrk
rgbkrk / fabfile.py
Last active December 25, 2015 16:49
Fabric file for creating named servers on Rackspace and bootstrapping them as salt minions.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Bootstrapping the salt minions on Rackspace (using fabric rather than
salt-cloud).
This is not the most effective way to do this, but it gets it done.
@rgbkrk
rgbkrk / stderr
Created October 17, 2013 17:45
nbviewer stderr via [salt-nbviewer deployment](https://github.com/rgbkrk/salt-nbviewer).
root@prod03:/var/log# cat supervisor/nbviewer-stderr---supervisor-r3dISD.log
2013-10-17 17:10:49 [17848] [INFO] Starting gunicorn 18.0
2013-10-17 17:10:49 [17848] [INFO] Listening at: http://0.0.0.0:8080 (17848)
2013-10-17 17:10:49 [17848] [INFO] Using worker: sync
2013-10-17 17:10:49 [17859] [INFO] Booting worker with pid: 17859
2013-10-17 17:10:49 [17864] [INFO] Booting worker with pid: 17864
2013-10-17 17:10:49 [17869] [INFO] Booting worker with pid: 17869
/usr/share/nbviewer/venv/local/lib/python2.7/site-packages/IPython/utils/path.py:304: UserWarning: IPython parent '/usr/share/nbviewer' is not a writable location, using a temp directory.
" using a temp directory."%parent)
/usr/share/nbviewer/venv/local/lib/python2.7/site-packages/IPython/utils/path.py:304: UserWarning: IPython parent '/usr/share/nbviewer' is not a writable location, using a temp directory.
@rgbkrk
rgbkrk / nbviewer.stderr
Created October 17, 2013 20:04
500 nbviewer
[2013-10-17 20:03:15,960] ERROR: Exception on /create/ [POST]
Traceback (most recent call last):
File "/usr/share/nbviewer/venv/local/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "/usr/share/nbviewer/venv/local/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/share/nbviewer/venv/local/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/share/nbviewer/venv/local/lib/python2.7/site-packages/flask/app.py", line 1344, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
@rgbkrk
rgbkrk / Primality triangle
Last active December 26, 2015 13:19
Primality checking regex
In [36]: composite_regex = re.compile(r"^1?$|^(11+?)\1+$")
In [37]: for ii in range(256):
print("%03d %s %s" % (ii, ii*"1", "" if composite_regex.match("1"*ii) else "- Prime!" ))
....:
000
001 1
002 11 - Prime!
003 111 - Prime!
004 1111
@rgbkrk
rgbkrk / ohmy.vim
Last active December 26, 2015 13:59
vim madness
" Search and replace simple anonymous js function that returns to coffeescript
%s/function(\([^)]*\))\s*{\s*return\s*\([^}]*\);\s*}/(\1) -> ( \2 )/cg
@rgbkrk
rgbkrk / forward.bash
Created October 31, 2013 21:42
Forward a port to port 80 using iptables
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 5000
iptables-save
@rgbkrk
rgbkrk / pyrax_install.ps1
Last active April 2, 2022 22:11
Powershell installation of python and pyrax on a fresh Rackspace Windows Server instance
##
## NOTE: This script is a walkthrough and may not work if run directly.
##
## If downloaded to run, make sure to set
##
## Set-ExecutionPolicy RemoteSigned
##
# Create a downloader via .NET
$notwget = New-Object System.Net.WebClient
@rgbkrk
rgbkrk / gist:7296691
Created November 4, 2013 01:09
XORed all the files within .git with random bytes, tried to reinitialize.
19:03:39 ~/code/wat/so_test$ git status
fatal: Not a git repository (or any of the parent directories): .git
19:05:19 ~/code/wat/so_test$ git init
fatal: bad config file line 1 in /Users/kyle6475/code/wat/so_test/.git/config
19:05:22 ~/code/wat/so_test$ rm .git/config
19:05:29 ~/code/wat/so_test$ git init
Reinitialized existing Git repository in /Users/kyle6475/code/wat/so_test/.git/
19:05:33 ~/code/wat/so_test$ git status
fatal: Not a git repository (or any of the parent directories): .git
@rgbkrk
rgbkrk / boot.sh
Last active December 27, 2015 14:19
Bring up a performance instance, download Expedia data from Kaggle
10:19:27 ~$ nova keypair-add --pub-key ~/.ssh/id_rsa.pub kyle
10:19:43 ~$ nova boot perf_kaggle --image dee7f62b-cbb1-4fdc-8dc5-33e408d8c599 --flavor performance2-15 --poll --key-name kyle
# Image is Ubuntu 13.04 w/ PVHVM Beta
# Flavor is the smallest of the performance 2 instances
nova boot saltmaster --image 62df001e-87ee-407c-b042-6f4e13f5d7e1 --flavor performance2-15 --poll --key-name kyle_grass --disk-config=AUTO