Skip to content

Instantly share code, notes, and snippets.

View techb's full-sized avatar

K.B. Carte techb

View GitHub Profile
:: https://stackoverflow.com/questions/15885132/file-folder-chooser-dialog-from-a-windows-batch-script
@echo off
set dialog="about:<input type=file id=FILE><script>FILE.click();new ActiveXObject
set dialog=%dialog%('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);
set dialog=%dialog%close();resizeTo(0,0);</script>"
for /f "tokens=* delims=" %%p in ('mshta.exe %dialog%') do set "file=%%p"
echo selected file is : "%file%"
// When the user scrolls the page, execute myFunction
window.onscroll = function() {myFunction()};
// Get the header
var header = document.getElementById("myHeader");
// Get the offset position of the navbar
var sticky = header.offsetTop;
var stickyBottom = header.offsetBottom;
states = [
'Alabama',
'Alaska',
'Arizona',
'Arkansas',
'California',
'Colorado',
'Connecticut',
'Delaware',
'District of Columbia',
<?php
/*
Template Name: AR Example
Don't use get_header() or get_footer()
this page needs to be 'blank' so the cam/ar view takes the whole
screen/canvas and no styles are applied except the ones we define here.
Some info and docs:
General
ssh -L 33666:127.0.0.1:3306 <USER>@<IP OR DOMAIN>
@techb
techb / add-admin-column.php
Last active February 15, 2022 23:33
wordpress function to add a new column to admin list view of selected post-type and field
<?php
// yoink: https://wordpress.stackexchange.com/a/379641
// add this to functions.php
function add_admin_column($column_title, $post_type, $cb){
// Column Header
add_filter( 'manage_' . $post_type . '_posts_columns', function($columns) use ($column_title) {
$columns[ sanitize_title($column_title) ] = $column_title;
return $columns;
} );
@techb
techb / export_wp_db.php
Last active March 16, 2022 17:07
Exports wp db using wpcli. Found not working for CloudWays, something to do with file paths?
<?php
function validate_export( $filename ){
$ext = explode(".", $filename);
if( $ext[1] && $ext[1] != "sql" ){
return false;
}
if( $ext[2] && $ext[2] != "gz" ){
return false;
}
@techb
techb / zip2city.py
Created January 7, 2022 21:00
gets the cites associated with the given zipcode
# requires uszipcode
# $ pip install uszipcode
# zip.csv is a list of only zipcodes, one per each line
from sqlalchemy.sql.operators import op
from uszipcode import SearchEngine
from pprint import pprint
rtn = []
zips = []
@techb
techb / template-home.php
Created April 26, 2022 16:01
WordPress Frontpage blog list pagination. How to use pagination with WP_Query.
<?php
/**
* Template Name: Homepage
*/
get_header();
// since this is the Front-Page we need to use "page" instead of "paged"
$paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
$args = array(
@techb
techb / GravityForms_Disable_AnchorScroll.md
Created May 3, 2022 20:52
Gravity Forms stop scrolling on multi-page ajax forms

When using a gravity form (multi-page, ajax) as a sticky modal for the bottom of the page, the generated anchor tag used to scroll interfears with the page scrolling.

The effect is when the user clicks the next button, the new page loads via ajax in the modal, but the gf js is trying to scroll to the top where the generated anchor tag is. But that's at the bottom of the page, so the page will auto scroll trying to keep up.

We can disable this behaviour with hooks. Add this to your themes function.php

Global disable add_filter( 'gform_confirmation_anchor', '__return_false' );