Skip to content

Instantly share code, notes, and snippets.

View nickretallack's full-sized avatar

Nick Retallack nickretallack

View GitHub Profile
@nickretallack
nickretallack / preview.swift
Last active July 16, 2024 05:23
Example of using relationships in a SwiftData preview and passing an instance as an argument.
import SwiftUI
import SwiftData
struct ItemView: View {
var parent: Parent
var body: some View {
VStack {
Text(parent.id)
List(parent.children) { child in
Text("Child \"\(child.id)\" of parent \"\(child.parent!.id)\"")
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': 'localhost',
'NAME': 'db',
'USER': 'root',
'PASSWORD': '',
'OPTIONS': {
'charset': 'utf8mb4',
'init_command': 'set collation_connection=utf8mb4_unicode_ci',
#[derive(Debug)]
struct Point {
x: f32,
y: f32,
}
#[derive(Debug)]
struct Rectangle {
p1: Point,
p2: Point,
$ brew update
warning: unable to unlink CONTRIBUTING.md: Permission denied
warning: unable to unlink SUPPORTERS.md: Permission denied
fatal: cannot create directory at '.github': Permission denied
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
$ brew update
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mach (LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Library/Homebrew/extend/pathname.rb:2:in `<top (required)>'
@nickretallack
nickretallack / error
Last active October 13, 2015 08:14
Why can't I put more than one level of
Uncaught Error: Invariant Violation: Relay.QL: Expected query `viewer` to be empty. For example, use `node(id: $id)`, not `node(id: $id) { ... }`.
@nickretallack
nickretallack / query1.graphql
Last active October 13, 2015 04:12
Why does it do a second query instead of re-using the result?
fragment on Viewer {
files(first: 10) {
edges {
node {
id,
url,
},
},
},
}
{
"errors": [
{
"message": "Argument \"input\" expected type \"UploadFileByUrlInput!\" but got: {url: foo}.",
"locations": [
{
"line": 1,
"column": 35
}
]
@nickretallack
nickretallack / request
Last active October 12, 2015 03:21
curl copy of a mutation?
curl 'http://localhost:4000/graphql' -X POST -H 'Pragma: no-cache' -H 'Origin: http://localhost:4000' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36' -H 'content-type: application/json' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'Referer: http://localhost:4000/?' -H 'Connection: keep-alive' -H 'Content-Length: 280' --compressed
@nickretallack
nickretallack / fails.js
Last active October 11, 2015 22:33
"this" is null in my handler. Am I doing something wrong here?
import 'babel/polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
class FileUploadPage extends React.Component {
handleSubmit(event) {
event.preventDefault();
console.log(this.refs.url.value.trim())
}
@nickretallack
nickretallack / pokemon.js
Created October 8, 2015 06:57
Resolvers for a Pokemon GraphQL API
let Users = []
function getUser(name) {
return Users.find(user => user.name == name)
}
function upsertUser(name) {
let user = getUser(name)
if (!user) {
user = {