Skip to content

Instantly share code, notes, and snippets.

View nozzlegear's full-sized avatar
🌸
There is no theory, only the knowing.

Joshua Harms nozzlegear

🌸
There is no theory, only the knowing.
View GitHub Profile
@nozzlegear
nozzlegear / regex.js
Last active May 30, 2016 00:26
Regex basics
// [0] the entire string, "require('my-module')"
// [1] require('
// [2] my-module
// [3] ')
const captures = /(require\s*\(["'])(.*)(["']\s*\))/ig.exec(replacement);
const requireStart = captures[1];
const requireEnd = captures[3];
let moduleName = captures[2];
// Use parentheses to denote capture groups, e.g. /(require)/ig will capture the word "require".
@nozzlegear
nozzlegear / Contract Killer 3.md
Last active February 16, 2017 22:42 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@nozzlegear
nozzlegear / email-widget.js
Last active July 14, 2020 02:07
This is an example email capturing widget, used to demonstrate the power of Shopify's script tags to add dynamic functionality to a Shopify store front. Learn more about using Shopify script tags with The Shopify Development Handbook at https://nozzlegear.com/shopify-development-handbook.
(function ()
{
//Build a pseudo-class to prevent polluting our own scope.
var api = {
Settings: {},
Vox: {},
Start: function ()
{
//Get the *.myshopify.com domain
var shop = Shopify.shop;
@nozzlegear
nozzlegear / CreateSnippet.cs
Created October 27, 2015 20:49
This is a quick and dirty example to show how you can add and replace a liquid snippet in a Shopify theme's layout file via the Asset API.
//Using ShopifySharp from https://github.com/nozzlegear/ShopifySharp
using ShopifySharp;
...
public void MySnippetCreatorMethod()
{
var service = new ShopifyAssetService(myShopifyUrl, accessToken);
var themeId = 123456;
var asset = new ShopifyAsset()
@nozzlegear
nozzlegear / AccountController.cs
Created September 20, 2015 21:59
A quick try/catch for the login method that will help you determine if a user has uninstalled your Shopify app.
//Try to get the user's subscription charge. If it returns a 404 "Not Found" message,
//then their subscription is no longer valid.
try
{
charge = await service.GetAsync(user.ShopifyChargeId.Value);
}
catch (ShopifyException e)
when (e.Message.Equals("not found", StringComparison.OrdinalIgnoreCase))
{
await DeleteChargeId(user);
@nozzlegear
nozzlegear / MainPage.xaml
Last active August 29, 2015 14:13
For Windows
<Page
x:Name="pageRoot"
x:Class="Space_Butterfly.MainPage"
DataContext="{Binding Items, RelativeSource={RelativeSource Self}}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Space_Butterfly"\
xmlns:common="using:Space_Butterfly.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.ApplicationModel.Background;
using ButterflyCore;
using Windows.UI.Notifications;
using Windows.Data.Xml.Dom;
using ButterflyCore.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
@nozzlegear
nozzlegear / YouTube.cs
Created January 15, 2015 20:08
A C# model for JSON YouTube response
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ButterflyCore.Models
{
public class Thumbnail
{
@nozzlegear
nozzlegear / jQuery.postJson.d.ts
Last active August 29, 2015 14:11
TypeScript definition file for $.postJson
/// <reference path="../typings/jquery/jquery.d.ts" />
// Extend the jQueryAjaxSettings interface that should be defined at /scripts/typings/jquery/jquery.d.ts
// Don't have that file? Install with NuGet: install-package jquery.typescript.definitelytyped
interface JQueryAjaxSettings {
/**
* Load data from the server using a HTTP POST request.
*
* @param url A string containing the URL to which the request is sent.