Skip to content

Instantly share code, notes, and snippets.

View l34marr's full-sized avatar

TsungWei Hu l34marr

View GitHub Profile
@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 / .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
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 / 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 *
@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 / 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 / develop.cfg
Last active July 29, 2016 14:21
Config File for a Typical Plone 4.3.2 Project with plone.app.contenttypes
#################################################################
#
# Development Configuration
# =========================
#
# This is a buildout configuration that sets up a development
# environment for Plone. It extends buildout.cfg.
#
# To use this configuration, run buildout via:
#
@l34marr
l34marr / etc_nginx_nginx.conf
Created March 28, 2014 02:55
Ubuntu 12.04 nginx-common 1.1.19-1ubuntu0.6
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
@l34marr
l34marr / mobile.css
Last active August 29, 2015 14:01
drchen.ploud.com
/* For devices with narrow screens, phones, tablets, etc. */
#portal-column-one,
#portal-column-two,
#portal-column-content,
#portal-column { /* updated */
clear: both;
width: 97.75%;
margin-left: -98.875%;
}
@l34marr
l34marr / plone-builddev.sh
Created June 25, 2014 07:30
Scripts for running a custom Plone install on Codio
#!/bin/sh
# This assumes you installed Plone on Nitrous.io using these instructions
# http://blog.dbain.com/2013/07/plone-quickstart-on-cloud-in-less-than.html
# download this file and run it with the following command
# sh plone-builddev.sh
echo "running buildout with default buildout.cfg"
~/plone433/zinstance/bin/buildout -c ~/plone433/zinstance/develop.cfg