Skip to content

Instantly share code, notes, and snippets.

View theacodes's full-sized avatar
🎛️
Bleep bloop

Stargirl Flowers theacodes

🎛️
Bleep bloop
View GitHub Profile
@theacodes
theacodes / service.py
Created October 16, 2014 15:36
Todo - 2
import ferris3
from google.appengine.ext import ndb
class Todo(ndb.Model):
text = ndb.StringProperty(default='', indexed=False)
done = ndb.BooleanProperty(default=False)
created = ndb.DateTimeProperty(auto_now_add=True)
@theacodes
theacodes / service.py
Created October 16, 2014 15:29
Ferris 3 todo
import ferris3
from google.appengine.ext import ndb
class Todo(ndb.Model):
text = ndb.StringProperty(default='', indexed=False)
done = ndb.BooleanProperty(default=False)
created = ndb.DateTimeProperty(auto_now_add=True)
@theacodes
theacodes / Dockerfile
Created October 14, 2014 14:21
Example python dockerfile (managed vms)
# Dockerfile extending the generic Python image with application files for a
# single application.
FROM google/appengine-python27
ADD requirements.txt /app/
RUN pip install -r requirements.txt
ADD . /app
@theacodes
theacodes / app.yaml
Last active August 29, 2015 14:07
Cloud Endpoints - Issue with resources & multiclass.
application: your-app-id
version: 1
runtime: python27
threadsafe: true
api_version: 1
module: api
handlers:
# Endpoints handler
- url: /_ah/spi/.*
@theacodes
theacodes / main.py
Created October 7, 2014 20:33
Simple top-level exception catch
import logging_config
if __name__ == '__main__':
try:
do_stuff()
except Exception as e:
logging.exception(e)
raise
@theacodes
theacodes / logging_setup.py
Created October 7, 2014 20:30
Sentry/Raven simple global logging setup
from raven.handlers.logging import SentryHandler
from raven.conf import setup_logging
import logging
handler = SentryHandler('sentry dsn here')
setup_logging(handler)
console = logging.StreamHandler()
console.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)-12s: %(levelname)-8s: %(message)s', datefmt='%m-%d %H:%M')
@theacodes
theacodes / script.js
Created October 5, 2014 04:36
Generic protorpc containers
function flatten_generic_value(val){
if(val.type === 'container'){
return flatten_generic(val['container_value']);
} else if(val.type === 'list'){
return val.list_value.map(flatten_generic_value);
} else {
return val[val.type + '_value'];
}
};
@theacodes
theacodes / index.html
Created September 6, 2014 18:39
Simple socket.io log viewer
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="/static/socket.io.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
<script>
angular.module('app', [])
.controller('logs', function($scope){
@theacodes
theacodes / logserver.py
Created September 6, 2014 18:29
Gevent based log server
#!/usr/bin/env python
from gevent import monkey
monkey.patch_all()
monkey.patch_sys(stdin=True, stdout=False, stderr=False)
import gevent
from gevent.queue import Queue
import signal
import sys
from socketio.namespace import BaseNamespace
@theacodes
theacodes / echo.py
Created September 6, 2014 17:58
Non-blocking gevent stdin read
#!/usr/bin/env python
from gevent import monkey
monkey.patch_all()
monkey.patch_sys(stdin=True, stdout=False, stderr=False)
import gevent
from gevent.queue import Queue
import sys
import signal