Skip to content

Instantly share code, notes, and snippets.

View jimyhuang's full-sized avatar

Jimmy Huang jimyhuang

View GitHub Profile
@jimyhuang
jimyhuang / pet-tpe.php
Created May 30, 2015 07:13
pet-tpe.php
<?php
`curl -s "http://data.taipei/opendata/datalist/apiAccess?scope=resourceAquire&rid=f4a75ba9-7721-4363-884d-c3820b0b917c&format=csv" -o pet-tpe.csv`;
$data = file_get_contents('pet-tpe.csv');
$data = iconv('BIG5', 'UTF-8', $data);
file_put_contents('pet-tpe.csv', $data);
@jimyhuang
jimyhuang / pet-hsz.php
Created May 31, 2015 10:01
pet-hsz.php
<?php
$page = 0;
$output = '';
`echo '' > /tmp/animal`;
while(1) {
$url = 'http://animalprotection.hchg.gov.tw/sca/C/Animal.aspx?page='.$page;
$doc = new DOMDocument();
$new = new DOMDocument();
$html = @file_get_contents($url);
@jimyhuang
jimyhuang / ansible-playbook.bash
Created July 10, 2015 14:20
Ansible-playbook bash complete for specific directory
#!/bin/env bash
_ansible_playbook() {
local current_word=${COMP_WORDS[COMP_CWORD]}
local previous_word=${COMP_WORDS[COMP_CWORD - 1]}
if [[ "$current_word" == -* ]]; then
_ansible_complete_options "$current_word"
elif [[ "$current_word" == @* ]]; then
_ansible_target "$current_word"
@jimyhuang
jimyhuang / company-relation-line.php
Last active August 31, 2015 02:32
company-relation
<?php
$BASE = "/mnt/tmp";
$line = file_get_contents("$BASE/tmpline");
preg_match("/^\d+,/", $line, $matches);
$id_dest = trim($matches[0], ',');
$line = str_replace($matches[0], '', $line);
$meta = json_decode($line, TRUE);
msgid "File extensions"
msgstr "副檔名"
msgid "Taxonomy settings"
msgstr "分類設定"
msgid "Cacheable"
msgstr "可快取"
msgid "Processor"
<?php
civicrm_initialize();
$pid = 1; // payment processor id from system
$payment_processor = CRM_Core_BAO_PaymentProcessor::getPayment($pid, 'live');
$contribution_trxn_id = 'ABCDE12345';
if($payment_processor['payment_processor_type'] == 'ALLPAY' || $payment_processor['payment_processor_type'] == 'ALLPAYX'){
if(!empty($payment_processor['url_recur']) && !empty($payment_processor['user_name'])){
$processor = array(
'password' => $payment_processor['password']