Skip to content

Instantly share code, notes, and snippets.

CREATE TRIGGER insert_enc BEFORE INSERT ON dmhy_lists
FOR EACH ROW
BEGIN
IF UPPER(NEW.title) REGEXP '(繁|BIG5)' THEN
SET NEW.enc = '1';
ELSEIF UPPER(NEW.title) REGEXP '(简|GB)' THEN
SET NEW.enc = '2';
END IF;
END;
@faryne
faryne / gist:6dc6bd21fa4a295caae5
Created July 13, 2015 02:07
抓某花園的番組表 HTML
var web = require('webpage');
var client = web.create();
var fs = require('fs');
var file = "/var/www/tmp/dmhy_programme.html";
client.open('http://share.dmhy.org/cms/page/name/programme.html', function(status){
if (status === 'success')
{
@faryne
faryne / gist:e189654b20e212dd7b39
Created June 29, 2015 04:03
Clef Login 範例程式碼
<?php
class clef_login extends CI_Controller
{
private $app_id = ''; // 填寫拿到的app_id
private $app_secret = ''; // 填寫拿到的app_secret
public function __construct ()
{
parent::__construct();
session_start();
<?php
$api_key = 'xxxxxxxxxxxxx'; // 在註冊帳號後進入dashboard就可以看到了
$collection = 'sample'; // 資料放置/讀取的容器
// 存取API的路徑
$base_url = 'https://api.orchestrate.io/v0/'.$collection;
// 塞入資料
$key = 'sample'; // 存放資料時作為識別的key
$data_insert = array('a'=>'1', 'b'=>'2', 'c'=>'3');
@faryne
faryne / gist:4373b04f32615508e50b
Created December 13, 2014 06:28
GitLab Code Sample
<?php
// API的基本路徑
$url = 'http://example.com/api/v3';
// 因為要列出projects,所以加上/projects
$url .= '/projects';
// GitLab認證的方式有兩種,一種是把private_token放在query_string內,另一種是放在http header內
// 可以根據自己需求來決定怎麼用。
{"header":{"num":23690,"start":"0","perpage":"50"},"artworks":[{"id":"41013348","author_id":"4075119","site":"pixiv","title":"\u9032\u6483\u306e\u5341\u4e8c\u652f\/\u3042\u305f\u308a\u3081","thumbnail":"http:\/\/cdn-pixiv.maid.tw\/thumb\/41013348_12efb_thumb.jpg","r_18":"false","original_url":"http:\/\/www.pixiv.net\/member_illust.php?mode=medium&illust_id=41013348","page_url":"http:\/\/neko.maid.tw\/pixiv\/4075119\/41013348","photos":[{"image":"http:\/\/cdn-pixiv.maid.tw\/41013348_12efb.jpg","width":1490,"height":2100}],"tags":["\u9032\u6483\u306e\u5de8\u4eba","104\u671f\u751f","\u306a\u306b\u3053\u308c\u304b\u308f\u3044\u3044","\u8fb0\u5e74\u306a\u306e\u3067\u30d9\u30eb\u3055\u3093\u9802\u6234\u3057\u307e\u3059","\u79c1\u306f\u514e\u5e74\u306a\u306e\u3067\u30de\u30eb\u30b3\u3092\u9802\u304d\u307e\u3059\u3002","\u9149\u5e74\u306a\u306e\u3067\u30a2\u30cb\u3092\u3044\u305f\u3060\u3044\u3066\u3044\u304d\u307e\u3059","\u79c1\u306f\u5348\u5e74\u306a\u306e\u3067\u30b8\u30e3\u30f3\u3092\u9802\u304d\u307e\u3059\u30
tmpdir=tmp
if [ -d "$tmpdir" ]; then
rm -rf $tmpdir
fi
mkdir $tmpdir
height=2592
width=10
n=0
for f in *.jpg
do
@faryne
faryne / gist:2940664
Created June 16, 2012 09:18
求吐嘲
<?php
foreach($dailyDetail[$key1] as $key2=>$value){
if($key1==0){
if($key2==0 ||$key2==1 ||$key2==2|| $key2==3 || $key2==4 || $key2==5 ||$key2==$dailyRevenueNum-2||$key2==$d ailyRevenueNum-3||$key2==$dailyRevenueNum-1){
$dailyDetail[$key1][$key2]['style']='s41';
}
else{
$dailyDetail[$key1][$key2]['style']='s42';
}
@faryne
faryne / gist:2719136
Created May 17, 2012 14:05
根據使用者輸入的數字,產生一個以星號組成的塔狀圖形
import java.util.Scanner;
class test {
/**
* @param args
*/
public static void main(String[] args) throws java.lang.Exception {
// TODO Auto-generated method stub
try {
@faryne
faryne / gist:2694565
Created May 14, 2012 15:25
利用遞迴函數處理階乘的問題
import java.io.*;
import java.util.Scanner;
class test {
/**
* @param args
*/
public static void main(String[] args) throws java.lang.Exception {
// TODO Auto-generated method stub