Skip to content

Instantly share code, notes, and snippets.

View kasparsd's full-sized avatar

Kaspars Dambis kasparsd

View GitHub Profile
@kasparsd
kasparsd / custom-post-taxonomy-permalinks.php
Created June 13, 2012 15:47
Create permalink structure URLs for custom post types that include all parent terms from a custom taxonomy
<?php
/*
Term Archive Pages:
- http://example.com/recipes/dinner/
- http://example.com/recipes/breakfast,brunch/
Single Recipe Pages:
- http://example.com/recipes/dinner/soup-title/
@kasparsd
kasparsd / wordpress-plugin-svn-to-git.md
Last active April 17, 2024 12:35
Using Git with Subversion Mirroring for WordPress Plugin Development
@kasparsd
kasparsd / enable-post-type-aps.php
Last active December 15, 2015 19:19
Enable post_type support for Automatic Post Scheduler plugin
<?php
// Called from $time_of_post = aps_get_nearest_open_time( $data );
function aps_get_nearest_open_time( $data ) {
// get furthest scheduled post
$post = get_posts( array(
'numberposts' => 1,
'post_status' => 'future',
'post_type' => $data['post_type']
@kasparsd
kasparsd / disable-title-rewrite-wordpress-seo.php
Last active November 22, 2023 12:13
Disable page title rewrite feature in WordPress SEO plugin
<?php
// Remove the wp_title filter
add_action( 'init', 'remove_wpseo_title_rewrite' );
function maybe_remove_wpseo_title_rewrite() {
global $wpseo_front;
remove_filter( 'wp_title', array( $wpseo_front, 'title' ), 15 );
}
@kasparsd
kasparsd / logitech-c270-lsusb-webcam
Created June 16, 2013 20:46
Logitech, Inc. Webcam C270, output of `lsusb -v`
Bus 001 Device 004: ID 046d:0825 Logitech, Inc. Webcam C270
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 ?
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x046d Logitech, Inc.
@kasparsd
kasparsd / gobots.sh
Created June 28, 2013 08:14
Create a GoAccess report of bots crawling your sites
#!/bin/sh
# Note: You need to run this as a user who has access to those log files
cat /var/log/nginx/access.log* | grep bot | goaccess -a
# Examples
#
# 1) Send output to logs.html
@kasparsd
kasparsd / mobius-camera-usb-info.txt
Created August 21, 2013 12:03
USB device info of Mobius Action Camera (firmware 0.42)
High Speed device @ 4 (0xFD120000): ............................................. Miscellaneous/Common Class device: "Mobius\000"
Port Information: 0x1018
Not Captive
External Device
Connected
Enabled
Number Of Endpoints (includes EP0):
Total Endpoints for Configuration 1 (current): 3
Device Descriptor
Descriptor Version Number: 0x0200
@kasparsd
kasparsd / microsoft-camera-usb-profile.txt
Created August 21, 2013 12:17
USB profile of Microsoft USB camera
High Speed device @ 4 (0xFD120000): ............................................. Miscellaneous/Common Class device: "Microsoft\256 LifeCam Cinema(TM)"
Port Information: 0x1018
Not Captive
External Device
Connected
Enabled
Number Of Endpoints (includes EP0):
Total Endpoints for Configuration 1 (current): 4
Device Descriptor
Descriptor Version Number: 0x0200
@kasparsd
kasparsd / parse-html-json-blog-posts.php
Created August 29, 2013 20:15
Parsing HTML using querypath library and creating a JSON feed of all blog posts
<?php
require 'querypath/src/qp.php';
$posts = array();
$map = array(
'kl.' => ' ',
'.' => ' ',
'des' => 'dec',
@kasparsd
kasparsd / tag-cloud-count-color.php
Last active December 30, 2015 12:09
Add tag counts as classname in the $range of 1 to 4 depending of the post count in each category
<?php
add_filter( 'wp_generate_tag_cloud', 'maybe_color_tag_cloud', 10, 3 );
function maybe_color_tag_cloud( $cloud, $tags, $args ) {
$a = array();
$counts = array();
$range = 4;