Skip to content

Instantly share code, notes, and snippets.

View adam-stokes's full-sized avatar
🦧

Adam Stokes adam-stokes

🦧
  • North Carolina
  • 17:46 (UTC -04:00)
View GitHub Profile
@adam-stokes
adam-stokes / websocket.pl
Created February 12, 2014 00:41
connect to websocket
#!/usr/bin/env perl
use Mojo::UserAgent;
my $endpoint = 'wss://10.0.3.1:17070/';
my $ua = Mojo::UserAgent->new;
$ua->websocket(
$endpoint => sub {
my $tx = pop;
@adam-stokes
adam-stokes / websocket2.pl
Created February 12, 2014 01:13
websocket2
#!/usr/bin/env perl
use Mojo::Transaction::WebSocket;
use DDP;
my $endpoint = 'wss://10.0.3.1:17070/';
my $ws = Mojo::Transaction::WebSocket->new(
remote_address => '10.0.3.1',
remote_port => '17070',
@adam-stokes
adam-stokes / websocket4.pl
Created February 12, 2014 02:29
websocket4
-- Non-blocking request (https://10.0.3.1:17070)
-- Switching to non-blocking mode
-- Connect (https:10.0.3.1:17070)
-- Client >>> Server (https://10.0.3.1:17070)
GET / HTTP/1.1
Connection: Upgrade
Content-Length: 0
Host: 10.0.3.1:17070
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: IDg2NzkxMDkxNDU2MjA2MA==
(use-package py-autopep8
:config
(add-hook 'before-save-hook 'py-autopep8-before-save))
@adam-stokes
adam-stokes / install-some-shit.sh
Last active August 29, 2015 14:06
install some shit
#!/bin/bash
sudo apt-update
sudo apt-get install -qyf git ubuntu-dev-tools emacs24
# pyenv
git clone git://github.com/yyuu/pyenv.git ~/.pyenv
# install pyenv virtualenv
git clone git://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
@adam-stokes
adam-stokes / cpanfile
Created September 16, 2014 02:18
perl deps
# download this file and run
# cpanm --installdeps .
requires "App::cpanminus" => "0";
requires "Mojo::UserAgent" => "0";
requires "strict" => "0";
requires "warnings" => "0";
requires "App::Ack" => "0";
requires "App::Cmd" => "0";
requires "App::Cronjob" => "0";
def run(self):
if os.path.exists(self.container_abspath):
log.error("Container exists, exiting.")
# Container exists, handle return code in installer
sys.exit(1)
self.ui.info_message(
"* Please wait while we generate your isolated environment ...")
utils.ssh_genkey()
self.prep_userdata()
class PasswordInput(WidgetWrap):
""" Password input dialog
"""
__metaclass__ = signals.MetaSignals
signals = ['done']
def __init__(self, title, done_signal_handler):
self.title = '{0} (Esc)'.format(title)
self.pass_input = Edit(caption=('', 'Password: '), mask='*')
class SingleInstall:
def __init__(self, opts, ui):
self.opts = opts
self.ui = ui
self.config = Config()
self.container_name = 'uoi-bootstrap'
self.container_path = '/var/lib/lxc'
self.container_abspath = os.path.join(self.container_path,
self.container_name)
def container_run(name, cmd, nowait=False):
""" run command in container
:param str name: name of container
:param str cmd: command to run
"""
ip = container_ip(name)
cmd = "sudo -H -u {3} TERM=xterm256-color ssh -t -q " \
"-l ubuntu -o \"StrictHostKeyChecking=no\" " \
"-o \"UserKnownHostsFile=/dev/null\" " \