import os
os.chdir( '/YOUR/PATH/' )
for folder in sorted( os.listdir( os.getcwd() ) ):
if not os.path.isfile( folder ):
print folder
2015-07-28
PYTHON - Extract string content between parenthesis (without regex)
print YOUR_STRING[ YOUR_STRING.find( '(' ) + 1 : YOUR_STRING.find( ')' ) ]
MacOS - How to toggle between windows of the same app
COMMAND-`
PS. To toggle between apps: COMMAND-TAB
PS. To toggle between apps: COMMAND-TAB
2015-07-27
PYTHON - How to determine the python version your code is running on
import sys
print sys.version
print sys.version_info
print sys.version
print sys.version_info
2015-07-26
PYTHON - How to curl into a file?
(1) Install the pycurl package:
easy_install pycurl
(2) Sample script:
import pycurl
c = pycurl.Curl()
c.setopt(c.USERAGENT, 'Mozilla/5.0 (compatible; pycurl)' )
c.setopt(c.URL, 'http://website.com/page1.html')
with open('target_file_name.html', 'w') as f:
c.setopt( c.WRITEFUNCTION, f.write )
c.perform()
f.close()
easy_install pycurl
(2) Sample script:
import pycurl
c = pycurl.Curl()
c.setopt(c.USERAGENT, 'Mozilla/5.0 (compatible; pycurl)' )
c.setopt(c.URL, 'http://website.com/page1.html')
with open('target_file_name.html', 'w') as f:
c.setopt( c.WRITEFUNCTION, f.write )
c.perform()
f.close()
2015-07-22
MacOS - How to customize your terminal prompt, adding a line after each command
(1) Open or create ~\.bash_profile (a text flat file at the root of your MacOS profile).
(2) Enter this line (cusomize... the dashes can be anything you want... the \n is a carriage return+line feed):
export PS1="----------------\n$"
(2) Enter this line (cusomize... the dashes can be anything you want... the \n is a carriage return+line feed):
export PS1="----------------\n$"
Subscribe to:
Posts (Atom)