Skip to content

Instantly share code, notes, and snippets.

View kilfu0701's full-sized avatar

kilfu0701 kilfu0701

  • Trend Micro
  • Japan & Taiwan
View GitHub Profile
# ~/.bashrc
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias rm='rm -i'
alias ccc="sudo chmod 775 -R"
alias ddd="sudo chown apache:nobody -R"
alias eee="sudo chmod 777 -R"
alias mydiff='diff -ENwbur'
alias ntt='netstat -nt'
<?php
/**
* http://www.php.net/manual/en/datetime.diff.php
* (PHP 5 >= 5.3.0)
*
* Calculate datetime interval.
*/
// Set timezone if need.
date_default_timezone_set('Asia/Taipei');
@kilfu0701
kilfu0701 / gist:6694691
Created September 25, 2013 03:03
override datepicker's result.
<html>
<head>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
</head>
<body>
<form id="FormSet" action="/abc" method="get" accept-charset="utf-8">
<input type="text" name="start_date" id="datepicker1" value="">
<input type="submit" value="Search it!">
@kilfu0701
kilfu0701 / pagito2.ctp
Last active December 23, 2015 21:19
CakePHP 1.x : pagination elements. Put this file in app/view/elements/ directory.
<?php
/**
* Need '$pagitor2' variable.
* Example:
* $pagitor2 = array(
* 'total' => 100,
* 'limit' => 15,
* 'page' => 2, // current page
* //'range' => 3, // optional.
* //'method' => 'get' // opt
@kilfu0701
kilfu0701 / gist:7192862
Created October 28, 2013 07:49
R mysql connect testing...
## base.R
library(DBI)
library(RMySQL)
DB_CONFIG <- list(
local = list(driver = 'MySQL', user = 'root', password = '', host = 'localhost'),
production = list(driver = 'MySQL', user = 'root', password = '', host = 'localhost')
)
db_con <- function(environ, db) {
@kilfu0701
kilfu0701 / django_export_csv.py
Last active December 27, 2015 13:19
Use django to export a CSV file.
# in some views.py, to serve a csv file in Django.
# -*- coding: utf-8 -*-
import csv
from django.http import HttpResponse
def donwload_csv(request):
# change export csv formatting by request parameter. ( url?encode=utf-8 )
encode = request.GET.get('encode', 'big5')
@kilfu0701
kilfu0701 / solr_date2tdate.php
Created December 30, 2013 03:54
Transfer date to solr date time.
<?php
// need to set a valid timezone.
date_default_timezone_set('Asia/Taipei');
/**
* @param
* $string: date string, '2013-12-12 01:23:44'
*
* @return:
* string type => '2013-12-12T01:23:44Z'
@kilfu0701
kilfu0701 / _install.sh
Last active April 13, 2017 02:19
install python 2.7.6 from source. ( CentOS )
## install deps if need
yum -y install openssl-devel readline-devel bzip2-devel sqlite-devel zlib-devel ncurses-devel db4-devel expat-devel
## if build from python src
cd ~
mkdir src
cd src
wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
tar zxvf Python-2.7.6.tgz
cd Python-2.7.6
@kilfu0701
kilfu0701 / c_chat_vote.user.js
Last active August 29, 2015 14:01
c_chat_vote.user.js
// ==UserScript==
// @name Vote counting for C_Chat@PTT
// @namespace https://github.com/kilfu0701
// @description Counting votes.
// @match http://www.ptt.cc/bbs/C_Chat/*.html
// @match http://www.ptt.cc/bbs/Test/*.html
// @run-at document-end
// @include *
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @version 1.4
from django import http
try:
from django.conf import settings
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS
XS_SHARING_ALLOWED_METHODS = settings.XS_SHARING_ALLOWED_METHODS
XS_SHARING_ALLOWED_HEADERS = settings.XS_SHARING_ALLOWED_HEADERS
XS_SHARING_ALLOWED_CREDENTIALS = settings.XS_SHARING_ALLOWED_CREDENTIALS
except AttributeError:
XS_SHARING_ALLOWED_ORIGINS = '*'