Skip to content

Instantly share code, notes, and snippets.

View koblas's full-sized avatar

David Koblas koblas

View GitHub Profile
@koblas
koblas / gist:1436076
Created December 6, 2011 00:25
backbone portfolio
<!--
Looking for some code reviews and commentary on this backbonejs application.
-->
<div class="content">
<table class="portfolio">
<thead>
<tr><th></th><th>Symbol</th><th>Name</th><th>Shares</th><th>% of portfolio value</th></tr>
</thead>
@koblas
koblas / backbone-filtered-collection.js
Created June 26, 2012 14:03
Filtered Collection Wrapper For Backbone
(function(_, Backbone) {
var defaultFilter = function() {return true;};
/**
* This represents a filtered collection. You can either pass a filter or
* invoke setFilter(filter) to give a filter. The filter is identical to
* that which is used for _.select(array, filter)
*
* false filter indicates no filtering.
*
@koblas
koblas / gist:3136961
Created July 18, 2012 15:35 — forked from zmaril/gist:3136483
Puma.com source code
(function (E, B) {
function ka(a, b, d) {
if (d === B && a.nodeType === 1) {
d = a.getAttribute("data-" + b);
if (typeof d === "string") {
try {
d = d === "true" ? true : d === "false" ? false : d === "null" ? null : !c.isNaN(d) ? parseFloat(d) : Ja.test(d) ? c.parseJSON(d) : d
} catch (e) {}
c.data(a, b, d)
} else d = B
@koblas
koblas / aws.py
Created October 23, 2012 18:19
Not caching Exceptions
import logging
from addons.route import route
from .base import BaseHandler
from amazonproduct.api import API, NoExactMatchesFound, TooManyRequests
from tornado import httpclient
from tornado.web import asynchronous, HTTPError
from tornado import gen
from app.util.cache import LRUCache
from StringIO import StringIO
@koblas
koblas / openvpn.cf
Created March 28, 2017 12:08
OpenVPN Cloudformation template
{
"Description": "EC2 OpenVPN host for stage-railz",
"Mappings": {
"AmiMap": {
"us-east-1": {
"bastion": "ami-2757f631",
"ecs": "ami-b2df2ca4",
"ubuntu1604": "ami-2757f631"
},
"us-west-2": {
@koblas
koblas / user_service.go
Created July 30, 2018 18:30
GraphQL user_update code separation
// UpdateUser save user updates to the DB
func (svc *userService) UpdateUser(ctx context.Context, user *model.User, args UpdateUserInput) (*model.User, error) {
update := make(map[string]interface{})
if args.Password != nil {
user.HashPassword(*args.Password)
update["password"] = user.Password
}
if args.Name != nil && *args.Name != user.Name {
update["name"] = *args.Name
@koblas
koblas / wrap_graphql.go
Last active August 3, 2018 13:35
graphql-go/graphql wrapper for unmarshaling
package nresolver
import (
"reflect"
"strings"
"github.com/asaskevich/govalidator"
"github.com/graphql-go/graphql"
"github.com/mitchellh/mapstructure"
)
@koblas
koblas / wrap_isauth.go
Created August 3, 2018 13:39
graphql authentication wrapper
package nresolver
import (
"errors"
"github.com/graphql-go/graphql"
"github.com/koblas/projectx/server-go/pkg/contextkey"
"github.com/koblas/projectx/server-go/pkg/service"
)
@koblas
koblas / schema.go
Created August 3, 2018 14:12
GraphQL Scheme base
package nresolver
import (
"github.com/graphql-go/graphql"
)
var queryConfig = graphql.NewObject(graphql.ObjectConfig{
Name: "Query",
// Must initialize to an empty set
Fields: graphql.Fields{},
@koblas
koblas / user_update.go
Created August 3, 2018 14:33
User Update
package nresolver
import (
"context"
"github.com/graphql-go/graphql"
"github.com/koblas/projectx/server-go/pkg/contextkey"
"github.com/koblas/projectx/server-go/pkg/model"
"github.com/koblas/projectx/server-go/pkg/service"
)