Skip to content

Instantly share code, notes, and snippets.

View l34marr's full-sized avatar

TsungWei Hu l34marr

View GitHub Profile
@l34marr
l34marr / xls_functions.py
Created January 24, 2014 03:16
Working with Excel File
import os
import sys
import pyExcelerator
from pyExcelerator import *
import xlrd
from database import PGDatabase
mydb = PGDatabase()
#mydb = mydbC.connect()
@l34marr
l34marr / list-temples.py
Created December 5, 2013 16:28
Python Script for Archetypes Types.
from Products.CMFCore.utils import getToolByName
request = container.REQUEST
catalog = getToolByName(context, 'portal_catalog')
path = '/mysite/temples'
for brain in catalog(portal_type='Temple', path=path):
try:
obj = brain.getObject()
print brain.getPath().split('/')[5] + ', ' + brain['Title'] + ', ' + obj.getEra()
except:
@l34marr
l34marr / nltk-zh.py
Last active December 24, 2015 13:19
NLTK patch for zh characters.
# !/usr/bin/python
# -*- coding: gbk -*-
# http://hi.baidu.com/xiaopch/item/3a54eec3d93f9e2def466548
from __future__ import division
import os
import codecs
import nltk
from nltk import *
##from nltk.book import *
from bs4 import BeautifulSoup
import requests
r = requests.get("http://www.nasdaq.com/symbol/f/dividend-history")
data = r.content
soup = BeautifulSoup(data)
for i in range(1,31):
id_exdate = "#quotes_content_left_dividendhistoryGrid_exdate_"+str(i)
id_cash = "#quotes_content_left_dividendhistoryGrid_CashAmount_"+str(i)
id_decl = "#quotes_content_left_dividendhistoryGrid_DeclDate_"+str(i)
id_rec = "#quotes_content_left_dividendhistoryGrid_RecDate_"+str(i)
@l34marr
l34marr / .dircolors
Last active December 23, 2015 01:19
Dot Files
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
# Copyright (C) 1996, 1999-2011 Free Software Foundation, Inc.
# Copying and distribution of this file, with or without modification,
# are permitted provided the copyright notice and this notice are preserved.
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
# Below, there should be one TERM entry for each termtype that is colorizable
TERM Eterm
TERM ansi
@l34marr
l34marr / document.py
Last active December 20, 2015 23:18
bin/plonectl run my-script.py
from Testing import makerequest
root = makerequest.makerequest(app)
site = root.mysite
folder = site.myfolder['some-folder']
admin = root.acl_users.getUserById('admin')
admin = admin.__of__(site.acl_users)
from AccessControl.SecurityManagement import newSecurityManager
newSecurityManager(None, admin)
@l34marr
l34marr / news-index_html.pt
Last active December 20, 2015 19:18
ChiNan Church News Folder Page Template.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="context/main_template/macros/master"
i18n:domain="plone">
<body>
@l34marr
l34marr / plonectl-debug.txt
Created August 3, 2013 09:23
Page (Document) Attributes
>>> dir(site.myfolder['page-one'])
['COPY', 'COPY__roles__',
'Contributors', 'Contributors__roles__',
'CookedBody', 'CookedBody__roles__',
'CreationDate', 'CreationDate__roles__',
'Creator', 'Creator__roles__', 'Creators', 'Creators__roles__',
'DELETE', 'DELETE__roles__',
'Date', 'Date__roles__',
'Description', 'Description__roles__',
'EditableBody', 'EditableBody__roles__',
@l34marr
l34marr / dropdown.css
Last active December 20, 2015 08:39
Responsive Menu Demo
/* main menu sticky setting */
#st-wrapper {
width: 100%;
margin: 0 auto;
}
#main-nav-holder {
height: 56px;
}
#main-nav {
@l34marr
l34marr / plone.global_sections
Created April 2, 2013 10:32
zope.interface.interface-plone.global_sections
<nav id="mainMenu" class="tencol last">
<a class="toggleMenu" href="#" style="display: none;">Menu <span class="expandicon"><img src="http://talks.taishinart.org.tw/pic/menu-expand.png"></span></a>
<ul class="nav" tal:define="root_url context/@@plone_portal_state/navigation_root_url; isAnon context/@@plone_portal_state/anonymous" >
<li class=""><a class="rootmenulink parent" href="#" tal:attributes="href string:${root_url}/event/info">藝術雷達<span class="eng-info" style="cursor: default">TS Art Radar</span></a>
<ul class="submenu">
<li class="menuitem"><a class="menulink" href="#" tal:attributes="href string:${root_url}/event/info">藝術動態</a> </li>
<li class="menuitem"><a class="menulink" href="#" tal:attributes="href string:${root_url}/event/talks">藝論紛紛</a> </li>
<li class="menuitem" tal:condition="python: not isAnon"><a class="menulink" href="#" tal:attributes="href string:${root_url}/event/advisors">推薦團</a> </li>
</ul>