Skip to content

Instantly share code, notes, and snippets.

View dmpeters's full-sized avatar
👨‍🔧

David Peters dmpeters

👨‍🔧
View GitHub Profile
@dmpeters
dmpeters / pappy1
Last active August 29, 2015 14:00
js for pap
var mt_referrer = document.cookie.match(new RegExp("mt_referrer" + '=([^;]+)'));
if(mt_referrer==null){
console.log('FUCK')
}else{
console.log(document.referrer)
}
@dmpeters
dmpeters / example.json
Created February 10, 2015 22:59
packer vagrant example
{
"builders": [{
"type": "virtualbox",
"iso_url": "http://releases.ubuntu.com/12.04/ubuntu-12.04.3-server-amd64.iso",
"iso_checksum": "2cbe868812a871242cdcdd8f2fd6feb9"
}],
"builders": [{
"type": "amazon-ebs",
"source_ami": "ami-de0d9eb7",
"region": "us-east-1",
{
"builders": [{
"type": "amazon-ebs",
"source_ami": "ami-de0d9eb7",
"region": "us-east-1",
}],
"provisioners": [{
"type": "puppet-masterless",
"manifest_file": "site.pp"
}],
@dmpeters
dmpeters / foo.md
Last active August 29, 2015 14:21

The Perils of CouchDB / Postgres to the rescue

CouchDB as an application database kind of sucks. Basically the only reason to use it is because it easily supports unstructured data. Even so, its limitations have a ton of negative ripple effects on basically the entire development process.

Luckily, Postgres has an hstore column type and has recently added a json column type. json supports arbitrary JSON but is stored as text so operations are slower. hstore stores only a flat mapping of string keys and values in a fast binary format, but nesting is on tap for 9.4 (Q3 2014) and non-string types are on the roadmap. In the meantime, nesting can be simulated by storing the full path to a value as the string key, and types can be handled in the application layer including with a query building abstraction that automatically casts hstore values to their expected types in database queries.

Postgres supports a number of other features that all together make it look like a great solution for scalably storing m

@dmpeters
dmpeters / backend.py
Last active August 29, 2015 14:22 — forked from dmitric/backend.py
class Backend(object):
def __init__(self):
engine = create_engine("mysql://{0}:{1}@{2}/{3}".format(options.mysql_user, options.mysql_pass, options.mysql_host, options.mysql_db)
, pool_size = options.mysql_poolsize
, pool_recycle = 3600
, echo=options.debug
, echo_pool=options.debug)
self._session = sessionmaker(bind=engine)
@classmethod
@dmpeters
dmpeters / gist:3195360
Created July 29, 2012 00:04
homebrew issues with git and pkg-config after installing mountain lion osx 10.8
Undefined symbols for architecture x86_64:
"_iconv", referenced from:
Undefined symbols for architecture x86_64:
"_iconv", referenced from:
_reencode_string in libgit.a(utf8.o)
_reencode_string in libgit.a(utf8.o)
"_iconv_close", referenced from:
"_iconv_close", referenced from:
_reencode_string in libgit.a(utf8.o)
Undefined symbols for architecture x86_64:
<?xml version="1.0" encoding="UTF-8"?>
<RETS ReplyCode="0" ReplyText="Operation successful.">
<METADATA>
<METADATA-RESOURCE Version="01.72.10255" Date="2013-02-06T21:22:33" System="BAK">
<Resource>
<ResourceID>ActiveAgent</ResourceID>
<StandardName>ActiveAgent</StandardName>
<VisibleName>Active Agent Search</VisibleName>
<Description>Contains information about active agents.</Description>
<KeyField>MemberNumber</KeyField>
@dmpeters
dmpeters / regex guide
Created February 11, 2013 21:39
a simple regex table for later reference.
_Symbol_ _Description_
. Any single character
\d Any single digit
[A-Z] Any character between A and Z (uppercase)
[a-z] Any character between a and z (lowercase)
[A-Za-z] Any character between a and z (case-insensitive)
+ One or more of the previous expression (for example, \d+ matches one or more digits)
[^/]+ One or more characters until (and not including) a forward slash
? Zero or one of the previous expression (for example, \d? matches zero or one digits)
* Zero or more of the previous expression (for example, \d* matches zero, one or more than one digit)
@dmpeters
dmpeters / elasticsearch_notes.md
Created February 25, 2013 00:33
Hacker News - February Meetup - elasticsearch Notes

Hacker News - February Meetup

elasticsearch notes

What is elasticsearch

  • a way to search... things
  • way to search data in terms of naturla language and mocuh more...
  • distributed JSON API
  • fancy cluster

What is lucene?

@dmpeters
dmpeters / salt_osx_setup.md
Created March 25, 2013 01:57
getting started with salt on osx

getting started with salt

a little adventurous tale of setting up salt on osx...

salt osx docs: http://goo.gl/E6ZtA

overall, seemed pretty straight forward...(?)

  • preliminary steps:
    • brew update (I did this to make sure I was up to date)
    • brew upgrade (I did this to upgrade what I was not up to date with)
  • brew doctor (I did this to make sure I was 'raring to brew')