When in trouble with IME detecting shortcuts (even if it "sees" the window).
Tuesday, 30 July 2013
Friday, 19 July 2013
Mirroring a website using wget
Every time I have to restore from my memory and man the same line of making a local copy of a website (or a part of it). But enough of that! I'll just post the line here and will never forget as long as this blog is not taken down (which may happen at some point, but who knows when and why?)
wget -N -np -r -l0 -k -p <URL>
wget -N -r -l0 -k -p -D website.edu,img.website.edu http://website.edu/stuffdir/ -I stuffdir -H
Also, this fine man explains how to fix the tilde character converted to a hex value: http://www.kozubik.com/docs/wget_hack.txt (tldr: urlchr_table:url.c). Weird that the source Ubuntu version has it fixed while the binary package doesn't.
This post was brought to you by: a teacup of red wine.
wget -N -np -r -l0 -k -p <URL>
wget -N -r -l0 -k -p -D website.edu,img.website.edu http://website.edu/stuffdir/ -I stuffdir -H
Also, this fine man explains how to fix the tilde character converted to a hex value: http://www.kozubik.com/docs/wget_hack.txt (tldr: urlchr_table:url.c). Weird that the source Ubuntu version has it fixed while the binary package doesn't.
This post was brought to you by: a teacup of red wine.
Sunday, 14 July 2013
LoL
Finding a working version of LoL (the only sane keyboard navigation plugin for Firefox to my knowledge) is getting more and more difficult every time I have to install a new instance of Firefox, so here is the link:
http://elder-gods.org/lol/
http://elder-gods.org/lol/
Tuesday, 21 May 2013
Tuesday, 2 April 2013
Fixing the "stack overflow in regexp matcher" error in Emacs.
I'm using a relatively large ctags file (~20 Mb) built for a C project I'm working on and I ran into the problem recently that the complete-symbol command (Ctrl-Alt-i) that auto-completes function and variable names in C files fails with the "stack overflow in regexp matcher" error.
Long story short, you need to increase the re_max_failures variable located in regex.c to fix this. Is this the right way? I don't know, but it works for me and the comments were not very clear to elaborate. There is also some "smart" logic related to re_max_failures in emacs.c that apparently tries to tweak it to the best value possible, but it turns out to be not smart enough for my use case.
This post was brought to you by GDB Reverse Debugging: Occasionally useful results for those who've got some lifetime to spare!
Long story short, you need to increase the re_max_failures variable located in regex.c to fix this. Is this the right way? I don't know, but it works for me and the comments were not very clear to elaborate. There is also some "smart" logic related to re_max_failures in emacs.c that apparently tries to tweak it to the best value possible, but it turns out to be not smart enough for my use case.
This post was brought to you by GDB Reverse Debugging: Occasionally useful results for those who've got some lifetime to spare!
Labels:
ctags,
emacs,
pain in the arse,
regexp,
stack overflow,
tags
Thursday, 14 March 2013
Probabilities in the game of Quasar.
def getPrize(num):
if num == 15:
return 5
elif num == 16:
return 10
elif num == 17:
return 20
elif num == 18:
return 25
elif num == 19:
return 30
elif num == 20:
return 40
else:
return 0
def getRoll(before):
if before > 20:
return ((), 0)
best_roll = ()
best_avg = getPrize(before)
for roll in (range(1,9), range(4,8)):
avg = 0.
for i in roll:
avg += getRoll(before + i)[1]
avg /= float(len(roll))
if avg > best_avg:
best_avg = avg
best_roll = roll
return (best_roll, best_avg)
for before in range(20):
roll=getRoll(before)
print("%d: %s(%f)" % (before, str(roll[0]), roll[1]))
Which leaves us with the following table of the best bets:
current sum: best choice option (average money won)
0: 4..7(24.459561)
1: 4..7(24.461427)
2: 4..7(23.844185)
3: 1..8(23.573145)
4: 1..8(23.723004)
5: 1..8(24.281559)
6: 4..7(24.718933)
7: 4..7(25.114746)
8: 4..7(23.730469)
9: 1..8(21.812592)
10: 1..8(22.166748)
11: 1..8(23.037109)
12: 1..8(24.921875)
13: 4..7(28.750000)
14: 4..7(23.750000)
15: 4..7(17.500000)
16: 1..8(14.375000)
17+: stop
Too bad the wages are too low to make it a viable source of income.
if num == 15:
return 5
elif num == 16:
return 10
elif num == 17:
return 20
elif num == 18:
return 25
elif num == 19:
return 30
elif num == 20:
return 40
else:
return 0
def getRoll(before):
if before > 20:
return ((), 0)
best_roll = ()
best_avg = getPrize(before)
for roll in (range(1,9), range(4,8)):
avg = 0.
for i in roll:
avg += getRoll(before + i)[1]
avg /= float(len(roll))
if avg > best_avg:
best_avg = avg
best_roll = roll
return (best_roll, best_avg)
for before in range(20):
roll=getRoll(before)
print("%d: %s(%f)" % (before, str(roll[0]), roll[1]))
Which leaves us with the following table of the best bets:
current sum: best choice option (average money won)
0: 4..7(24.459561)
1: 4..7(24.461427)
2: 4..7(23.844185)
3: 1..8(23.573145)
4: 1..8(23.723004)
5: 1..8(24.281559)
6: 4..7(24.718933)
7: 4..7(25.114746)
8: 4..7(23.730469)
9: 1..8(21.812592)
10: 1..8(22.166748)
11: 1..8(23.037109)
12: 1..8(24.921875)
13: 4..7(28.750000)
14: 4..7(23.750000)
15: 4..7(17.500000)
16: 1..8(14.375000)
17+: stop
Too bad the wages are too low to make it a viable source of income.
Saturday, 12 January 2013
Wheezy GTK in KDE4 black on black
1) /etc/kde/kdm/kdmrc: TerminateServer=true
2) restart
via http://www.linuxquestions.org/questions/slackware-14/next-kde-4-8-2-regression-firefox-thunderbird-joined-the-all-blacks-942693/
2) restart
via http://www.linuxquestions.org/questions/slackware-14/next-kde-4-8-2-regression-firefox-thunderbird-joined-the-all-blacks-942693/
Monday, 8 October 2012
TMNT as I will always remember them.
We're not miserable bugs,
We're Super Ninja Turtles!
Wearing shells like T-shirts,
Young talents, yeah, yeah!
Our fighting team is always united! (April: United!)
We'll defeat mean and negligent folks! (April: Defeat!)
We're not scared of attacks!
We'll beat all meanies in a row!
We're not miserable bugs,
We're Super Ninja Turtles!
Teacher gave us lessons of his Skill! (April: Yeah, yeah!)
Now we know it as good as 2x2! (April: 2x2!)
Be always cold-blooded,
Protect your friend's chest well! (April: HOORAAAY!!! :D )
We're not miserable bugs,
We're Super Ninja Turtles!
Wearing shells like T-shirts,
Young talents, yeah, yeah!
Lionsgate are a bunch of cunts.
We're Super Ninja Turtles!
Wearing shells like T-shirts,
Young talents, yeah, yeah!
Our fighting team is always united! (April: United!)
We'll defeat mean and negligent folks! (April: Defeat!)
We're not scared of attacks!
We'll beat all meanies in a row!
We're not miserable bugs,
We're Super Ninja Turtles!
Teacher gave us lessons of his Skill! (April: Yeah, yeah!)
Now we know it as good as 2x2! (April: 2x2!)
Be always cold-blooded,
Protect your friend's chest well! (April: HOORAAAY!!! :D )
We're not miserable bugs,
We're Super Ninja Turtles!
Wearing shells like T-shirts,
Young talents, yeah, yeah!
Lionsgate are a bunch of cunts.
Sunday, 23 September 2012
Adjusting console column width number in R.
options(width=Sys.getenv("COLUMNS"))
It may be put in ~/.Rprofile to initialize during startup, but the Squeeze version (2.11.1) seems to be bugged out and does not work. My attempt in being a smartass
options(width = system("echo $COLUMNS", intern = TRUE))
does not work either.
Sunday, 2 September 2012
Finding kanji I haven't studied yet in my main deck
Present in Heisig:
鼠汰闇鼈雛韮
sqlite3 ~/.anki/decks/Japanese.anki 'select * from facts'|sed -E 's/(.)/\1\n/g'|sort|uniq > /tmp/used_kanji && for kanji in `sqlite3 -header ~/.anki/decks/Heisigs\ Remember\ the\ Kanji\ \(RTK\)\ 13.anki 'select value from (select * from cards left join facts on facts.id=cards.factid where type=-1) as t left join fields on t.factid=fields.factid where fieldmodelid=(select id from fieldmodels where name="Kanji")'`; do grep -F $kanji /tmp/used_kanji|tr -d '\n' ; done ; echo; rm /tmp/used_kanji
Any:
汰薤辣鐶闇雛韭韮鼈鼠
sqlite3 -header ~/.anki/decks/Heisigs\ Remember\ the\ Kanji\ \(RTK\)\ 13.anki 'select value from (select * from cards left join facts on facts.id=cards.factid where type!=-1) as t left join fields on t.factid=fields.factid where fieldmodelid=(select id from fieldmodels where name="Kanji")' > /tmp/unlocked_kanji; for kanji in $(sqlite3 ~/.anki/decks/Japanese.anki 'select * from facts'|sed -E 's/(.)/\1\n/g'|sort|uniq|grep -v '*'); do if ! grep -qF "$kanji" /tmp/unlocked_kanji; then echo $kanji; fi ; done |tr -d '\n'; echo; rm /tmp/unlocked_kanji
Obsoletee! Obsoletee! With Anki 2.0!
Subscribe to:
Comments (Atom)