2007-07-26

Mailing List Archive in RSS

Big thanks to Fredrik Carlsson for the responsiveness and the efficient job.

Messages from some mailing lists can be seen not only through web http://archive.netbsd.se, but through any rss-reader.

And now thanks to the fresh-added tag <pre> around the contents it's properly reflected in google-reader.

2007-07-23

Haskell : Record update is not first class

Gradually, I continue to study Haskell. During the try to avoid the trouble Record update is not first class looked into the library HList. Damn, it's a little bit verbose.

What for? To have two functions on entry: String->Maybe Setter и String->Maybe Getter, and hence further everything would be beautiful and safety.

Update 24.07.2007 Damn, it could be more easy

The problem of elegant modeling a state with neither more nor less than 10 fields:


data Slots = Slots {
slot1 :: SlotData
slot2 :: SlotData
slot3 :: SlotData
....
}

and the understanding of аn outer world is done by:

mkGetter n | n == 1 = slot1
| n == 2 = slot2
...

mkSetter n | n == 1 = \s v -> s{slot1=v}
| n == 2 = \s v -> s{slot2=v}
...

Though of course if it could be done without lambdas it would be more convenient.

2007-07-19

File browser with tags

LJ user olpa asks himself: File browser with tags. Why it is needed?

IMHO if one uses such a browser then the functionality implemented in more specific programs a-la Windows Media Player or Picasa has become absolutely useless.

I myself started to dig in the similar direction. But first of all I'd like to files combine by tags be available in any program including the ill-stared dialog Open File.... And I do not like to implement yet another file manager.

The problem is easy solved at file system level and it seems to be all: sqlite base + fuse + console utility + nautilus plugin, it's rather easy and beautiful implemented. But damn, it will not work on Windows.

Update 23.07.2007 The modest operating system Emacs supports it for a long time.

2007-07-13

Unsecure by design

Avoiding Connection String Injection Attacks
A connection string injection attack can occur when dynamic string concatenation is used to build connection strings based on user input. If the string is not validated and malicious text or characters not escaped, an attacker can potentially access sensitive data or other resources on the server. For example, an attacker could mount an attack by supplying a semicolon and appending an additional value. The connection string is parsed using a "last one wins" algorithm, so the hostile input would be substituted for a legitimate value.
msdn


And why rational escaping mechanism is not provided for every eventually? It's all the same impossible to specify any symbol in the password.

using Oracle.DataAccess.Client;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Data.OracleClient.OracleConnectionStringBuilder builder =
new System.Data.OracleClient.OracleConnectionStringBuilder();
builder.DataSource = "dev";
builder.Pooling = false;
builder.UserID = "user";
builder.Password = "a\"';1234";
OracleConnection connection = new OracleConnection();
connection.ConnectionString = builder.ConnectionString;
connection.Open();
}
}
}

2007-07-11

Links: Powershell in action

I like to study script languages possibilities not from books with artificial samples but during digging real files. More associations remain in memory.

The main thing in the automation is just to remember such a possibility in a right moment.

An interesting article in MSDN Magazine - Light testing with Windows PowerShell

2007-07-05

Google, google - save our soils.

There is a lot of computer dictionaries, there is a lot of programs, which easy translate a word when the mouse is moved to it, there is a lot of on-line dictionaries and translators, it's all great and wonderful.

But I'd like to have a list of everything I translate, to see the statistics in order to learn by heart the most often forgotten words after all. May be some flash cards should be formed by them, it seems there is such way of words learning already.

I need such web service, I need corresponding script for greasemonkey I need corresponding dictionary for my computer with the necessary possibility of quickly translation a word under the mouse, I need pdf dictionary integrated with a book reader... and so that all this has a common base of made requests.
Is there anything similar?

So far I've created a little script for we, using http://lingvo.yandex.ru. As least, I'll bind a database to it, it will be happiness yet.

The code
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, urllib2, libxslt, libxml2
from html5lib import html5parser

# http://www.dbforums.com/archive/index.php/t-1419974.html
# by John J. Lee
class DumbProxyPasswordMgr:
def __init__(self):
self.user = self.passwd = None
def add_password(self, realm, uri, user, passwd):
self.user = user
self.passwd = passwd
def find_user_password(self, realm, authuri):
return self.user, self.passwd

def word2url(word):
return "http://lingvo.yandex.ru/en?text=%s"%word

def download(url):
proxy= urllib2.ProxyHandler({"http" : "http://proxy:8080"})
proxy_auth_handler = urllib2.ProxyBasicAuthHandler(DumbProxyPasswordMgr ())
proxy_auth_handler.add_password(None, None, 'user', 'password')
opener = urllib2.build_opener(proxy,proxy_auth_handler)
urllib2.install_opener(opener)
src = urllib2.urlopen(url)
return src.read()

def html2xml(src):
p = html5parser.HTMLParser()
doc = p.parse(src,'utf-8')
return doc.toxml()


def decodeYaXML(src):
styledoc = libxml2.parseFile("decode.xslt")
style = libxslt.parseStylesheetDoc(styledoc)
doc = libxml2.parseDoc(src)
result = style.applyStylesheet(doc, None)
content = style.saveResultToString(result)
style.freeStylesheet()
doc.freeDoc()
result.freeDoc()
return content

if __name__ == '__main__':
if len(sys.argv) < 2:
print "usage %s word"%sys.argv[0]
sys.exit()
word = sys.argv[1]
result = decodeYaXML(html2xml(download(word2url(word))))
print result.decode('utf-8','replace').encode('cp866','replace')



The contents of decode.xslt file is trivial everybody can write it to one's heart's content.

Monsieur being a good judge of perversion can appreciate the last row.

Benefits of layouts and the structural programming

In addition to this
Visual interface builders save time only as the expense of one shouldn't think about the beauty and the convenience of the interface. Slam bang - and a heap of trash as a result.

Layouts make easier manual coding significantly, provide visual symmetry of the interface and force to think about the information structure.

For the comparison:


credits-na-pivo-oldcredits-na-pivo





Which one is better? What else can be improved?