I have a plain txt file which contains paragraphs which contain about 15-40 lines and each paragraph is separated from the previous/next one with 3 empty lines, I'd like to print out all the paragraphs which contain the string "sasi89".
Example:
PokerStars Hand #61919020230: Tournament #393199063, $0.10+$0.01 USD Hold'em No Limit - Level IV (50/100) - 2011/05/10 12:11:58 ET
Table '393199063 1' 9-max Seat #9 is the button
Seat 1: bebe2829 (1529 in chips)
Seat 3: zng 111 (4374 in chips)
Seat 4: mal4o (11100 in chips)
Seat 6: gysomi (6118 in chips)
Seat 7: DEEAMAYA (2590 in chips)
Seat 9: sasi89 (235 in chips)
bebe2829: posts small blind 50
zng 111: posts big blind 100
*** HOLE CARDS ***
Dealt to sasi89 [Kc Th]
mal4o: folds
gysomi: folds
DEEAMAYA: folds
sasi89: raises 135 to 235 and is all-in
bebe2829: folds
zng 111: calls 135
*** FLOP *** [7h 9s Tc]
*** TURN *** [7h 9s Tc] [Qd]
*** RIVER *** [7h 9s Tc Qd] [9d]
*** SHOW DOWN ***
zng 111: shows [Jh Kh] (a straight, Nine to King)
sasi89: shows [Kc Th] (two pair, Tens and Nines)
zng 111 collected 520 from pot
sasi89 finished the tournament in 11th place
*** SUMMARY ***
Total pot 520 | Rake 0
Board [7h 9s Tc Qd 9d]
Seat 1: bebe2829 (small blind) folded before Flop
Seat 3: zng 111 (big blind) showed [Jh Kh] and won (520) with a straight, Nine to King
Seat 4: mal4o folded before Flop (didn't bet)
Seat 6: gysomi folded before Flop (didn't bet)
Seat 7: DEEAMAYA folded before Flop (didn't bet)
Seat 9: sasi89 (button) showed [Kc Th] and lost with two pair, Tens and Nines
PokerStars Hand #61918994165: Tournament #393199063, $0.10+$0.01 USD Hold'em No Limit - Level IV (50/100) - 2011/05/10 12:11:19 ET
Table '393199063 1' 9-max Seat #7 is the button
Seat 1: bebe2829 (1079 in chips)
Seat 3: zng 111 (4374 in chips)
Seat 4: mal4o (11500 in chips)
Seat 6: gysomi (6118 in chips)
Seat 7: DEEAMAYA (2590 in chips)
Seat 9: sasi89 (285 in chips)
sasi89: posts small blind 50
bebe2829: posts big blind 100
*** HOLE CARDS ***
Dealt to sasi89 [2d 7h]
zng 111: folds
mal4o: calls 100
gysomi: folds
DEEAMAYA: folds
sasi89: folds
bebe2829: checks
*** FLOP *** [8c Js 2h]
bebe2829: checks
mal4o: checks
*** TURN *** [8c Js 2h] [8h]
bebe2829: checks
mal4o: checks
*** RIVER *** [8c Js 2h 8h] [6h]
bebe2829: bets 300
mal4o: calls 300
*** SHOW DOWN ***
bebe2829: shows [Jc 3c] (two pair, Jacks and Eights)
mal4o: mucks hand
bebe2829 collected 850 from pot
*** SUMMARY ***
Total pot 850 | Rake 0
Board [8c Js 2h 8h 6h]
Seat 1: bebe2829 (big blind) showed [Jc 3c] and won (850) with two pair, Jacks and Eights
Seat 3: zng 111 folded before Flop (didn't bet)
Seat 4: mal4o mucked [6d Ac]
Seat 6: gysomi folded before Flop (didn't bet)
Seat 7: DEEAMAYA (button) folded before Flop (didn't bet)
Seat 9: sasi89 (small blind) folded before Flop
You can use awk in "paragraph mode" (see https://www.gnu.org/software/gawk/manual/html_node/Multiple-Line.html) by setting RS to the empty string:
awk -v RS= '/sasi89/' file
The above assumes there's no other blank lines in your file except those between paragraphs.
awk to the rescue
awk 'BEGIN{ORS=RS="\n\n\n"} /sasi89/'
this will keep the 3 empty lines between paragraphs. If you want to normalize to single empty line remove ORS= or simply
awk -v RS="\n\n\n" '/sasi89/'
Related
I am trying to compare if there are differences in the number of obtained seeds in five different populations with different applied treatments, and having maternal plant and paternal plant as random effects. First I tried to fit a glmer model.
dat <-dat [,c(12,7,6,13,8,11)]
dat$parents<-factor(paste(dat$mother,dat$father,sep="_"))
compareTreat <- function(d)
{
d$treatment <-factor(d$treatment)
print (tapply(d$pop,list(d$pop,d$treatment),length))
print(summary(fit<-glmer(seed_no~treatment+(1|pop/mother)+
(1|pop/father),data=d,family="poisson")))
}
Then, I compared two treatments in two populations (pop 64 and pop 121, in that case). The other populations do not have this particular treatments, so I get NA values for those.
compareTreat(subset(dat,treatment%in%c("IE 5x","IE 7x")&pop%in%c(64,121)))
This is the output:
IE 5x IE 7x
10 NA NA
45 NA NA
64 31 27
121 33 28
144 NA NA
Generalized linear mixed model fit by maximum likelihood (Laplace
Approximation) [glmerMod]
Family: poisson ( log )
Formula: seed_no ~ treatment + (1 | pop/mother) + (1 | pop/father)
Data: d
AIC BIC logLik deviance df.resid
592.5 609.2 -290.2 580.5 113
Scaled residuals:
Min 1Q Median 3Q Max
-1.8950 -0.8038 -0.2178 0.4440 1.7991
Random effects:
Groups Name Variance Std.Dev.
father.pop (Intercept) 3.566e-01 5.971e-01
mother.pop (Intercept) 9.456e-01 9.724e-01
pop (Intercept) 1.083e-10 1.041e-05
pop.1 (Intercept) 1.017e-10 1.008e-05
Number of obs: 119, groups: father:pop, 81; mother:pop, 24; pop, 2
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.74664 0.24916 2.997 0.00273 **
treatmentIE 7x -0.05789 0.17894 -0.324 0.74629
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr)
tretmntIE7x -0.364
It seems there are no differences between treatments. But as there are many zeros in the data, a zero-inflated model would be worthy to try. I tried with glmmabmd, and I wrote the script like this:
compareTreat<-function(d)
{
d$treatment<-factor(d$treatment)
print(tapply(d$pop,list(d$pop,d$treatment), length))
print(summary(fit_zip<-glmmadmb(seed_no~treatment + (1|pop/mother)+
(1|pop/father),data=d,family="poisson", zeroInflation=TRUE)))
}
Then I compared again the treatments. Here I have not changed the code.
compareTreat(subset(dat,treatment%in%c("IE 5x","IE 7x")&pop%in%c(64,121)))
But in that case, the output is
IE 5x IE 7x
10 NA NA
45 NA NA
64 31 27
121 33 28
144 NA NA
Error in pop:father : NA/NaN argument
In addition: Warning messages:
1: In pop:father :
numerical expression has 119 elements: only the first used
2: In pop:father :
numerical expression has 119 elements: only the first used
3: In eval(parse(text = x), data) : NAs introduced by coercion
Called from: eval(parse(text = x), data)
I tried to change everything I came up with, but I still don't know where the problem is.
If I remove the (1|pop/father) from the glmmadmb script, the model runs, but it feels not correct. I wonder if the mistake is in the loop prior to the glmmadmb but it worked OK in the glmer model, or if it is in the comparison itself after the model. I tried as well to remove NAs with na.omit in case that was an issue, but it did not make a difference. Why does the script stop and does not continue running?
I am a student beginner with RStudio, my version is 3.4.2, called Short Summer. If someone with experience could point me in the right direction I would be very grateful!
H.
I just started learning Memory Management and have an idea of page,frames,virtual memory and so on but I'm not understanding the procedure from changing logical addresses to their corresponding page numbers,
Here is the scenario-
Page Size = 100 words /8000 bits?
Process generates this logical address:
10 11 104 170 73 309 185 245 246 434 458 364
Process takes up two page frames,and that none of its are resident (in page frames) when the process begins execution.
Determine the page number corresponding to each logical address and fill them into a table with one row and 12 columns.
I know the answer is :
0 0 1 1 0 3 1 2 2 4 4 3
But can someone explain how this is done? Is there a equation or something? I remember seeing something with a table and changing things to binary and putting them in the page table like 00100 in Page 1 but I am not really sure. Graphical representations of how this works would be more than appreciated. Thanks
I am getting a segfault in the native part of my android app, in the moment a void function returns to its caller. To visualize better, I put a log statement at the end of the callee function, and one in the caller function, right after the call to the callee (sorry for the pun).
In the logcat, the first message is printed, and the second not (the app crashes).
Thinking about a possible memory corruption I decided to activate malloc debug (giving "setprop libc.debug.malloc 10" in adb shell). Then, i get this in the logcat right after the log message from the end of the callee function:
D/MyApp - NativeSide(12778): I am the callee function and I am about to return!
E/libc (12778): *** FREE CHECK: buffer 0x82869900 corrupted 16 bytes before allocation
E/libc (12778): call stack:
E/libc (12778): 0: 8000e3ea
E/libc (12778): 1: 8000e49c
E/libc (12778): 2: 8000e4e2
E/libc (12778): 3: 8000e540
E/libc (12778): 4: afd14ccc
E/libc (12778): 5: 81258188
E/libc (12778): 6: 81258188
E/libc (12778): 7: 81258188
E/libc (12778): 8: 81258188
E/libc (12778): 9: 81258188
E/libc (12778): 10: 81258188
E/libc (12778): 11: 81258188
E/libc (12778): 12: 81258188
E/libc (12778): 13: 81258188
E/libc (12778): 14: 81258188
E/libc (12778): 15: 81258188
E/libc (12778): 16: 81258188
E/libc (12778): 17: 81258188
E/libc (12778): 18: 81258188
E/libc (12778): 19: 81258188
I couldn't find any information on how to decipher this output. The numbers shown at each line are changing at every app launch. I hope there's a way to use this information as a clue on where the corruption happens, as I can't find it from the code. I also tried building the native libraries with the "-fstack-check flag, but I couldn't say if I got more informations in the log (it seems not but I might have missed them), or whether I need to do other things to get them.
Also, here's the stack dump, coming after the "FREE CHECK:" message.
I/DEBUG (12311): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG (12311): Build fingerprint: 'google/soju/crespo:2.3/GRH55/79397:user/release-keys'
I/DEBUG (12311): pid: 12778, tid: 12907 >>> com.ntrack.tuner <<<
I/DEBUG (12311): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
I/DEBUG (12311): r0 deadbaad r1 45ea374c r2 00000027 r3 00000000
I/DEBUG (12311): r4 00000080 r5 45ea374c r6 8003422e r7 45ea37b4
I/DEBUG (12311): r8 45da4000 r9 a811eca5 10 00100000 fp 00000001
I/DEBUG (12311): ip ffffffff sp 45ea3738 lr 8000f623 pc 8000f650 cpsr 20000030
I/DEBUG (12311): d0 3f9664f48406d639 d1 3f8226e3e96e8495
I/DEBUG (12311): d2 3faba1ba1bb34201 d3 0000000000000000
I/DEBUG (12311): d4 3d7943379e56fd24 d5 3d8f940585cd5f95
I/DEBUG (12311): d6 3f2cf2145b888497 d7 3f2cf214636d85f8
I/DEBUG (12311): d8 0000000000000000 d9 0000000000000000
I/DEBUG (12311): d10 0000000000000000 d11 0000000000000000
I/DEBUG (12311): d12 0000000000000000 d13 0000000000000000
I/DEBUG (12311): d14 0000000000000000 d15 0000000000000000
I/DEBUG (12311): scr 20000010
I/DEBUG (12311):
Anything, a suggestion on the typical things to check or just the way to make use of the malloc debug informations would be of great help, thanks!
The malloc debug property is probably setting some magic numbers before and after the area you allocate. Then, when freeing, it would check those areas to make sure the magic number is still there.
For example, if you allocate 1024 bytes:
char * p = malloc(1024);
The malloc debug code would actually allocate 1024 bytes that you requested, plus some extra around it:
[ 32 bytes ---- | -------- 1024 bytes ------| ---- 32 bytes ]
^ 0xc0000000 ^ 0xc0000020
The library would then write a magic value into those 32 bytes:
[ 32 bytes ---- | -------- 1024 bytes ------| ---- 32 bytes ]
[ 0xdeadd00d | | 0xdeadd00d ]
^ 0xc0000000 ^ 0xc0000020
The library would return 0xc0000020 into p and internally it would save 0xc0000000, the size, etc.
Your function then uses the allocated area somehow:
memset(p, 0, 1025);
Notice this line copied more than 1024 bytes. That would write a 0 into the last 32 byte magic area (notice the 0 in the last 32 bytes, which should be 0xdeadd00d):
[ 32 bytes ---- | -------- 1024 bytes ------| ---- 32 bytes ]
[ 0xdeadd00d | 000... ...00 | 0x0eadd00d ]
^ 0xc0000000 ^ 0xc0000020 (address)
When your function calls free:
free(p);
The library would then check to make sure the first and last 32 bytes are still 0xdeadd00d. Since your function overwrote the last 32 bytes, it would print an error like you posted.
This is only an example of how a malloc debug checking would work. If you would like to see exactly what the malloc debug checks and how it works, go to the bionic directory of Android source and search for the property you set, libc.debug.malloc.
Check your code for how you use allocated memory in the called function. You are probably writing to an area outside of the area you allocated.
To me, this:
a segfault in the native part of my android app, in the moment a void function returns to its caller.
means stack corruption (more than heap corruption). What state is stored on the stack of this function you're returning from (and from every function it calls ..)?
The call stack output you're seeing should be the address of each function on the stack at the time the corruption was detected. You'll need to know what address your library was loaded at to map those back to a symbol in your .so. (I think this question will help: How to use addr2line in Android)
The fact that 81258188 repeats off the top of the stack dump also suggest that you might've blown out the bottom of the stack (by recursing too many times). If you're not aware of any intentional recursion in your code, then figuring out where your library was loaded and mapping that back to your code could be useful.
can anyone help me out in interpreting this panic crash log?
this happens during rotation with many images ... it involves javascript if that is of any help.
Incident Identifier: AD3EB83A-2379-4876-BCB3-6C9A4B5DC862
CrashReporter Key: e580be25a4b36b96f0d033b88c3cfebf6232e309
Hardware Model: iPad2,1
Date/Time: 2012-06-27 14:26:41.182 +0200
OS Version: iPhone OS 5.1.1 (9B206)
panic(cpu 1 caller 0x801c6fdb): mbuf_watchdog: 4 waiters stuck for 12 secs
13872/13872 mbufs in use:
13868 mbufs allocated to data
4 mbufs allocated to packet headers
13748/13748 mbuf 2KB clusters in use
0/122 mbuf 4KB clusters in use
31452 KB allocated to network (approx. 98% in use)
mbuf leak detection table:
total captured: 31701 (one per 500)
total allocs outstanding: 42
new hash recorded: 27032 allocs, 26944 traces
hash collisions: 18 allocs, 4669 traces
overwrites: 26449 allocs, 0 traces
lock conflicts: 0
top 5 outstanding traces:
[1] 29 outstanding alloc(s), 30 hit(s), 1 collision(s)
[2] 5 outstanding alloc(s), 26 hit(s), 0 collision(s)
[3] 3 outstanding alloc(s), 2546 hit(s), 0 collision(s)
[4] 3 outstanding alloc(s), 1844 hit(s), 0 collision(s)
[5] 1 outstanding alloc(s), 4662 hit(s), 4661 collision(s)
trace [1] trace [2] trace [3] trace [4] trace [5]
---------- ---------- ---------- ---------- ----------
1: 0x801bff71 0x801bff71 0x801bff71 0x801bff71 0x801bff71
2: 0x801b0df3 0x801b0df3 0x801b0e2b 0x801b0df3 0x801b0df3
3: 0x801bf8b5 0x801c12db 0x801c12db 0x801bf871 0x801b0f39
4: 0x801b0c67 0x801c9517 0x801c9517 0x801b0c67 0x801c08bb
5: 0x801c12db 0x801cece3 0x801cece3 0x801c12db 0x802b7855
6: 0x801c9517 0x801ceb05 0x801ceb05 0x801c9517 0x801be739
7: 0x801cece3 0x801e1bd8 0x801e1bd8 0x801cece3 0x8010e8d5
8: 0x801ceb05 0x801ceb05 0x802b91f5
9: 0x801e1bd8 0x801e1bd8 0x802b937f
10: 0x802b8591
11: 0x8002425b
12:
13:
14:
15:
16:
Debugger message: panic
OS version: 9B206
Kernel version: Darwin Kernel Version 11.0.0: S
Thanks for any insight.
You should use instruments to check memory allocations and memory leaks. It could also be that the app was too long unresponsive and was killed, the text 4 waiters stuck for 12 secs could indicate that. The crash report content and format is pretty unique, haven't seen that one yet. So these are just guesses.
I want to write a Rails app to assist me with my online Poker. I play on PokerStars, and there is text data available for each hand that is played. The format it comes in is this:
PokerStars Game #27457662450: Tournament #157033867, Freeroll Hold'em No Limit - Level IV (50/100) - 2009/04/24 20:39:44 ET
Table '157033867 830' 9-max Seat #1 is the button
Seat 1: DortheaV (7624 in chips)
Seat 2: Currly234 (3016 in chips)
Seat 3: paolilla (3086 in chips)
Seat 4: triumph888 (1571 in chips) is sitting out
Seat 5: Minchausti (1185 in chips) is sitting out
Seat 6: madmike11847 (1195 in chips) is sitting out
Seat 7: alamodey (4038 in chips)
Seat 8: whiskerbob (3365 in chips)
Seat 9: SHpic76 (1115 in chips) is sitting out
DortheaV: posts the ante 10
Currly234: posts the ante 10
paolilla: posts the ante 10
triumph888: posts the ante 10
Minchausti: posts the ante 10
madmike11847: posts the ante 10
alamodey: posts the ante 10
whiskerbob: posts the ante 10
SHpic76: posts the ante 10
Currly234: posts small blind 50
paolilla: posts big blind 100
*** HOLE CARDS ***
Dealt to alamodey [8s Ks]
triumph888: folds
Minchausti: folds
madmike11847: folds
alamodey: calls 100
whiskerbob: folds
SHpic76: folds
DortheaV: folds
Currly234: calls 50
paolilla: checks
*** FLOP *** [5c 4h 6d]
Currly234: checks
paolilla: checks
alamodey: bets 234
Currly234: folds
paolilla: folds
Uncalled bet (234) returned to alamodey
alamodey collected 390 from pot
alamodey: doesn't show hand
*** SUMMARY ***
Total pot 390 | Rake 0
Board [5c 4h 6d]
Seat 1: DortheaV (button) folded before Flop (didn't bet)
Seat 2: Currly234 (small blind) folded on the Flop
Seat 3: paolilla (big blind) folded on the Flop
Seat 4: triumph888 folded before Flop (didn't bet)
Seat 5: Minchausti folded before Flop (didn't bet)
Seat 6: madmike11847 folded before Flop (didn't bet)
Seat 7: alamodey collected (390)
Seat 8: whiskerbob folded before Flop (didn't bet)
Seat 9: SHpic76 folded before Flop (didn't bet)
Are there any parsing libraries for Ruby or do I have to do this manually and hackily?
This sounds like a job for Regex!. I doubt using any library would make it any easier to parse, since it's a pretty custom format you'll just have to hack away at it.
You might want to look at Treetop, a Parsing Expression Grammar based parser generator for Ruby.
Ragel is very good to write a parser. E.g. the http parser of Mongrel is generated with ragel.
Also if you just want the data you should just check out PokerTracker. PokerTracker stores 100% of hand information and has a well-documented schema and an open PostgreSQL database.