Skip to content

Instantly share code, notes, and snippets.

View ryanckulp's full-sized avatar
💭
retired / hacking

Ryan Kulp ryanckulp

💭
retired / hacking
View GitHub Profile
@ryanckulp
ryanckulp / README.md
Created November 12, 2023 22:26 — forked from leastbad/README.md
Choices.js Stimulus wrapper preview
View README.md

Choices.js Stimulus wrapper

https://joshuajohnson.co.uk/Choices/

Soon, this will be published as an NPM package, but there's an absence of documentation right now. It supports almost all functions from the original library; soon it will support 100% of them.

This wrapper adds Ajax pre-fetch search. Happens if controller has a data-search-path attribute.

Stimulus controller targets use new v2 syntax. Controller attaches a reference to itself on the element so that you can access the internal state from external scripts.

@ryanckulp
ryanckulp / SwordNFT.sol
Created January 25, 2022 04:35 — forked from Chmarusso/SwordNFT.sol
Learn how to create truly immutable smart contracts (Ethereum / EVM) that can hold all metadata and SVG images on-chain
View SwordNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
library Base64 {
string internal constant TABLE_ENCODE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
bytes internal constant TABLE_DECODE = hex"0000000000000000000000000000000000000000000000000000000000000000"
@ryanckulp
ryanckulp / KlaytnContractTemplate.sol
Last active January 15, 2022 09:48
Ooju.xyz -- Klaytn Smart Contract Template
View KlaytnContractTemplate.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
View fh_traversing_api_payloads.rb
# While in IRB, use the Ruby JSON library with:
require 'json'
# Then pass stringifed JSON content into it, surrounded by single quotes:
JSON.parse('stringified json here')
# In this lecture we learned a new Hash method:
hash.delete(:key_or_string)
# This will remove by the key AND the key's corresponding value from a hash.
View fh_looping_multi_single_line.rb
# Multi-line inner loop blocks
collection.each do |parameter_name|
# logic_here
end
# Single-line inner loop blocks
collection.each { |parameter_name| logic_here }
View fh_destructive_non_destructive_methods.rb
"string".gsub("g", "") # => "strin" (new value)
"string".gsub!("g", "") # => "strin" (modified original value)
View fh_accessing_hashes.rb
hash = { person: "Ryan" }
hash.stringify_keys
# => { "person" => "Ryan" } you should see this result after hitting enter
View fh_method_recipes_chained.rb
def create_full_name(first, last)
"#{first} #{last}"
end
name_length = create_full_name("Ryan", "Kulp").length