Skip to content

Instantly share code, notes, and snippets.

View 1forh's full-sized avatar
🎯
Focusing

1forh

🎯
Focusing
View GitHub Profile
@1forh
1forh / generate.py
Created January 18, 2024 18:35
generate script
import os
import random
from PIL import Image
import json
import csv
# Get the current working directory
current_directory = os.path.dirname(os.path.abspath(__file__))
# Set the paths based on the current working directory
nfd-verify:3690058
@1forh
1forh / rarity-scores.js
Last active May 10, 2023 01:08
Algorand NFT - Rarity Scores
const rarityScore = getTraitRarityScore(nft, allNfts);
// https://medium.com/@nfthelperbot/understanding-nft-rarity-calculation-c724518efd63
// rarityScore = 1 ÷ ([Number of Items With That Trait Value] / [Total Number of Items in Collection])
function getTraitRarityScore(nft, allNfts) {
if (!nft?.metadata?.properties || Object.keys(nft.metadata.properties).length === 0) return 0;
const total = allNfts.length;
const traitFrequencies = getTraitFrequencies(allNfts);
const rarityScore = Object.entries(nft.metadata.properties).reduce((acc, [trait, value]) => {
@1forh
1forh / formatWordPressUrlsInString.js
Created December 23, 2022 15:56
Rewriting CMS URLS
export const formatWordPressUrlsInString = (str: string): string => {
if (!str) return '';
// from wizzy fields
const pageExp = `${process.env.NEXT_PUBLIC_WP_URL}/hoops_page`;
const postExp = `${process.env.NEXT_PUBLIC_WP_URL}/hoops_`;
const videoExp = `${process.env.NEXT_PUBLIC_WP_URL}/hoops_video`;
const teamExp = `${process.env.NEXT_PUBLIC_WP_URL}/hoops_team`;
const pageRegExp = new RegExp(pageExp, 'g');
const postRegExp = new RegExp(postExp, 'g');
<?php
add_action('admin_menu', 'admin_menu_mobile');
add_action('admin_menu', 'admin_menu_hoops');
add_action('admin_menu', 'admin_menu_football');
add_action('admin_menu', 'admin_menu_remove_items');
function admin_menu_remove_items () {
remove_menu_page('edit.php');
remove_menu_page('edit.php?post_type=page');
@1forh
1forh / skulis.js
Last active April 25, 2022 19:28
Skuli Frens - Algorand NFT Collection
export const frens = [
{
id: 544176827,
name: 'skuli frens #1',
unitname: 'sf001',
rank: 281,
arc69: { properties: { background: 'tealpink', skin: 'white', face: 'redeyes', head: 'bluedurag', body: 'redstrippedshirt' } },
image: 'https://ipfs.io/ipfs/bafkreiflc5bj3zdf5oe3dn2dmtqtyrzdroozgt7bi5nnwbun6wujthniuq#i',
href: 'https://www.nftexplorer.app/asset/544176827',
},
@1forh
1forh / usePDF.js
Last active November 15, 2021 21:44
React hook that generates a PDF based on an array of images and some other things
import { useEffect, useState, createContext, useContext } from 'react';
import jsPDF from 'jspdf';
import toast from 'react-hot-toast';
import toDataUrl from '../utilities/toDataUrl';
import { logEvent } from '../utilities/ga';
import useStorage from './useStorage';
import { STORAGE_KEYS } from '../config';
const CARD_WIDTH_DEFAULT = 66;
const CARD_HEIGHT_DEFAULT = 92;
@1forh
1forh / development.services.yml
Created October 4, 2019 13:24
Development services file for Drupal 8
# Local development services.
#
# To activate this feature, follow the instructions at the top of the
# 'example.settings.local.php' file, which sits next to this file.
parameters:
http.response.debug_cacheability_headers: true
twig.config:
debug: true
auto_reload: true
cache: false
@1forh
1forh / .htaccess
Created October 4, 2019 13:20
Drupal .htaccess file
#
# Apache/PHP/Drupal settings:
#
# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|install|make|module|profile|po|sh|.*sql|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock))$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>