Skip to content

Instantly share code, notes, and snippets.

View TomiToivio's full-sized avatar

Tomi Toivio TomiToivio

View GitHub Profile
@phatduckk
phatduckk / Gistson.php
Created December 7, 2009 08:54
Embed a Gist in Wordpress
<?php
/*
Plugin Name: Gistson - Embedded Gist WP Plugin
Plugin URI: http://arin.me/blog/tag/gistson
Description: Use a shortcode [gist id="12345"] to embed A Gist from http://gist.github.com into your blog
Version: 0.1
Author: Arin Sarkissian
Author URI: http://arin.me
Copyright 2009 Arin Sarkissian
@mikejolley
mikejolley / gist:1604009
Created January 13, 2012 00:31
WooCommerce - Add a special field to the checkout, order emails and user/order meta
/**
* Add the field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';
/**
@mikejolley
mikejolley / gist:1860056
Created February 18, 2012 16:27
WooCommerce - Override billing fields
add_filter( 'woocommerce_billing_fields', 'custom_woocommerce_billing_fields' );
function custom_woocommerce_billing_fields( $fields ) {
// Over-ride a single label
$fields['billing_first_name']['label'] = 'Your label';
// Over-ride a single required value
$fields['billing_first_name']['required'] = false;
@kfox
kfox / sysctl.conf
Created February 29, 2012 17:32
Linux kernel tuning settings for large number of concurrent clients
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0
@TomiToivio
TomiToivio / django.po
Created April 14, 2012 16:07
Booktype Finnish Localization
# This file is distributed under the same license as the Booktype package.
#
# Tomi Toivio <tomi@flossmanuals.net>, 2012.
msgid ""
msgstr ""
"Project-Id-Version: Booktype\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-04-08 23:25+0200\n"
"PO-Revision-Date: 2012-04-14 18:59+0300\n"
"Last-Translator: Tomi Toivio <tomi@flossmanuals.net>\n"
@kurtpayne
kurtpayne / phpl.sh
Last active April 8, 2019 01:17
WordPress Unit Tests Jenkins Config
#!/bin/bash
find $1 \( -type f -and \( -name "*.php" -or -name "*.inc" -or -name "*.phtml" \) \) -exec php -l {} \; | grep -v "No syntax errors"
@zachflower
zachflower / tor_curl.php
Last active March 15, 2024 15:02
How To Anonymize PHP cURL Requests Using Tor
<?php
$ip = '127.0.0.1';
$port = '9051';
$auth = 'PASSWORD';
$command = 'signal NEWNYM';
$fp = fsockopen($ip,$port,$error_number,$err_string,10);
if(!$fp) { echo "ERROR: $error_number : $err_string";
return false;
@jplhomer
jplhomer / woocommerce-alter-cart-total.php
Last active July 10, 2021 01:53
Programmatically alter the WooCommerce cart discount total (and apply a new discount) before it's calculated through the woocommerce_calculate_totals hook. Add this code to your Wordpress functions.php file.
<?php
/**
* Programmatically alter the WooCommerce cart discount total (and apply a new discount) before it's calculated
* through the woocommerce_calculate_totals hook.
*
* For example, if you want to apply an arbitrary discount after a certain number of products in the cart,
* you can loop through that number and increment it as needed.
*
* In this example, I increment the discount by $8.85 after every 15 products added to the cart.
*
@ChromeOrange
ChromeOrange / gist:6533713
Created September 12, 2013 06:39
Add Bank Details under notes section from WooCommerce BACS settings in WooCommerce PDF Invoice
/**
* Add Bank Details under notes section from WooCommerce BACS settings
*
* Uses template tag [[PDFBANKDETAILS]]
*
* 1 - Add the template tag to template.php
* 2 - Add this code to the theme functions.php
* 3 - check invoice layout and modify CSS in template.php as necessary
*/
add_filter ( 'pdf_content_additional_content' , 'pdf_additional_content_bank_details' );
@ChromeOrange
ChromeOrange / gist:6533754
Created September 12, 2013 06:48
Example template.php file used in https://gist.github.com/ChromeOrange/6533569, adds tag [[PDFTERMSCONDITIONS]]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
@page {
margin: 480px 50px 150px 50px;
}
#header {
position: fixed;
left: 0px;