Search Results

Search found 14 results on 1 pages for 'lennart'.

Page 1/1 | 1 

  • PHP: simple form encoding/decoding

    - by Lennart
    Hi guys, Probably, this question has been asked before, though, I'll ask it again. Currently, I'm facing a problem with form encoding. When posting my form, all spaces are replaced by the "+" character. I would like to replace this "+" character by a real space. Does someone has a PHP solution for this? Thanks in advance. Cheers, Lennart

    Read the article

  • What are the packages/libraries I should install before compiling Python from source?

    - by Lennart Regebro
    Once in a while I need to install a new Ubuntu (I used it both for desktop and servers) and I always forget a couple of libraries I should have installed before compiling, meaning I have to recompile, and it's getting annoying. So now I want to make a complete list of all library packages to install before compiling Python (and preferably how optional they are). This is the list I compiled with below help and by digging in setup.py. It is complete for Ubuntu 10.04 and 11.04 at least: build-essential (obviously) libz-dev (also pretty common and essential) libreadline-dev (or the Python prompt is crap) libncursesw5-dev libssl-dev libgdbm-dev libsqlite3-dev libbz2-dev More optional: tk-dev libdb-dev Ubuntu has no packages for v1.8.5 of the Berkeley database, nor (for obvious reasons) the Sun audio hardware, so the bsddb185 and sunaudiodev modules will still not be built on Ubuntu, but all other modules are built with the above packages installed. Python 2.5 and Python 2.6 also needs to have LDFLAGS set on Ubuntu 11.04 and later, to handle the new multi-arch layout: export LDFLAGS="-L/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)" For Python 2.6 and 2.7 you also need to explicitly enable SSL after running the ./configure script and before running make. In Modules/Setup there are lines like this: #SSL=/usr/local/ssl #_ssl _ssl.c \ # -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ # -L$(SSL)/lib -lssl -lcrypto Uncomment these lines and change the SSL variable to /usr: SSL=/usr _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto Python 2.6 also needs Modules/_ssl.c modified to be used with OpenSSL 1.0, which is used in Ubuntu 11.10. At around line 300 you'll find this: else if (proto_version == PY_SSL_VERSION_SSL3) self->ctx = SSL_CTX_new(SSLv3_method()); /* Set up context */ else if (proto_version == PY_SSL_VERSION_SSL2) self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */ else if (proto_version == PY_SSL_VERSION_SSL23) self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */ Change that into: else if (proto_version == PY_SSL_VERSION_SSL3) self->ctx = SSL_CTX_new(SSLv3_method()); /* Set up context */ #ifndef OPENSSL_NO_SSL2 else if (proto_version == PY_SSL_VERSION_SSL2) self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */ #endif else if (proto_version == PY_SSL_VERSION_SSL23) self->ctx = SSL_CTX_new(SSLv23_method()); /* Set up context */ This disables SSL_v2 support, which apparently is gone in OpenSSL1.0.

    Read the article

  • build command by concatenating string in bash

    - by Lennart Rolland
    I have a bash script that builds a command-line in a string based on some parameters before executing it in one go. The parts that are concatenated to the command string are supposed to be separated by pipes to facilitate a "streaming" of data through each component. A very simplified example: #!/bin/bash part1=gzip -c part2=some_other_command cmd="cat infile" if [ ! "$part1" = "" ] then cmd+=" | $part1" fi if [ ! "$part2" = "" ] then cmd+=" | $part2" fi cmd+="> outfile" #show command. It looks ok echo $cmd #run the command. fails with pipes $cmd For some reason the pipes don't seem to work. When I run this script i get different error messages relating usually to the first part of the command (before the first pipe). So my question is whether or not it is possible to build a command in this way, and what is the best way to do it?

    Read the article

  • compiz hiding unity and all menus

    - by Lennart Guldbrandsson
    After updating to Ubuntu 11.10, I was severly disturbed by Dash and wanted to go back to Ubuntu Classic. So I tried to read up, and found Compiz SettingsManager. In there, I clicked "on" never hide menus. For some reason this made all my menus at the top of the screen (volume, network, my login identity, and shutoff, etc) disappear - as well as the quickstart menu to the left (Unity). I am not very technical, so I have a hard time finding any programs now, and I just got on the internet by clicking on a link in a document, that I was fortunate to have on my Desktop. Without it, I wouldn't be able to ask for help. What I wish for is a) to get back the menu at the top, b) to restore the Ubuntu Classic without the irritating launcher and Dash, c) these two things to not disappear every time there is a new version of Ubuntu. Any help is greatly appreciated.

    Read the article

  • What are the packages/libraries I should install before compiling Python from source?

    - by Lennart Regebro
    Once in a while I need to install a new Ubuntu (I used it both for desktop and servers) and I always forget a couple of libraries I should have installed before compiling, meaning I have to recompile, and it's getting annoying. So now I want to make a complete list of all library packages to install before compiling Python (and preferably how optional they are). Off the top of my head I can remember these: build-essential (obviously) libz-dev (also pretty common and essential) libreadline-dev (or the Python prompt is crap) But I know there are many more. Please tell me and I'll update.

    Read the article

  • Migrating mysql 4 to mysql 5

    - by Lennart Regebro
    This seems to me to be a common use case, so I'm surprised so little information is about it, so sorry if it's a duplicate, but I have searched. :) I'm migrating a clients website from one CMS to another, and of moving to newer faster machines all at the same time. As a part of this I'm moving a MySQL database from the old server to the new ones. The problem is that the old server runs MySQL 4 and the new MySQL 5. So when i do a mysqldump at the old site and then try to run it on the new site I get syntax errors. ERROR 1064 (42000) at line 178: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BTREE (`id`), KEY `f_ChangedOnWeb` (`f_ChangedOnWeb`), KEY `f_AddressUpdate`' at line 56 I also tried to use an even older syntax by dumping with --compatible mysql323, but that just resulted in ERROR 1062 (23000) at line 2283: Duplicate entry '??????????' for key 2`... It seems to me this must be a reasonably common use case, yet I can't find any sort of help on this. Possibly all my Google searches just drown in irrelevant answers. Most seem to agree that mysqldump is the right answer, but noone mentions that you can get syntax errors...

    Read the article

  • Supervisord doesn't stop nginx process

    - by Lennart Regebro
    I'm using Supervisor a lot, and in this project I have an nginx process managed by Supervisord. The relevant parts of the configuration is this: [supervisord] logfile=/home/projects/eceee-web/prod/var/log/supervisord.log logfile_maxbytes=5MB logfile_backups=10 loglevel=info pidfile=/home/projects/eceee-web/prod/var/supervisord.pid ; childlogdir=/home/projects/eceee-web/prod/var/log nodaemon=false ; (start in foreground if true;default false) minfds=1024 ; (min. avail startup file descriptors;default 1024) minprocs=200 ; (min. avail process descriptors;default 200) directory=/home/projects/eceee-web/prod [program:nginx] command = /home/projects/eceee-web/prod/bin/nginx redirect_stderr = true autostart= true autorestart = true directory = /home/projects/eceee-web/prod stdout_logfile = /home/projects/eceee-web/prod/var/log/nginx-stdout.log stderr_logfile = /home/projects/eceee-web/prod/var/log/nginx-stderr.log The /home/projects/eceee-web/prod/bin/nginx command will start nginx in the foreground, it does not deamonify itself. Still, stopping it will fail: supervisorctl stop nginx Will not give any answer, but the process will continue. Any idea what? This is on OS X Darwin, with Supervisor 3.0a9 and nginx 0.7.65.

    Read the article

  • Create Word files from Excel content

    - by Lennart
    I have an Excel file that I want to split into several files (Word, PDF is also good), based on content. The content is somewhat like this: Person Fase Date Item Text A 1 01-01-2012 Z Lorem ipsum A 2 01-02-2012 X Lorem ipsum B 1 02-01-2012 Y Lorem ipsum C 2 01-01-2012 Z Lorem ipsum I want Word/PDF documents with names like Person_Fase.docx And as content the date, item and text. Idealy in a table layout. Any hints/ clues on how to get there? It's about 700 clients, with up to 300 Excel entries each.

    Read the article

  • List the root contexts in LDAP

    - by Lennart Schedin
    I would like to list or search the root context(s) in a LDAP tree. I use Apache Directory Server and Java: Hashtable<String, String> contextParams = new Hashtable<String, String>(); contextParams.put("java.naming.provider.url", "ldap://localhost:10389"); contextParams.put("java.naming.security.principal", "uid=admin,ou=system"); contextParams.put("java.naming.security.credentials", "secret"); contextParams.put("java.naming.security.authentication", "simple"); contextParams.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory"); DirContext dirContext = new InitialDirContext(contextParams); NamingEnumeration<NameClassPair> resultList; //Works resultList = dirContext.list("ou=system"); while (resultList.hasMore()) { NameClassPair result = resultList.next(); System.out.println(result.getName()); } //Does not work resultList = dirContext.list(""); while (resultList.hasMore()) { NameClassPair result = resultList.next(); System.out.println(result.getName()); } I can list the sub nodes of ou=system. But I cannot list the sub nodes of the actual root node. I would like to have this list just like Apache Directory Studio can:

    Read the article

  • What does Ruby have that Python doesn't, and vice versa?

    - by Lennart Regebro
    There is a lot of discussions of Python vs Ruby, and I all find them completely unhelpful, because they all turn around why feature X sucks in language Y, or that claim language Y doesn't have X, although in fact it does. I also know exactly why I prefer Python, but that's also subjective, and wouldn't help anybody choosing, as they might not have the same tastes in development as I do. It would therefore be interesting to list the differences, objectively. So no "Python's lambdas sucks". Instead explain what Ruby's lambdas can do that Python's can't. No subjectivity. Example code is good! Don't have several differences in one answer, please. And vote up the ones you know are correct, and down those you know are incorrect (or are subjective). Also, differences in syntax is not interesting. We know Python does with indentation what Ruby does with brackets and ends, and that @ is called self in Python. UPDATE: This is now a community wiki, so we can add the big differences here. Ruby has a class reference in the class body In Ruby you have a reference to the class (self) already in the class body. In Python you don't have a reference to the class until after the class construction is finished. An example: class Kaka puts self end self in this case is the class, and this code would print out "Kaka". There is no way to print out the class name or in other ways access the class from the class definition body in Python. All classes are mutable in Ruby This lets you develop extensions to core classes. Here's an example of a rails extension: class String def starts_with?(other) head = self[0, other.length] head == other end end Ruby has Perl-like scripting features Ruby has first class regexps, $-variables, the awk/perl line by line input loop and other features that make it more suited to writing small shell scripts that munge text files or act as glue code for other programs. Ruby has first class continuations Thanks to the callcc statement. In Python you can create continuations by various techniques, but there is no support built in to the language. Ruby has blocks With the "do" statement you can create a multi-line anonymous function in Ruby, which will be passed in as an argument into the method in front of do, and called from there. In Python you would instead do this either by passing a method or with generators. Ruby: amethod { |here| many=lines+of+code goes(here) } Python: def function(here): many=lines+of+code goes(here) amethod(function) Interestingly, the convenience statement in Ruby for calling a block is called "yield", which in Python will create a generator. Ruby: def themethod yield 5 end themethod do |foo| puts foo end Python: def themethod(): yield 5 for foo in themethod: print foo Although the principles are different, the result is strikingly similar. Python has built-in generators (which are used like Ruby blocks, as noted above) Python has support for generators in the language. In Ruby you could use the generator module that uses continuations to create a generator from a block. Or, you could just use a block/proc/lambda! Moreover, in Ruby 1.9 Fibers are, and can be used as, generators. docs.python.org has this generator example: def reverse(data): for index in range(len(data)-1, -1, -1): yield data[index] Contrast this with the above block examples. Python has flexible name space handling In Ruby, when you import a file with require, all the things defined in that file will end up in your global namespace. This causes namespace pollution. The solution to that is Rubys modules. But if you create a namespace with a module, then you have to use that namespace to access the contained classes. In Python, the file is a module, and you can import its contained names with from themodule import *, thereby polluting the namespace if you want. But you can also import just selected names with from themodule import aname, another or you can simply import themodule and then access the names with themodule.aname. If you want more levels in your namespace you can have packages, which are directories with modules and an __init__.py file. Python has docstrings Docstrings are strings that are attached to modules, functions and methods and can be introspected at runtime. This helps for creating such things as the help command and automatic documentation. def frobnicate(bar): """frobnicate takes a bar and frobnicates it >>> bar = Bar() >>> bar.is_frobnicated() False >>> frobnicate(bar) >>> bar.is_frobnicated() True """ Python has more libraries Python has a vast amount of available modules and bindings for libraries. Python has multiple inheritance Ruby does not ("on purpose" -- see Ruby's website, see here how it's done in Ruby). It does reuse the module concept as a sort of abstract classes. Python has list/dict comprehensions Python: res = [x*x for x in range(1, 10)] Ruby: res = (0..9).map { |x| x * x } Python: >>> (x*x for x in range(10)) <generator object <genexpr> at 0xb7c1ccd4> >>> list(_) [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] Ruby: p = proc { |x| x * x } (0..9).map(&p) Python: >>> {x:str(y*y) for x,y in {1:2, 3:4}.items()} {1: '4', 3: '16'} Ruby: >> Hash[{1=>2, 3=>4}.map{|x,y| [x,(y*y).to_s]}] => {1=>"4", 3=>"16"} Python has decorators Things similar to decorators can be created in Ruby, and it can also be argued that they aren't as necessary as in Python.

    Read the article

  • How to handle ordering of @Rule's when they are dependant on eachother

    - by Lennart Schedin
    I use embedded servers that run inside Junit test cases. Sometimes these servers require a working directory (for example the Apache Directory server). The new @Rule in Junit 4.7 can handle these cases. The TemporaryFolder-Rule can create a temporary directory. A custom ExternalResource-Rule can be created for server. But how do I handle if I want to pass the result from one rule into another: import static org.junit.Assert.assertEquals; import java.io.*; import org.junit.*; import org.junit.rules.*; public class FolderRuleOrderingTest { @Rule public TemporaryFolder folder = new TemporaryFolder(); @Rule public MyNumberServer server = new MyNumberServer(folder); @Test public void testMyNumberServer() throws IOException { server.storeNumber(10); assertEquals(10, server.getNumber()); } /** Simple server that can store one number */ private static class MyNumberServer extends ExternalResource { private TemporaryFolder folder; /** The actual datafile where the number are stored */ private File dataFile; public MyNumberServer(TemporaryFolder folder) { this.folder = folder; } @Override protected void before() throws Throwable { if (folder.getRoot() == null) { throw new RuntimeException("TemporaryFolder not properly initialized"); } //All server data are stored to a working folder File workingFolder = folder.newFolder("my-work-folder"); dataFile = new File(workingFolder, "datafile"); } public void storeNumber(int number) throws IOException { dataFile.createNewFile(); DataOutputStream out = new DataOutputStream(new FileOutputStream(dataFile)); out.writeInt(number); } public int getNumber() throws IOException { DataInputStream in = new DataInputStream(new FileInputStream(dataFile)); return in.readInt(); } } } In this code the folder is sent as a parameter into the server so that the server can create a working directory to store data. However this does not work because Junit processes the rules in reverse order as they are defined in the file. The TemporaryFolder Rule will not be executed before the server Rule. Thus the root-folder in TempraryFolder will be null, resulting that any files are created relative to the current working directory. If I reverse the order of the attributes in my class I get a compile error because I cannot reference a variable before it is defined. I'm using Junit 4.8.1 (because the ordering of rules was fixed a bit from the 4.7 release)

    Read the article

  • ASP.NET Session and target blank

    - by Lennart
    Hi I have seen a few posts regarding Session and using target blank to open a new page. But I still don´t get it. Im working with an application which opens from a link on an Intranet site. I guess it uses target blank to get it in a new window. (I don´t have the source). If both windows are closed (My application and the Intranet site) it seems like the Session is destroyed. I need that to happen when my application is closed. (ie, still leaving the Intranet site open). If I use the site in my testenvironment without opening it from a page with target blank, it seems like I get the expected behaviour. Web.config has: pages enableSessionState="true" Thanks

    Read the article

  • LaTex: why partially showing up references?

    - by HH
    The bib.style part may be the problem. If I do not reference to references, do they show up? I have listed all errors below, the file compiles so I don't know whether they are related to partially-showing-up-references. For example, work with many authors gets only one author listed. I want to see references fully, not partially. Headers $ grep bib header.tex \usepackage{natbib} \bibliographystyle{abbrvnat} Errors $ grep -n -A 7 -B 7 Error *.log combined.log-505-! Illegal unit of measure (pt inserted). combined.log-506-<to be read again> combined.log-507- \futurelet combined.log-508-l.353 \hline combined.log-509- combined.log-510-? combined.log-511- combined.log:512:! Package caption Error: cite undefined. combined.log-513- combined.log-514-See the caption package documentation for explanation. combined.log-515-Type H <return> for immediate help. combined.log-516- ... combined.log-517- combined.log-518-l.374 ...n={CPU O(mlog(n))}, cite={topcoder:node}] combined.log-519- -- combined.log-559- [] combined.log-560- combined.log-561-) [10] combined.log-562-\openout2 = `references.aux'. combined.log-563- combined.log-564- (./references.tex combined.log-565- combined.log:566:! LaTeX Error: \include cannot be nested. combined.log-567- combined.log-568-See the LaTeX manual or LaTeX Companion for explanation. combined.log-569-Type H <return> for immediate help. combined.log-570- ... combined.log-571- combined.log-572-l.1 \include{timeUse.tex} Bibs.bib @misc{ Gundersen, author = "G. Gundersen", title = "Data Structures in Java for Matrix Computations", year = "2002" } @book{ Lennart, author = "R. Lennart", title = "Mathematics Handbook for Science and Engineering BETA", year = "2004" }

    Read the article

  • Python: query a class's parent-class after multiple derivations ("super()" does not work)

    - by henry
    Hi, I have built a class-system that uses multiple derivations of a baseclass (object-class1-class2-class3): class class1(object): def __init__(self): print "class1.__init__()" object.__init__(self) class class2(class1): def __init__(self): print "class2.__init__()" class1.__init__(self) class class3(class2): def __init__(self): print "class3.__init__()" class2.__init__(self) x = class3() It works as expected and prints: class3.__init__() class2.__init__() class1.__init__() Now I would like to replace the 3 lines object.__init__(self) ... class1.__init__(self) ... class2.__init__(self) with something like this: currentParentClass().__init__() ... currentParentClass().__init__() ... currentParentClass().__init__() So basically, i want to create a class-system where i don't have to type "classXYZ.doSomething()". As mentioned above, I want to get the "current class's parent-class". Replacing the three lines with: super(type(self), self).__init__() does NOT work (it always returns the parent-class of the current instance - class2) and will result in an endless loop printing: class3.__init__() class2.__init__() class2.__init__() class2.__init__() class2.__init__() ... So is there a function that can give me the current class's parent-class? Thank you for your help! Henry -------------------- Edit: @Lennart ok maybe i got you wrong but at the moment i think i didn't describe the problem clearly enough.So this example might explain it better: lets create another child-class class class4(class3): pass now what happens if we derive an instance from class4? y = class4() i think it clearly executes: super(class3, self).__init__() which we can translate to this: class2.__init__(y) this is definitly not the goal(that would be class3.__init__(y)) Now making lots of parent-class-function-calls - i do not want to re-implement all of my functions with different base-class-names in my super()-calls.

    Read the article

1