Skip to content

Instantly share code, notes, and snippets.

@y-yagi
y-yagi / tutorial.md
Created July 17, 2018 04:50 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

record = Post.new(:title => 'Yay', :body => 'This is some insert SQL')
# easiest way to achieve this is by calling protected #arel_attributes_values (tested in
# rails 3.2.13). the alternative is to build the entire insert statement using arel >_>
record.class.arel_table.create_insert \
.tap { |im| im.insert(record.send(:arel_attributes_values, false)) } \
.to_sql
require 'openssl'
require 'socket'
KEY = OpenSSL::PKey::RSA.new <<-_end_of_pem_
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDLwsSw1ECnPtT+PkOgHhcGA71nwC2/nL85VBGnRqDxOqjVh7Cx
aKPERYHsk4BPCkE3brtThPWc9kjHEQQ7uf9Y1rbCz0layNqHyywQEVLFmp1cpIt/
Q3geLv8ZD9pihowKJDyMDiN6ArYUmZczvW4976MU3+l54E6lF/JfFEU5hwIDAQAB
AoGBAKSl/MQarye1yOysqX6P8fDFQt68VvtXkNmlSiKOGuzyho0M+UVSFcs6k1L0
maDE25AMZUiGzuWHyaU55d7RXDgeskDMakD1v6ZejYtxJkSXbETOTLDwUWTn618T
#!/usr/bin/env ruby
# Tab completion for minitest tests.
#
# INSTALLATION:
#
# 1. Put this file in a directory in your $PATH. Make sure it's executable
# 2. Run this:
#
# $ complete -o bashdefault -f -C /path/to/this/file.rb ruby
@y-yagi
y-yagi / pr.md
Last active August 29, 2015 14:13 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

sudo -i
cd
apt-get install build-essential checkinstall && apt-get build-dep imagemagick -y
wget http://www.imagemagick.org/download/ImageMagick-6.8.7-7.tar.gz
tar xzvf ImageMagick-6.8.9-1.tar.gz
cd ImageMagick-6.8.9-1/
./configure --prefix=/opt/imagemagick-6.8 && make
checkinstall
import com.android.volley.toolbox.HurlStack;
import com.squareup.okhttp.OkHttpClient;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* An {@link com.android.volley.toolbox.HttpStack HttpStack} implementation which
* uses OkHttp as its transport.
*/

Testing behavior of a CollectionProxy based on :dependent option, delete method used and assocation type (:has_many vs :has_many :through)

:has_many association

class Category < ActiveRecord::Base
	has_many :contacts, through: :categorizations
	has_many :categorizations, dependent: DEPENDENT
end
# config/initializers/char_converter.rb
require 'uri'
module Support
class CharConverter
SANITIZE_ENV_KEYS = [
"HTTP_COOKIE", # bad cookie encodings kill rack: https://github.com/rack/rack/issues/225
"HTTP_REFERER",
"PATH_INFO",

Testing behavior of a CollectionProxy based on :dependent option, delete method used and assocation type (:has_many vs :has_many :through)

:has_many association

class Category < ActiveRecord::Base
	has_many :contacts, through: :categorizations
	has_many :categorizations, dependent: DEPENDENT
end