Skip to content

Instantly share code, notes, and snippets.

View ashsaraga's full-sized avatar
🌈
Building tools only I'll wind up using.

Ash Saraga ashsaraga

🌈
Building tools only I'll wind up using.
View GitHub Profile
@ashsaraga
ashsaraga / log_onClick.js
Created February 14, 2022 17:16
Quick script to `console.log()` any element clicked on.
window.onclick = e => {
console.log(e.target);
}
@ashsaraga
ashsaraga / tunejack.sh
Created November 13, 2019 17:53 — forked from xndc/tunejack.sh
Instant radio streaming script using the TuneIn API
#!/bin/bash
# tunejack.sh uses the TuneIn public API (at opml.radiotime.com) to search for
# a radio station, print out its details and try to play it somehow.
if [ "$#" -eq 0 ]; then
echo "$0: search for a radio station using the TuneIn API"
echo "Usage: $0 PATTERN"
exit 1
fi
<?php
function enable_page_excerpt() {
add_post_type_support('page', array('excerpt'));
}
add_action('init', 'enable_page_excerpt');
@ashsaraga
ashsaraga / sort_bymeta.php
Last active August 27, 2021 16:25
Sorts any archive by any meta field.
<?php
$the_key = ''; // Field Name to sort on
$args = array( 'meta_key' => $the_key,
'orderby' => 'meta_value',
'order' => 'ASC'
);
global $wp_query;
query_posts(
array_merge(
$wp_query->query,
@ashsaraga
ashsaraga / wpSSL.conf
Created May 31, 2018 20:23
Include in the site's `-le-ssl.conf` file to avoid redirect loop on HTTPS request.
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://example.com%{REQUEST_URI} [END,NE,R=permanent]
@ashsaraga
ashsaraga / setURL.php
Created May 31, 2018 20:17
Include in `wp-config.php` to set the URL for a WordPress install.
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
<?php
// Echo with lowercase first letter
echo lcfirst( post_type_archive_title( '', false ) );
// Echo as titled in WP
echo post_type_archive_title( '', false );
?>
@ashsaraga
ashsaraga / custom_tax.php
Created May 14, 2018 19:23
Custom taxonomies in WordPress.
/**
* Add custom taxonomies
*
* Additional custom taxonomies can be defined here
* http://codex.wordpress.org/Function_Reference/register_taxonomy
*/
function add_custom_taxonomies() {
// Add new "Locations" taxonomy to Posts
register_taxonomy('location', 'post', array(
// Hierarchical taxonomy (like categories)
@ashsaraga
ashsaraga / getParams.js
Created April 13, 2018 18:17
Will set the value for any input with a name attribute equal to a URL parameter key.
function setParams() {
// Sets the value of any field with a matching name attribute
var params;
params = getParams();
$.each( params, function( key, value ) {
var ref;
ref = $('input[name="'+key+'"');
if (ref.length) {
$(ref).val(value);
}