Skip to content

Instantly share code, notes, and snippets.

View ccashwell's full-sized avatar
🤔
¯\_(ツ)_/¯

Chris Cashwell ccashwell

🤔
¯\_(ツ)_/¯
View GitHub Profile
@ccashwell
ccashwell / getDiscountCode.html
Last active January 19, 2023 15:25
Autofill Discount Code from Shopify URL
<script>
/* Put this in theme.liquid, preferably right before "</body>" */
(function() {
var discountParam = document.location.search.match(/discount=(\w+)/);
if (discountParam && discountParam.length > 1) {
document.cookie = discountParam[0];
}
})();
</script>
@ccashwell
ccashwell / helpers.ts
Created November 29, 2021 17:18
HardHat Test Helpers
import * as hre from "hardhat";
import { RequestArguments } from "hardhat/types";
import { BigNumber } from "@ethersproject/abi/node_modules/@ethersproject/bignumber";
import { Block } from "@ethersproject/abstract-provider";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
// Mine the next block
export async function mineBlock(): Promise<void> {
await rpc({ method: "evm_mine" });
@ccashwell
ccashwell / restrict_by_request_type.rb
Last active November 29, 2018 22:32
CanCan Authorization: Restrict resources by request format JSON
# Lock down controller actions with CanCan based on request format.
class Ability
include CanCan::Ability
def initialize(user, format=nil)
user ||= User.new
can :index, Model if format == "application/json"
end
end
@ccashwell
ccashwell / cattributes.csv
Last active July 20, 2018 04:55 — forked from eugeneotto/gist:192af598a911318b5f43b3f3bd1a0e71
List of CryptoKitties cattribute values and masks
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 5 columns, instead of 1. in line 7.
mask_value,gene_value,cattribute_name,cattribute_type,recessiveness
0x000000000000000000000000000000000000000000000000000000000000001f,0x000000000000000000000000000000000000000000000000000000000000000b,himalayan,body,D
0x00000000000000000000000000000000000000000000000000000000000003e0,0x0000000000000000000000000000000000000000000000000000000000000160,himalayan,body,R1
0x0000000000000000000000000000000000000000000000000000000000007c00,0x0000000000000000000000000000000000000000000000000000000000002c00,himalayan,body,R2
0x00000000000000000000000000000000000000000000000000000000000f8000,0x0000000000000000000000000000000000000000000000000000000000058000,himalayan,body,R3
0x000000000000000000000000000000000000000000000001f000000000000000,0x0000000000000000000000000000000000000000000000008000000000000000,caffeine,eyes,D
0x00000000000000000000000000000000000000000000003e0000000000000000,0x0000000000000000000000000000000000000000000000100000000000000000,caffeine,eyes,R1
0x0000000000000000000000000000000000000000000007
@ccashwell
ccashwell / ABI.json
Last active February 16, 2018 18:40
Transferring Mythereum Cards with MyEtherWallet
[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenId","type":"uint256"}],"name":"approvedFor","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutabil
@ccashwell
ccashwell / github_ssh.sh
Created November 8, 2012 22:29
Bash Scripting: OAUTH2 Authorization, Generating SSH keys and Adding Keys to GitHub
#!/bin/bash
# This is an example of OAUTH2 authorization via GitHub and adding a new (optionally generated) SSH key to your account.
# If generated, the key is put in the default location with no password. Security is obviously relaxed for brevity's sake. Enjoy.
read -p "GitHub Username: " uname
read -s -p "GitHub Password: " passwd
if [[ "$uname" == "" || "$passwd" == "" ]]; then
echo -e "\n\nCan't set up your GitHub SSH keys without authorization. You're on your own now, champ."
exit 1
fi
@ccashwell
ccashwell / ProjectWyvernAudit.md
Created January 2, 2018 20:14
Audit of the Project Wyvern Platform's Solidity Smart Contracts

Audit: Project Wyvern

Completed on January 2, 2018 @ 7358a6c065

Abstract

Project Wyvern is a decentralized item exchange platform (the “Platform”) comprised of three primary components: (1) The WYV Token; (2) The Wyvern Exchange; and (3) The Wyvern Decentralized Autonomous Organization (DAO). This goal of this audit has been to ascertain the overall security of the Platform. In pursuit of that goal, this author has reviewed the Solidity source code of all relevant Smart Contracts, deployed and tested a live version of the Platform on the Ethereum Main Network.

This audit is presented as a Code Review which reflects a deep analysis of the Smart Contracts that comprise the Platform. It is broken into sub-sections, each of which relate to a single Smart Contract. Each sub-section includes a link to the Smart Contract’s Solidity source code as it stood at the ti

@ccashwell
ccashwell / QuillTable.jsx
Last active November 2, 2017 22:35
Building Proof-of-Concept Table Support for Quill.js using React Components
import Quill from 'quill'
import TableComponent from 'TableComponent'
import ReactDOM from 'react-dom'
const QuillEmbed = Quill.import('blots/block/embed');
class QuillTable extends QuillEmbed {
static create(values) {
let node = super.create(values);
package com.some.api.support;
import com.some.domain.User;
public class AuthenticationResult {
private String token;
private User user;
public String getToken() {
return token;
@ccashwell
ccashwell / env_setup.sh
Last active December 16, 2015 16:39
WIP
#!/bin/bash
#
# This script will get a Chris-approved environment setup done right, with just one command. Enjoy.
echo -e "##### Installing: RVM #####\n"
curl -L https://get.rvm.io | bash -s stable --autolibs=3 --rails
echo -e "##### Installing: Homebrew #####\n"
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"