Skip to content

Instantly share code, notes, and snippets.

View bruce's full-sized avatar
✌️

Bruce Williams bruce

✌️
View GitHub Profile
@bruce
bruce / example.graphql
Created January 5, 2017 19:24
Example introspecting enum values
{
__type(name: "Color") {
enumValues {
name
}
}
}
@bruce
bruce / absinthe_example.ex
Created January 4, 2017 20:51
Comparing absinthe schema definition to graphql-elixir schema definition
defmodule TestSchema do
use Absinthe.Schema
query do
@desc "A Greeting"
field :greeting, :string do
@desc "The name of who you'd like to greet"
arg :name, :string
resolve &greeting/3
end
@bruce
bruce / schema.ex
Created January 3, 2017 07:51
Quick, dirty (and untested) example of using import_types and import_fields
defmodule MyApp.Schema do
use Absinthe.Schema
import_types MyApp.Schema.Query.User
query do
import_fields :user_queries
end
end
@bruce
bruce / Program.cs
Created November 10, 2016 00:30
Basic "Hello World" WinForms in C# and F#
using System;
using System.Drawing;
using System.Windows.Forms;
namespace MWFTestApplication {
class MainWindow : System.Windows.Forms.Form {
public MainWindow() {
Label label;
ClientSize = new System.Drawing.Size (250, 250);
@bruce
bruce / resolution.ex
Created November 4, 2016 06:38
Example resolver mapping / wrapping
defmodule Resolution do
@operations %{
organization: {Resolution.Organization, :find}
# lots of others...
}
def resolver(name) do
case @operations |> Map.get(name) do
{mod, fun} ->
@bruce
bruce / vps.md
Created October 3, 2016 22:38
VPS requirements

9 WP-based sites doing e-commerce:

  • Currently using 50 GB storage (total all sites); need room for media to grow.
  • Currently using 1GB / day total transfer (all sites)

VPS environment:

  • Currently on CENT 5
  • Need to upgrade to SHA256 and TLS 1.2 (prob CENT 7)
  • Currently using Cpanel & WHM; want the same.
  • 4+ GB RAM
  • CSF & LFD

Given this code, filtering to only retrieve "dog" records:

"""
{
  pets(ofType: "dog") {
    name
  }
}
"""
@bruce
bruce / concrete_id.ex
Created April 16, 2016 23:26
Example of how to use
defmodule Foo.ConcreteId do
alias Absinthe.Relay.Node
def to_concrete_id(node_id, expected_node_type) do
{:ok, %{type: ^expected_node_type, id: id}} = Node.from_global_id(node_id, Foo.Schema)
id
end
end
# Abstract
class Transaction
attr_reader :amount, :description
def initialize(amount, description)
@amount = amount
@description = description
end
# Common stuff here...
end
@bruce
bruce / Product.js
Created March 30, 2016 17:13
Probably dispatching rendering different components when I should just have routed to separate Product components instead...
import classnames from 'classnames';
// Redux
import { connect } from 'react-redux';
import Redux, { bindActionCreators } from 'redux';
import * as productSlugActions from '../../actions/currentProductSlug';
import ProductADashboard from '../../components/ProductADashboard';
import ProductBDashboard from '../../components/ProductBDashboard';
import ProductCDashboard from '../../components/ProductCDashboard';