Skip to content

Instantly share code, notes, and snippets.

View yankchina's full-sized avatar
💭
Researching and Learning

yankchina yankchina

💭
Researching and Learning
View GitHub Profile
@yankchina
yankchina / gist:000b9db000e25892c7ef
Created February 1, 2015 01:30
获取 bash 脚本存储的路径
# 取脚本存储的路径,直接使用 $DIR
# see http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
@yankchina
yankchina / format_code.sh
Created September 4, 2014 06:25
astyle format code in all folders
find . -name *.c -exec astyle --style=allman --add-brackets --pad-oper --unpad-paren --pad-header --break-blocks --align-pointer=type {} \;
$table_name = $this -> table_name;
$sqlstring = "select * from $table_name where meeting_id = $meeting_id";
$db = new MyDB();
$result = $db -> query($sqlstring);
$row = $result->fetch_array(MYSQLI_ASSOC);
$meeting = new meeting();
while($finfo = $result->fetch_field())
{
$field_name = $finfo->name;
$meeting -> $field_name = $row[ $field_name ];
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Lantinghei SC Extralight}
\begin{document}
Hello world,欢迎来到 MacTex 的世界。
\end{document}
@yankchina
yankchina / basic.html
Created July 2, 2014 07:42
中文html
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<title>欢迎页面</title>
</head>
<body>
</body>
</html>
@yankchina
yankchina / read_xls.py
Created May 20, 2014 03:20
从XLS中读取信息,然后关闭该XLS文件
workbook = xlrd.open_workbook('1.xls')
sheet = workbook.sheet_by_index(0)
print sheet.nrows, sheet.ncols
teachers = []
for row_index in range(sheet.nrows):
teachers_name = sheet.cell_value(row_index,1)
teachers.append(teachers_name)
workbook.release_resources()
@yankchina
yankchina / bkpj_report1.html
Created May 9, 2014 10:47
Jinja中创建 rowspan 的样例
{% extends "base.html" %}
{% block title %}{{report.title}}{% endblock %}
{% block titledemo %}{{report.demo_string}}{% endblock %}
{% block content %}
<div class="table-responsive" id="report">
<table class='table table-striped'>
<thead>
{% for item in report.columes %}
<th>{{item}}</th>
{% endfor %}
prox="http://proxy.com:8080"
alias proxyon="export http_proxy=$prox && export https_proxy=$prox"
alias proxyoff='unset http_proxy && unset https_proxy'
echo "Turning http(s) proxies on"
proxyon
# investigate function is repeated here for portability but, we
# only define it if investigate isn't already a defined function
if ! type -t investigate &> /dev/null; then
function investigate {
#!/usr/bin/env python
# -*- coding: utf-8 -*-
## Versao 0.22
"""
Script de Backup MYSQL (backup_mysq.py)
Copyrighted by Nilton OS <jniltinho at gmail.com>
License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
@yankchina
yankchina / TestDemoController.php
Created July 27, 2013 13:48
db create command by QueryBuilder
$rows = Yii::app()->db->createCommand()
->from('tbl_Topic')
->where('status_code > 0')
->order('id desc')
->queryAll();
echo '<ul>';
foreach ($rows as $row ) {
echo '<li>'.$row['id'].'</li>';
}
echo '</ul>';