Skip to content

Instantly share code, notes, and snippets.

View keitheis's full-sized avatar

Keith Yang keitheis

View GitHub Profile
"""
Output all plim to the folder
e.g.
python plimcd.py ./templates ../mako
"""
import sys
import os.path
import subprocess
@keitheis
keitheis / numpy_scipy_matplotlib_test.py
Created March 26, 2014 07:56
Test NumPy, SciPy, and Matplotlib installed
# Copy from http://www.scipy.org/getting-started.html
import argparse
import numpy as np
from scipy import special, optimize
import matplotlib.pyplot as plt
def main():
# Parse command-line arguments
parser = argparse.ArgumentParser(usage=__doc__)
@keitheis
keitheis / part_list.py
Last active December 26, 2015 04:39
仍是個有懈可擊的解。
def part_list(l, head_amount=1, tail_amount=1):
length = len(l)
tail_start = length - tail_amount
return l[head_amount-1], l[head_amount:tail_start], l[tail_start]
def main():
l = range(5)
x, y, z = part_list(l, 1, 1)
print(x) # 0
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Vim reStructured Text</title>
<meta name="Generator" content="Vim reStructured Text 140 - Vim 7.3" />
<meta name="Author" content="Mikolaj Machowski" />
<meta name="Title" content="Vim reStructured Text - HTML and LaTeX output" />
<meta name="Keywords" content="Vim, LaTeX, PDF, HTML, XML" />
@keitheis
keitheis / inline_loops.py
Created May 28, 2013 16:38
some bad ideas for seeking good
-for row in ['apple', 'banana', 'pineapple']: tr
-for col in ['juice', 'muffin', 'pie']: td
${row.capitalize()} ${col}
-<tr> for row in ['apple', 'banana', 'pineapple']
-<td> for col in ['juice', 'muffin', 'pie']
${row.capitalize()} ${col}
tr -for row in ['apple', 'banana', 'pineapple']
td -for col in ['juice', 'muffin', 'pie']
"""
% python taipeipy_scores.py
{2: 9, 3: 4, 4: 6, 5: 8, 6: 3}
[2, 5, 4, 3, 6]
"""
import pprint
vote_lists = ([5, 2, 4, 6, 3],
[4, 5, 2, 3, 6],
[2, 3, 6, 5, 4])
@keitheis
keitheis / pycontw2013_promote_codes
Created May 8, 2013 15:13
PyCon Taiwan 2013 Promote Codes of Speaker Invitation
C3DCBLJSMR
CB88YXR373
3PYCX4RH5A
D5AKEFEYCD
3AN6FMALSF
from flask import Flask, render_template
from flask.ext.wtf import Form, widgets, SelectMultipleField
SECRET_KEY = 'development'
app = Flask(__name__)
app.config.from_object(__name__)
class MultiCheckboxField(SelectMultipleField):
widget = widgets.ListWidget(prefix_label=False)
{
"metadata": {
"name": "play3"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@keitheis
keitheis / test_sql_build.py
Last active December 13, 2015 19:08
It tests the speed of building SQL by different ways, really.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sql
from sqlalchemy import MetaData, Table, Column, String, DateTime
metadata = MetaData()
users = Table('users', metadata,