Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
retired / hacking

Ryan Kulp ryanckulp

💭
retired / hacking
View GitHub Profile
@ryanckulp
ryanckulp / SwordNFT.sol
Created Jan 25, 2022 — 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 Jan 15, 2022
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
View fh_method_recipes_non_chained.rb
def create_full_name(first, last)
"#{first} #{last}"
end
full_name = create_full_name("Ryan", "Kulp")
name_length = full_name.length