rails new demo-rails-gql --api
bundle add graphql
rails generate graphql:install
rails g model product title description options
rails g model variant title option1 option2 option3 sku product:references
rails db:migrate
rails g graphql:object product
rails g graphql:object variant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Home</title> | |
<script> | |
function checkStatus() { | |
var queryString = parseQueryString(); | |
if (queryString['name']) { | |
var result = document.getElementById('result'); | |
result.innerHTML = 'Form submitted'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):002> h = {}.compare_by_identity | |
=> {} | |
irb(main):003> h['a'] =3 | |
=> 3 | |
irb(main):004> h['a'] =5 | |
=> 5 | |
irb(main):005> h | |
=> {"a"=>3, "a"=>5} | |
irb(main):006> h[:a] = 1 | |
=> 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async (secret, body) => { | |
let enc = new TextEncoder("utf-8"); | |
let algorithm = { name: "HMAC", hash: "SHA-256" }; | |
let key = await crypto.subtle.importKey("raw", enc.encode(secret), algorithm, false, ["sign", "verify"]); | |
let signature = await crypto.subtle.sign(algorithm.name, key, enc.encode(body)); | |
let hexString = Array.from(new Uint8Array(signature)).map(byte => byte.toString(16).padStart(2, '0')).join(''); | |
console.log(hexString); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
import zipfile | |
con = sqlite3.connect("NoteStore.sqlite") | |
res = con.execute("select Z_PK, ZDATA from ZICNOTEDATA") | |
for row in res.fetchall(): | |
print(f"ID: {row[0]}") | |
# this is a protobuf doc but the text is usually readable | |
temp_file_name = f"doc{row[0]}.txt.zip" | |
f = open(temp_file_name, "wb") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { ActionFunctionArgs, UploadHandler } from "@remix-run/node"; | |
import { | |
json, | |
unstable_createMemoryUploadHandler as createMemoryUploadHandler, | |
unstable_parseMultipartFormData as parseMultipartFormData, | |
} from "@remix-run/node"; | |
import { useFetcher } from "@remix-run/react"; | |
type ActionData = { | |
errorMsg?: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:bullseye | |
ENV DEBIAN_FRONTEND=noninteractive | |
# Install the minimum amount of packages required for testing, which currently means: | |
# - minimal set of packages required to run Python 3 | |
# - shipping versions of uWSGI and nginx (so that config files are put in the right places) | |
# Also, make sure we have a sane default locale inside the container | |
RUN apt-get update \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundle config build.puma --with-pkg-config=$(brew --prefix [email protected])/lib/pkgconfig | |
bundle install --redownload |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream app { | |
# Path to Puma SOCK file, as defined previously | |
# server unix:/home/deploy/appname/shared/sockets/puma.sock fail_timeout=0; | |
server unix:/Users/ericwalker/src/github.com/ewalk153/sample-rails-app/shared/sockets/puma.sock fail_timeout=0; | |
} | |
server { | |
listen 4000; | |
server_name localhost; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream backend { | |
server localhost:3000; | |
} | |
server { | |
listen 9000; | |
server_name localhost; | |
root /path_of_rails_app/public; | |
try_files $uri/index.html $uri @app; |
NewerOlder