Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dphaener's full-sized avatar

Darin Haener dphaener

View GitHub Profile

Keybase proof

I hereby claim:

  • I am dphaener on github.
  • I am dphaener (https://keybase.io/dphaener) on keybase.
  • I have a public key ASCtvfS81AHlurJbXpzXrAU-TpRUTStPYqPqziO3g96fTgo

To claim this, I am signing this object:

@dphaener
dphaener / application_resolver.rb
Created January 27, 2017 16:52
Base GraphQL Resolver
class ApplicationResolver
def self.get_policy_class
name.sub("Resolver", "Policy").safe_constantize
end
def self.authorize(ctx, record, action)
policy_class = get_policy_class
if policy_class
policy = policy_class.new(ctx, record, ctx.brewery)
{"data":{"__schema":{"queryType":{"name":"Query"},"mutationType":{"name":"Mutation"},"subscriptionType":null,"types":[{"kind":"OBJECT","name":"Query","description":"The query root for this schema","fields":[{"name":"node","description":null,"args":[{"name":"id","description":null,"type":{"kind":"NON_NULL","name":"Non-Null","ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"defaultValue":null}],"type":{"kind":"INTERFACE","name":"Node","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"user","description":null,"args":[{"name":"token","description":null,"type":{"kind":"NON_NULL","name":"Non-Null","ofType":{"kind":"SCALAR","name":"String","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INTERFACE","name":"Node","description":null,"fields":[{"name":"id","description":null,"args":[],"type":{"kind":"NON_NULL","name":"Non-
@dphaener
dphaener / webpack_loaders.js
Created January 20, 2016 03:38
Webpack extra config
// Add these to the loaders in webpack.config.js
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
// Install the loaders for that
npm install --save url-loader file-loader
@dphaener
dphaener / networkLayer.js
Created January 13, 2016 18:58
A sample custom network layer for Relay
import Relay from 'react-relay'
import fetch from 'isomorphic-fetch'
export default class NetworkLayer {
constructor(auth, url = null) {
this.auth = auth
this.url = url || 'http://localhost:7000/queries'
}
get defaultHeaders() {
var webpack = require('webpack');
module.exports = {
entry: {
'react-reading-time': [
'webpack-dev-server/client?http://localhost:8881/',
'webpack/hot/only-dev-server',
'./example/react-reading-time.jsx'
]
},
@dphaener
dphaener / sections.geojson
Created January 6, 2016 18:44
California Sections
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dphaener
dphaener / elemental-modal.scss
Created October 26, 2015 22:18
Elemental UI Modal CSS
%modal_common {
margin-left: 20px;
margin-right: 20px;
padding-bottom: 20px;
padding-top: 20px;
position: relative;
}
@-webkit-keyframes modalDialogEnter {
@dphaener
dphaener / flash.html.erb
Created March 13, 2015 02:04
Flash HTML for Basewise
<% if flash[:success] %>
<div class="flash-success">
<span><%= flash[:success] %></span>
</div>
<% end %>
<% if flash[:error] %>
<div class="flash-error">
<span><%= flash[:error] %></span>
</div>
@dphaener
dphaener / flash.css.scss
Created March 13, 2015 02:02
Flash CSS for Basewise
$base-spacing: 1.5em !default;
$alert-color: #fff6bf !default;
$error-color: #fbe3e4 !default;
$notice-color: #e5edf8 !default;
$success-color: #e6efc2 !default;
@mixin flash($color) {
background-color: $color;
color: darken($color, 60%);
display: block;