Skip to content

Instantly share code, notes, and snippets.

View KSym04's full-sized avatar
👀
BUIDLing dApps ❤️

Ken Villanueva KSym04

👀
BUIDLing dApps ❤️
View GitHub Profile
@KSym04
KSym04 / downloadAll.js
Last active September 13, 2023 14:15
Appends a download button to images within a specified element + auto download it
/**
* appendDownloadButton - Appends a download button to images within a specified element.
* The download URL is modified to fetch the original (full-sized) image.
*
* @param {string} selector - The CSS selector of the parent element.
*/
function appendDownloadButton(selector) {
// Get all the images within the specified element
const images = document.querySelectorAll(`${selector} > a > img`);
@KSym04
KSym04 / ducktalks.js
Last active August 11, 2023 16:40
Let the duck talks
const generateDuck = () => {
const quacks = [
"quack", "quack-quack", "quackity", "quack!", "quack?", "quackity-quack",
"quaack", "quuuack", "qua-quack", "quack-quack-quack", "quaaack!",
];
const duckLength = [25, 30, 35, 40, 45, 50];
const quackCount = duckLength[Math.floor(Math.random() * duckLength.length)];
let duckSound = "";
@KSym04
KSym04 / contracts...AddressExample.sol
Created July 3, 2022 18:35
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.3+commit.8d00100c.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.1;
contract AddressExample {
address public myAddress;
function setAddress(address _address) public {
myAddress = _address;
}
@KSym04
KSym04 / Replace Howdy Text
Last active July 28, 2024 04:18
Replace Howdy Text
/**
* replace_gday
* Customizing WordPress backend G'day text.
*
* @since 1.0.0
*/
function replace_gday( $wp_admin_bar ) {
$my_account = $wp_admin_bar->get_node( 'my-account' );
$newtitle = str_replace( "G'day,", "Hello,", $my_account->title );
$wp_admin_bar->add_node( array(
// vars
$content = NULL;
settype( $content, 'string' );
jQuery(function($){
jQuery('#cpt_loadmore').click(function(){
var button = jQuery(this),
currentPaged = parseInt(button.attr('data-current-paged')),
maxNumPage = parseInt(button.attr('data-max-num-page')),
dataPosts = {
'action' : 'xyxyxyxyxy',
'paged' : currentPaged,
'posts_per_page' : button.attr('data-posts-per-page')
};
<?php
/**
* Register Ajax script
*
* @return void
*/
function theme_name_reg_script() {
wp_register_script( 'loadmore_custom_ajax', trailingslashit( get_stylesheet_directory_uri() ) . 'assets/js/loadmore.js', ['jquery'] );
@KSym04
KSym04 / WordPress RPC Ping Services List.txt
Created April 8, 2018 06:12
WordPress RPC Ping Services List
http://rpc.twingly.com
http://api.feedster.com/ping
http://api.moreover.com/RPC2
http://api.moreover.com/ping
http://www.blogdigger.com/RPC2
http://www.blogshares.com/rpc.php
http://www.blogsnow.com/ping
http://www.blogstreet.com/xrbin/xmlrpc.cgi
http://bulkfeeds.net/rpc
http://www.newsisfree.com/xmlrpctest.php
function add_wp_http_referer( $output ) {
if ( empty( $_SERVER['HTTP_REFERER'] ) ) {
$output = str_replace( '</form>', '<input type="hidden" name="_wp_http_referer" value="' . esc_url( get_the_permalink() ) . '"></form>', $output );
}
return $output;
}
add_filter( 'the_password_form', 'add_wp_http_referer' );
/* template caching fix WP 4.9 */
function template_caching_fix( WP_Screen $current_screen ) {
if ( ! in_array( $current_screen->base, array( 'post', 'edit', 'theme-editor' ), true ) )
return;
$theme = wp_get_theme();
if ( ! $theme )
return;
$cache_hash = md5( $theme->get_theme_root() . '/' . $theme->get_stylesheet() );