Skip to content

Instantly share code, notes, and snippets.

@KorvinM
KorvinM / wp-supress-private-posts.php
Last active June 25, 2022 15:20
WordPress: Remove private posts from the main query on the posts page
<?php
/* We can use the pre_get_posts action hook to modify a query before it's run.
* http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts*/
add_action( 'pre_get_posts', 'kvn_rem_pp' );
function kvn_rem_pp($query){
if(current_user_can ('read_private_posts') ){
/*restrict to the posts page main query.
*All other views (eg. category archives) unnaffected
*http://codex.wordpress.org/Function_Reference/is_home
*http://codex.wordpress.org/Function_Reference/is_main_query*/
@htp
htp / curl-websocket.sh
Last active May 14, 2024 21:24
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@mikejolley
mikejolley / functions.php
Last active February 5, 2024 15:33 — forked from claudiosanches/functions.php
WooCommerce - Hide shipping rates when free shipping is available.
<?php
/**
* Hide shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
@kdabir
kdabir / heredoc_json.bash
Last active January 11, 2024 02:25
json in heredoc in bash script alongwith variable substitution
_BUCKET_NAME="foo.example.com"
_POLICY=$(cat <<EOT
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadForGetBucketObjects",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
@tablekat
tablekat / main.ts
Created June 30, 2016 20:24
Making gmail push notifications to webhook
import * as request from 'request';
import * as fs from 'fs';
import * as readline from 'readline';
var google = require('googleapis');
var googleAuth = require('google-auth-library');
/*************** STEPS
- made a project on https://console.cloud.google.com/cloudpubsub/topicList?project=testmabs thing?
@jboursiquot
jboursiquot / dumptransport.go
Created January 17, 2017 13:52
Dump transport will dump Go HTTP request/response for debugging
package dumptransport
import (
"fmt"
"net/http"
"net/http/httputil"
)
type DumpTransport struct {
r http.RoundTripper
@ricjcosme
ricjcosme / dump-restore
Created September 13, 2017 17:33
DUMP / RESTORE PostgreSQL Kubernetes
DUMP
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
kubectl exec [pod-name] -- bash -c "pg_dump -U [postgres-user] [database-name]" > database.sql
RESTORE
// pod-name name of the postgres pod
// postgres-user database user that is able to access the database
// database-name name of the database
@jkutner
jkutner / atik-indi-phd2-raspbian-instructions.md
Last active January 19, 2024 19:09
Turn a Raspberry Pi into an Astrophotography Autoguider
@davidmroth
davidmroth / .bash_profile
Last active November 11, 2022 01:04
Homebrew Setup Mac M1
# !!! IMPORTANT
# Must point to the correct director or this entire script breaks
eval $(/opt/homebrew/bin/brew shellenv)
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/usr/local/google-cloud-sdk/path.bash.inc' ]; then . '/usr/local/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/usr/local/google-cloud-sdk/completion.bash.inc' ]; then . '/usr/local/google-cloud-sdk/completion.bash.inc'; fi
@davidmroth
davidmroth / compile_cpuminer-multi.sh
Last active February 25, 2021 00:08
Compile cpuminer-multi for Raspberry Pi
#!/bin/bash
#
# WARNING: CPU MINING IS UNPROFITABLE! (FOR HOBBY / EXPERIMENT / RESEARCH ONLY)
#
# RASPBERRY PI CPUMINER-MULTI SETUP SCRIPT
#
# RASPBERRY PI, DOGE, DOGECOIN, PROHASHING.COM, LITECOIN, MINING
#