Skip to content

Instantly share code, notes, and snippets.

View yokada's full-sized avatar
🏠
Working from home

yokada yokada

🏠
Working from home
View GitHub Profile
var m = require('ti.paypal');
var appID = 'MY-LIVE-APP-ID'; // live App ID
var env = m.PAYPAL_ENV_LIVE; // live
var recip = '[email protected]'; // live
var btn = m.createPaypalButton({
// NOTE: height/width only determine the size of the view that the button is embedded in - the actual button size
// is determined by the buttonStyle property!
width : 278,
height : 60,
@yokada
yokada / gist:8973142
Last active August 29, 2015 13:56
test app formvalidator::lite
#!/usr/bin/env perl
package FormValidator::Lite::Constraint::MyVal;
use strict;
use warnings;
use FormValidator::Lite::Constraint;
use Data::Dumper;
rule 'CHECKBOX' => sub{
my $ages = $_;
@yokada
yokada / gist:8973558
Created February 13, 2014 11:31
FormValidator::Lite, Plack::Request, Hash::MultiValue
#!/usr/bin/env perl
package MyValidator;
use strict;
use warnings;
use FormValidator::Lite::Constraint;
use Data::Dumper;
rule 'CHECKBOX' => sub{
my $ages = $_;
@yokada
yokada / gist:2f61d953cf4952e6cb8f8b1de69bf714
Created December 30, 2016 18:37
Add extra charges for cash on delivery.
class My_Wc_Cart
{
protected $logger;
public function __construct()
{
$this->logger = new WC_Logger();
add_action('woocommerce_cart_calculate_fees', [$this, 'check_fees'], 10, 1);
}
<?php
function 問い詰める()
{
static $c = 0;
if ($c >= 3) {
return "実は私がやりました";
}
$c++;
}
@yokada
yokada / gist:3885e60f6cea605f7afd4e201cb2f6cc
Created January 19, 2017 07:13
Translates WooCommerce in order review page's comsumption tax label.
add_action('woocommerce_cart_tax_totals', 'check_taxes', 10, 2);
function check_taxes($tax_total, $cart)
{
foreach($tax_totals as $k=>$v) {
// Do translate all labels via wp-content/languages/plugins/woocommerce-ja.mo
$v->label = __($v->label, 'woocommerce');
}
return $tax_totals;
}
@yokada
yokada / gist:0d2f19b3829404b339401bc85adc2689
Last active January 19, 2017 16:22
payment cards php
<?php
class MyPayment
{
protected static cards_config = [
[
'type' => 'visaelectron',
'patterns' => [4026, 417500, 4405, 4508, 4844, 4913, 4917],
'format' => '/(\d{1,4})/',
'length' => [16],
// [ PHP :: Bug #73322 :: mb_convert_variables detects recursive reference incorrectly ]( https://bugs.php.net/bug.php?id=73322 )
$ php -v
PHP 7.1.0 (cli) (built: Dec 1 2016 08:13:15) ( NTS )
$ php -r '$x = ["a", "b"]; mb_convert_variables("UTF-8", "SJIS,EUC-JP", $x);'
PHP Warning: mb_convert_variables(): Cannot handle recursive references in Command line code on line 1
<?php
// woocommerceテンプレート呼び出しをフックする
add_filter('wc_get_template', 'my_wc_get_template', 10, 5);
function my_wc_get_template($located, $template_name, $args, $template_path, $default_path)
{
// 変更したいテンプレートを指定する
$templates = [
'myaccount/form-login.php',
@yokada
yokada / gist:f26e47efc3b225760d715a30fd7d487a
Created February 11, 2017 22:32
Result set of 2016 General Election Trump vs Clinton
#!/bin/sh
curl "http://elections.huffingtonpost.com/pollster/api/charts/2016-general-election-trump-vs-clinton.csv" > ~/test.csv