defgenerate_index(path): ''' :param path: parent dir of the new public (dist) and old archive ''' with open(path / 'public' / 'index.html', encoding='utf-8') as fp: new = fp.read() with open(path / 'old_archive' / 'index.html', encoding='utf-8') as fp: old = fp.read() stp = [] for m in re.finditer('article>\s+?</div', new, re.DOTALL): stp.append(m.start() + len('article>') + 10) output = new[:stp[0]] + '\n'.join(re.findall(r'<article.+?/article>', old, re.DOTALL)) + new[stp[0]:] with open(path / 'public' / 'index.html', 'w', encoding='utf-8') as fp: fp.write(output)
II. 将old_archive中的必要文件拷贝到新的dist文件夹(视具体情况修改),并将旧页面的css改回原来的css。
# 将旧页面的css替换回原来的css,解决页面显示错误的问题 for x in glob.glob(path / 'public' / '201*/*/*/*/index.html'): with open(x, encoding='utf-8') as fp: con = fp.read().replace('/css/main.css?v=5.0.1', '/css_old/main.css?v=5.0.1') with open(x, 'w', encoding='utf-8') as fp: fp.write(con)
for x in list(glob.glob(path / 'public/archives' / '201*/index.html')) + list(glob.glob(path / 'public/archives' / '201*/*/index.html')): print(x) with open(x, encoding='utf-8') as fp: con = fp.read().replace('/css/main.css?v=5.0.1', '/css_old/main.css?v=5.0.1') with open(x, 'w', encoding='utf-8') as fp: fp.write(con)
from path import Path from bs4 import BeautifulSoup path = Path('/PATH/TO/DIR')
with open(path / 'old_archive' / 'archives' / 'index.html', encoding='utf-8') as fp: old = BeautifulSoup(fp) # 修改旧文章的css with open(path / 'public/archives/index.html', encoding='utf-8') as fp: new = BeautifulSoup(fp)
art = new.find_all('div', {'class': 'posts-collapse'})[0] hd = old.find_all('div', {'class': 'collection-title'})[1] hd['class'] = 'collection-year' hd.h2['class'] = 'collection-header' hd.h2.name = 'span' hd.span.contents[0].replaceWith('更早之前...')
base = len(list(art.children)) art.insert(base, hd) base += 1
for i, x in enumerate(old.find_all('article', {'class': 'post post-type-normal'})): x.h1.name = 'div' x.header.contents = [x.header.contents[0], x.header.contents[3], x.header.contents[2], x.header.contents[1]] art.insert(base + i, x)
with open(path / 'public/archives/index.html', 'w', encoding='utf-8') as fp: fp.write(str(new))
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Assume that we have 10000 genes, which is quantitied in normal ppl and turmor ppl. We
have a algorithm to convert it to a bool table, than we want to pick up the
combinations of gene have satisfied sensitivity and specificity
Sensitivity (also called the true positive rate, the recall, or
probability of detection[1] in some fields) measures the proportion of positives
that are correctly identified as such (e.g., the percentage of sick people who
are correctly identified as having the
condition). Specificity (also called the true negative rate)
measures the proportion of negatives that are correctly identified as such
(e.g., the percentage of healthy people who are correctly identified as not
having the condition).
First
idea
Seem that intutive idea is like this
read bool table
generate combination?
check the Sen. and Spe.
use python’s itertools.combination to generate a iterator of combination
of potential result and check it. However, even while handling 100 genes, the result
may be tremendous. for example
1
5C100 = 75287520
The Language like Python or perl, handle these kind of loop was terriblly slow, one
of my mate takes nearly 35 hours to finish a 5C100 recombination in
Perl.
Is
every combination needed?
After pick some genes, we actually have a bool matrix like this:
1
2
3
|<-----normal---->|<----turmor----->|
g1 0 0 1 1 1 0 1 0 0 0
g2 1 1 1 0 1 1 0 1 1 1
than we can calculate the spe, filter the set whose spe or sen < 0.8:
1
2
3
4
5
6
7
spec, sen = 0, 0
spec = len([x for x in range(normal)
if g1[x] and ge2[x]
]) / normal
sen = len([x for x in range(normal, turmor)
if g1[x] and ge2[x]
]) / turmor
Here we feel diffcult to reduct the execute time of this part of codes. However, we
find out that if one gene’s spe or sen < 0.8, than the combination won’t
satisfied the requirements. So some improvements could be made.
Little improvements
so assume we have a list initial, than we can filter the unsatisfied
single gene.
1
candidate = [gene for gene in initial if is_satisfied(gene)]
Than we run first combination, 2 C len(candidate), far less than the
inital count.
Go
deeper
when we get the result of 2 elements’s combination, we next want to generate the 3
element’s combination.
The hardware of a RPi 3B is listed below, no surprise, just ordinary as his ancestor:
802.11n Wireless LAN
4 USB ports (usb 2.0)
40 GPIO pins
Full HDMI port
Ethernet port(100Mbps)
Camera interface (CSI)
Display interface (DSI)
Micro SD card slot (now push-pull rather than push-push)
In this generation of RPi, this limitation of performance is mainly in its IO
performance, The 100Mbps Ethernet, usb 2.0 and 802.11n
Wifi. This kind of performance has kill is possibility to become a NAS,
which I think should have at least 2 STAT, use3.0, 1Gbps
Ethernet, and a powerful Soc to satisfy this kind of IO requirement. But to be a
wireless router, RPi its enough.
Sniff the packet
At the beginning, I use scapy to capture the traffic through the RPi
like:
1
sniff(iface='ppp0', prn=lambda x: self.handle(x))
however, its cpu usage is ultra hight to >100%, result in a high ratio of package
loss. (~10% captured). After that I find use layer 2’s socket and
tcpdump may be better solution.
1
sudo tcpdump -i ppp0 -w out traffic.pcap
which i can save the traffic to a pcap file and handle it in
scapy.
Handle the packet and get the
address:
In this capture, we will get the ip address of the traffic, check if it is the local
ip or board cast ip address. than, query the public api to get the ipaddress.
PartI,
Injection and Read module handle and method address
To build a internal hack, we simply inject a Dynamic
Link Library to the gaming process. Start a new Thread, and
gather the information we care, and do something. In this part of the
article, we start with the topic of Injection, which is a very normal task in windows
and linux, luckily, there are few wheel we can use in macOS:
Let us start with the project the second
repo mention last section, and copy the third’s repo’s testdylib’s code to
replace the second one. so now we get the project. however as valve
currently update cogs to 64bit, we need to set 4 project to x86_64 in
project setting. after this, our project look like this: there should be a
image
1
2
3
4
5
// the code in install will run after the dylib's injection
voidinstall()
{
printf("loaded\n!");
}
Get the module
address and Find CreateInterface:
In windows we have GetModuleHandle(may be
wrong..)to get the handle of a dll. in macOS, we have the
dlopen from dlfcn.h and apple provide detailed docs:
OS X ABI Dynamic Loader Reference The
methods we use are detail listed in the docs, what we want to do is simply call
them to get the address
1
2
3
4
5
auto address_of_engine = dlopen("client.dylib", RTLD_NOW);
if (!address_of_engine){
printf("Unable to read the address of client.dylib: %s\n", dlerror());
exit(0)
}
if the dylib has been added into the process’s scope, what
is the situation what we meets here, the method will return the handle(address of
the dylib in the memory). After we get the address of the module, we
start to ask where is CreateInterface which is the function to get the
interface(like entity_list, engine_trace) which module
expose to the extern. use the dlsym to the the address:
1
2
3
4
5
6
7
8
// define the CreateInterface first
typedefvoid* (*CreateInterface)(constchar*, int *);
// next call method dlsym
auto clintFactory = (CreateInterface)dlsym(address_of_engine, "CreateInterface");
if (!address_of_create_interface){
printf("Unable to read the address of CreateInterface: %s\n", dlerror());
}
Use
*Factory to get the Interface:
After we get the ClientFactory and
EngineFactory we have to get the useful object we need when making a
hack. like this
auto entity_list = (IClientEntityList *)clientFactory(“VClientEntityList003", nil);
After doing this, we get the basic to making a Internal Hack.