Skip to content

Instantly share code, notes, and snippets.

View brent-hoover's full-sized avatar
🏠
Working from home

Brent Hoover brent-hoover

🏠
Working from home
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>Chromecast init</title>
<script src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
</head>
<body>
<div id="message"></div>
<script type="text/javascript">
/*
* Copyright (c) 2014 Gerwin Sturm, FoldedSoft e.U. / www.foldedsoft.at
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@brent-hoover
brent-hoover / destructive_encode.py
Created February 7, 2014 22:40
Unicode safe wrapper for urlencode
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from urllib import urlencode
def destructive_encode(instring):
if isinstance(instring, unicode):
print('is unicode')
outstring = instring.encode('utf8')
elif isinstance(instring, str):
@brent-hoover
brent-hoover / create_nginx_key.sh
Last active August 29, 2015 13:55 — forked from jessedearing/gist:2351836
Set up self-signed key for Nginx
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@brent-hoover
brent-hoover / dynamicMapping.java
Created January 20, 2014 15:19
Dynamic Mapping
private void loadRules(Map<String, Object> rules, ResultSet results) throws SQLException {
// create map to hold results
while(results.next()) {
DataType dataType
= new ReferenceTableEntryFactory<DataType>().createFromCode(results.getInt(4), DataType.values());
switch (dataType) {
case Boolean:
rules.put(results.getString(3), results.getBoolean(6));
break;
case TinyInt:
@brent-hoover
brent-hoover / show_queries.py
Created January 20, 2014 14:57
Get SQL queries from Django ORM commands
from django import db
def show_queries():
for query in db.connection.queries:
print query["sql"]
db.reset_queries()
@brent-hoover
brent-hoover / parameterized.py
Created January 20, 2014 14:56
Parameterizing Unit Tests
import unittest
l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]]
class TestSequense(unittest.TestCase):
pass
def test_generator(a, b):
def test(self):
self.assertEqual(a,b)
@brent-hoover
brent-hoover / serializable.py
Created January 20, 2014 14:55
Serializable Object (my version accounts for nested object, so I should merge)
class SerializableMixin(object):
"""
Mixin to convert an Object to json-encodable standard types
We only want to encode public properties
"""
def deserialize(self, values):
for k, v in values.items():
if hasattr(self, k):
setattr(self, k, v)