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:5122433
Created March 9, 2013 03:51
用AFNetworking库获取远端的JSON数据,其PHP文件需要增加 header('Content-type: application/json');
NSURL *url = [NSURL URLWithString:@"http://localhost:8080/tce/testsuites/json-sample.php"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"success: %@",[JSON valueForKey:@"name"]);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"fail: %@", [error userInfo]);
}];
[operation start];
@yankchina
yankchina / m130726_080918_create_sample_table.php
Last active December 20, 2015 06:49
yii create table model
$this->createTable('tbl_topic',
array(
'id' =>'pk',
'title' =>'string NOT NULL',
'description' => 'text COMMENT \'说明\'',
'project_id' => 'int(11) DEFAULT NULL',
'owner_id' => 'int(11) DEFAULT NULL',
'status_code' => 'int(11) DEFAULT NULL',
),
'ENGINE=InnoDB DEFAULT CHARSET=utf8');
@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>';
#!/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)
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 {
@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 %}
@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 / 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>
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Lantinghei SC Extralight}
\begin{document}
Hello world,欢迎来到 MacTex 的世界。
\end{document}
$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 ];