This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: UTF-8 -*- | |
# !/usr/bin/python | |
# read content from the html file | |
file = open('/Users/marco/PycharmProjects/StyleReplace/wechat.html' ,'r') | |
str = file.read() | |
# replace head 2 label | |
h2Start = '''<p style="line-height: 25.6px; max-width: 100%; min-height: 1em; white-space: pre-wrap; color: rgb(62, 62, 62); background-color: rgb(255, 255, 255); box-sizing: border-box !important; word-wrap: break-word !important;"><strong style="max-width: 100%; color: rgb(41, 148, 128); line-height: 25.6px; box-sizing: border-box !important; word-wrap: break-word !important;"></strong></p> | |
<p style="max-width: 100%; box-sizing: border-box !important; word-wrap: break-word !important;"><strong style="max-width: 100%; color: rgb(41, 148, 128); line-height: 25.6px; box-sizing: border-box !important; word-wrap: break-word !important;"><span style="max-width: 100%; font-size: 24px; box-sizing: border-box !important; word-wrap: break-word !important;"> '''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from collections import namedtuple | |
disk_ntuple = namedtuple('partition', 'device mountpoint fstype') | |
usage_ntuple = namedtuple('usage', 'total used free percent') | |
def disk_partitions(all=False): | |
"""Return all mountd partitions as a nameduple. | |
If all == False return phyisical partitions only. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum groupinstall 'Development tools' -y | |
yum install ncurses ncurses-devel wget git -y | |
cd /usr/local/src | |
wget ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2 | |
tar -xjf vim-7.4.tar.bz2 | |
cd vim74 | |
./configure --prefix=/usr --with-features=huge --enable-rubyinterp --enable-pythoninterp | |
make && make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import string | |
RCV_LOG = r"/path/to/xxx.log" | |
def get_last_n_lines(logfile, n): | |
n = string.atoi(n) | |
blk_size_max = 4096 | |
n_lines = [] | |
with open(logfile, 'rb') as fp: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
backspace %08 | |
tab %09 | |
linefeed %0A | |
creturn %0D | |
space %20 | |
! %21 | |
" %22 | |
# %23 | |
$ %24 | |
% %25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_login_addr(email): | |
main_addr = email.split('@')[-1] | |
if 'mail' in main_addr: return main_addr | |
else: return 'mail.' + main_addr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#originated from http://stackoverflow.com/questions/5457286/drop-multiple-databases | |
#firstly you should use mysql_config_editor to set up a "login path" which the mysql command line client can then use. | |
#http://architects.dzone.com/articles/passwordless-command-line | |
DB_STARTS_WITH="test_" | |
MYSQL="mysql" | |
DBS="$($MYSQL --login-path=restore -Bse 'show databases')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo { | |
function myFoo() { | |
return $this->myBar(); | |
} | |
function myBar() { | |
return "Foo"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo { | |
function myFoo() { | |
return $this->myBar(); | |
} | |
function myBar() { | |
return "Foo"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* The lesson from this example is in the output | |
* rather than the PHP code itself. | |
*/ | |
$magnitude_lower = pow(2, (PHP_INT_SIZE * 8) - 2); | |
p($magnitude_lower - 1); | |
p($magnitude_lower, 'See the rollover? Watch it next time around...'); |
NewerOlder