Skip to content

Instantly share code, notes, and snippets.

Avatar

Jimmy Huang jimyhuang

View GitHub Profile
View 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);
View 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 Jul 10, 2015
Ansible-playbook bash complete for specific directory
View ansible-playbook.bash
#!/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"
View company-relation-line.php
<?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);
View drupal-lastest-translation.po
msgid "File extensions"
msgstr "副檔名"
msgid "Taxonomy settings"
msgstr "分類設定"
msgid "Cacheable"
msgstr "可快取"
msgid "Processor"
View allpay_api_sample.php
<?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']