Skip to content

Instantly share code, notes, and snippets.

@aschroder
aschroder / gist:9060312
Last active August 29, 2015 13:56
OpenSSL command to split the private key out of the Xero .p12 partner certificate on OSX
openssl pkcs12 -in entrust-client.p12 -nocerts -nodes -out entrust-private.pem
# this command from here: http://developer.xero.com/documentation/getting-started/partner-applications/
# openssl pkcs12 -in entrust-client.p12 -nocerts -out entrust-private.pem
# did not work
@aschroder
aschroder / gist:2469319
Created April 23, 2012 07:17
Magento REST API PHP test harness (admin and customer)
<?php
/**
* Copyright Magento 2012
* Example of products list retrieve using Customer account via Magento
REST API. OAuth authorization is used
*/
$callbackUrl = "http://yourhost/oauth_customer.php";
$temporaryCredentialsRequestUrl =
"http://magentohost/oauth/initiate?oauth_callback=" .
urlencode($callbackUrl);
@aschroder
aschroder / gist:2325562
Created April 7, 2012 05:35
dx3webs debug info from EU server
traceroute demo8.dx3webs.com
traceroute to demo8.dx3webs.com (213.175.202.192), 30 hops max, 60 byte packets
<snip>
4 178.236.0.220 (178.236.0.220) 0.702 ms 0.870 ms 178.236.1.5 (178.236.1.5) 0.648 ms
5 178.236.0.205 (178.236.0.205) 1.002 ms 1.210 ms 178.236.0.201 (178.236.0.201) 1.139 ms
6 ae3.dub40.ip4.tinet.net (141.136.96.137) 1.537 ms ae1.dub40.ip4.tinet.net (141.136.96.129) 1.381 ms 178.236.0.203 (178.236.0.203) 0.893 ms
7 xe-2-0-0.lon21.ip4.tinet.net (89.149.185.233) 18.913 ms ae1.dub40.ip4.tinet.net (141.136.96.129) 1.199 ms xe-9-2-0.lon21.ip4.tinet.net (89.149.180.106) 11.286 ms
8 xe-7-3-0.lon21.ip4.tinet.net (89.149.180.89) 14.757 ms as29550-gw.ip4.tinet.net (77.67.67.138) 12.349 ms 12.618 ms
@aschroder
aschroder / TestOptimizations.java
Created March 14, 2012 08:13
Test some Java loop optimization cf. http://pastebin.com/4edtQXmV
public class TestOptimizations {
private static final String str = "abcdefg";
private static long nothing = 0;
public static void main(String[] args) {
// try swapping the order of these first two calls.
System.out.println("inline (ms): " + runLoopInline(10000000));
System.out.println("precalc (ms): " + runLoopPrecalc(10000000));
@aschroder
aschroder / woocommerce_template_functions.php
Created October 28, 2011 05:15
Hack Woocommerce to add product custom fields - updated
<form action="<?php echo esc_url( $_product->add_to_cart_url() ); ?>" class="variations_form cart" method="post">
<table class="variations" cellspacing="0">
<tbody>
<?php foreach ($attributes as $name => $options) : ?>
<tr>
<td><label for="<?php echo sanitize_title($name); ?>"><?php echo $woocommerce->attribute_label($name); ?></label></td>
// START HACK HERE
<?php if(is_array($options) && $options[0] == "CUSTOM_TEXT") : ?>
@aschroder
aschroder / woocommerce_template_functions.php
Created October 10, 2011 02:14
Hack Woocommerce to add product custom fields
<form action="<?php echo esc_url( $_product->add_to_cart_url() ); ?>" class="variations_form cart" method="post">
<table class="variations" cellspacing="0">
<tbody>
<?php foreach ($attributes as $name => $options) :?>
<tr>
<td><label for="<?php echo sanitize_title($name); ?>"><?php echo $woocommerce->attribute_label($name); ?></label></td>
// Start custom code to add custom text field
<?php if(is_array($options) && $options[0] == "CUSTOM_TEXT") : ?>
<td> <input type="text" id="<?php echo esc_attr( sanitize_title($name) ); ?>" name="attribute_<?php echo sanitize_title($name); ?>"/></td>
@aschroder
aschroder / tracepath-crucial-magespedtest.com
Created August 21, 2011 01:09
Tracepath from US West MageSpeedtest.com server on EC2 to Crucial Magento host
~$ tracepath 50.23.69.213
1: ip-10-170-99-240.us-west-1.compute.internal 0.144ms pmtu 1500
1: ip-10-170-96-3.us-west-1.compute.internal 0.487ms asymm 2
1: ip-10-170-96-3.us-west-1.compute.internal 0.418ms asymm 2
2: 216.182.236.162 0.611ms
3: no reply
4: 72.21.222.20 3.515ms asymm 9
5: 72.21.222.207 2.198ms
6: 72.21.222.207 2.181ms asymm 5
7: te1-7.bbr01.eq01.sjc01.networklayer.com 3.845ms