Skip to content

Instantly share code, notes, and snippets.

View charlesemarsh's full-sized avatar

Charles Marsh charlesemarsh

  • Shopify Expert
  • Cambridge, UK
View GitHub Profile
@phawk
phawk / graphql.js
Created August 23, 2019 17:01
Lambda Shopify graphql proxy endpoint
const https = require("https")
const fetch = require("isomorphic-fetch")
const Account = require("./models/account")
const authenticated = require("./lib/auth")
exports.handler = authenticated(async (event, context) => {
const { id: shopId, shopifyToken } = context.account
try {
const resp = await fetch(`https://${shopId}/admin/api/2019-07/graphql.json`, {
@mankind
mankind / rails-jsonb-queries
Last active May 23, 2024 06:47
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@telent
telent / sagepay-admin.rb
Created November 4, 2010 17:29
Talking to Sagepay Reporting & Admin API from Ruby
require 'patron'
require 'time'
require 'active_support/core_ext/hash.rb'
require 'digest/md5'
require 'nokogiri'
module SagePay;end
class SagePay::Admin
def initialize(args)