Search Results

Search found 67 results on 3 pages for 'kristian nissen'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • C++ string sort like a human being?

    - by Walter Nissen
    I would like to sort alphanumeric strings the way a human being would sort them. I.e., "A2" comes before "A10", and "a" certainly comes before "Z"! Is there any way to do with without writing a mini-parser? Ideally it would also put "A1B1" before "A1B10". I see the question "Natural (human alpha-numeric) sort in Microsoft SQL 2005" with a possible answer, but it uses various library functions, as does "Sorting Strings for Humans with IComparer". Below is a test case that currently fails: #include <set> #include <iterator> #include <iostream> #include <vector> #include <cassert> template <typename T> struct LexicographicSort { inline bool operator() (const T& lhs, const T& rhs) const{ std::ostringstream s1,s2; s1 << toLower(lhs); s2 << toLower(rhs); bool less = s1.str() < s2.str(); std::cout<<s1.str()<<" "<<s2.str()<<" "<<less<<"\n"; return less; } inline std::string toLower(const std::string& str) const { std::string newString(""); for (std::string::const_iterator charIt = str.begin(); charIt!=str.end();++charIt) { newString.push_back(std::tolower(*charIt)); } return newString; } }; int main(void) { const std::string reference[5] = {"ab","B","c1","c2","c10"}; std::vector<std::string> referenceStrings(&(reference[0]), &(reference[5])); //Insert in reverse order so we know they get sorted std::set<std::string,LexicographicSort<std::string> > strings(referenceStrings.rbegin(), referenceStrings.rend()); std::cout<<"Items:\n"; std::copy(strings.begin(), strings.end(), std::ostream_iterator<std::string>(std::cout, "\n")); std::vector<std::string> sortedStrings(strings.begin(), strings.end()); assert(sortedStrings == referenceStrings); }

    Read the article

  • Drupal 6 hook_form_FORM_ID_alter adding upload file field

    - by kristian nissen
    I'm trying to extend a form and add an upload file field from within a module, I can see the file field just fine, but it's empty when I submit the form, the enctype is set. $form['#attributes'] = array( 'enctype' => "multipart/form-data" ); $form['file_upload'] = array( '#type' => 'file', '#title' => 'Attach Image' ); custom form submit hook: $form['#submit'][] = 'user_images_handler'; is being called, but when I dump the form, the file field is empty, and when I try to access it, it's empty as well.

    Read the article

  • Nested model form with collection in Rails 2.3

    - by kristian nissen
    How can I make this work in Rails 2.3? class Magazine < ActiveRecord::Base has_many :magazinepages end class Magazinepage < ActiveRecord::Base belongs_to :magazine end and then in the controller: def new @magazine = Magazine.new @magazinepages = @magazine.magazinepages.build end and then the form: <% form_for(@magazine) do |f| %> <%= error_messages_for :magazine %> <%= error_messages_for :magazinepages %> <fieldset> <legend><%= t('new_magazine') %></legend> <p> <%= f.label :title %> <%= f.text_field :title %> </p> <fieldset> <legend><%= t('new_magazine_pages') %> <% f.fields_for :magazinepages do |p| %> <p> <%= p.label :name %> <%= p.text_field :name %> </p> <p> <%= p.file_field :filepath %> </p> <% end %> </fieldset> <p> <%= f.submit :save %> </p> </fieldset> <% end %> problem is, if I want to submit a collection of magazinepages, activerecord complaints because it's expected a model and not an array. create action: def create @magazine = Magazine.new params[:magazine] @magazine.save ? redirect_to(@magazine) : render(:action => 'new') end

    Read the article

  • g++ creates several symbols of a const ?

    - by nissen
    In one of my header (C++) files I changed #define TIMEOUT 10 to the more(?) C++ way: const int TIMEOUT = 10; It seems however, g++(v 4.4.3) now includes this symbol several times in the binary. $ nm -C build/ipd/ipd |head 08050420 T ToUnixTime 08050470 T ParseTime 080504c0 T ParseISOTime 080518e4 r TIMEOUT 080518ec r TIMEOUT 080518f4 r TIMEOUT 080518fc r TIMEOUT 080503e0 T HandleMessage How come ?

    Read the article

  • Getting FC11 to run under VMware Server, converted from physical machine

    - by Kristian
    I have a FC11 installation that I have converted to a VMware disk image to run om my VMware Server. I converted it with qemu-img, as the VMware Converter software apparently only converts Linux hosts to VMware Infrastructure servers. The disk image boots fine (grub is loaded and boots the kernel) but it seems like the disk is not found by the kernel, and the boot process stalls. Hotplugging USB devices work (the kernel prints debug information) and I'm able to press keys (Ctrl-Alt-Delete for instance). The VMware guest OS is set to RedHat Enterprise Linux 5 (32 bit), and I have tried both the LSI Logic, LSI Logic SAS and VMware Accelerated SCSI SCSI controllers, to no avail. I'm able to boot an installer disk and get into rescue mode and mount the filesystem, so my question is, what do I need to do to the guest kernel / initrd image to make it recognize the virtual disk?

    Read the article

  • How does FTP servers handle rename to existing file

    - by Kristian
    How does FTP servers normaly handle rename to a file that aready exist? That is, will the existing to-file be overwritten or will I get an error? Is there some specification about how FTP servers should handle this, or is it OS or implementation dependent? vsftpd on Linux seems to overwrite, with FileZilla on Vista I get 550 file exists...

    Read the article

  • How do FTP servers handle rename to an existing file?

    - by Kristian
    How do FTP servers normaly handle rename to a file that aready exist? That is, will the existing to-file be overwritten or will I get an error? Is there some specification about how FTP servers should handle this, or is it OS or implementation dependent? vsftpd on Linux seems to overwrite, with FileZilla on Vista I get 550 file exists...

    Read the article

  • Syslog permissions

    - by Niels Kristian
    I'm using the $InputFile facility in rsyslog to monitor various log files scattered around my ubuntu 12.04 server. E.g. nginx, unicorn, rails, postgres, cron etc. Now my problem is, that some of these log files are created with -rw-r----- right, so rsyslog doesn't have read rights. Since I install most of the programs using apt-get, and therefore didn't change anything from default. So, in other words, I would like not to modify every singe log file / daemon to have the right permissions, if I instead could give syslog read access to all of them at once. But the question is - can I do that, and is it the "right thing to do"?

    Read the article

  • Skype account migration / username change

    - by Kristian Glass
    Some time ago now I created myself a Skype account. I've since amassed a number of contacts, and also realised that the username I chose really isn't one I wish to continue using, for a variety of reasons. Services like Twitter and GitHub offer username-change functionality; I can't find this in Skype. Am I missing something, or does it just not exist? If, as I suspect, it doesn't exist, is there anything I can do to migrate my contacts across to a new, more sensibly-named, account, or am I going to find myself having to manually publicise my account name change and adding contacts to the new account one-by-one?

    Read the article

  • Concurrent NFS access

    - by Kristian
    Similar to Concurrent FTP access. How is concurrent file access handled for NFS? Say that one client is updating/overwriting a file on a NFS server, and a process on the server is reading that same file directly from the file system at the same time. Is there some sort of atomic handling of file read/write in NFS/Linux or do I have to work with tmp files to ensure data consistency? I'm worried that the process reading the file will get corrupt data.

    Read the article

  • Soundtest works, but no other sounds and windows starts very slowly

    - by Kristian Kari
    So suddenly all sounds on my computer stopped working expect the sound test works, but when I go to control panel and audio it says there's no audio device. And audio players and audio on website doesn't work either. and Also windows starts very slowly. I'm not sure if this helps but I'll tell what happened before this. I downloaded this program from a little shady website, I hesitated and for a good reason I guess cos the moment I finished downloading it, my antivir detected it as unwanted program and put it on quarantine. I thought everything was fine, but had some problems with program (won't go to details about it cos it's not really related to audio) so rebooted the computer and I was suprised that windows started really really slowly. It took like 5 mins to load the desktop such. After that I noticed the sounds were missing, I immediately deleted the program since I thought it was causing the problem. But it didn't change much. I tried to find the solution with no success and now I'm just scanning again my computer. I'd be thankful if anyone would be able to help me. I might have left a thing or ten things out, so feel free to ask. oh and I'm using windows xp

    Read the article

  • URGENT: help recovering lost data

    - by Niels Kristian
    I have made a directory: sudo mkdir /ssd, the directory was supposed to be mounted to a raid array called md3. This was done by adding /dev/md3 /ssd auto defaults 0 0 to fstab. Then after a while where I had used the directory, I realized that I had forgotten to run sudo mount -a - and then I did, and now the data is gone. I tried to uncomment the line in fstab and run sudo mount -a but that didn't get back my data. What can I do!? CONTENT OF FSTAB: proc /proc proc defaults 0 0 none /dev/pts devpts gid=5,mode=620 0 0 /dev/md/0 none swap sw 0 0 /dev/md/1 /boot ext3 defaults 0 0 /dev/md/2 / ext4 defaults 0 0 /dev/md3 /ssd auto defaults 0 0

    Read the article

  • Embedded pdf object steals focus and will not let it go

    - by Kristian Hebert
    Hi guys, I was given the task of adding some usability to one of our applications, ie. make sure that every controll has a shortcut key, and that they can be reached by "tabbing" through the page. The gui runs in a IE. control on a winform, and consists of asp.net pages, so basically it is just asp.net always running in internet explorer. My problem is that one of the pages has an embeded pdf in it, like so: <object tabindex="-1" height="273" width="663" visible="false" type="Application/pdf" data="showpdf.ashx#navpanes=0"></object> showpdf.ashx is an httphandler, that streams the pdf contents to the response. It does not handle focus in any way. Now when I run this page, the pdf application steals focus, no matter what I do to set it to another control. And when it takes focus, I cannot take it back with the keyboard. Only a mouseclick on the page will set it to another control. I have tried to set focus in code behind OnPreRender, or in jevescript, but no luck. It seems that the http handler always runs after all the other code, and it sets focus on the pdf object. Any thought would be greatly appreciated.

    Read the article

  • How do I use DomainContext.Load in my ViewModel?

    - by kristian
    I'm trying to use RIA services to provide data to my Silverlight application by calling DomainContext.Load to retrieve a collection of widgets. I want to expose this collection through a property of the ViewModel so I can bind a control to the collection in my page. I think my approach must be fundamentally wrong because Load is called asynchronously and is therefore not available when my page loads and the control tried to bind. Can someone please show me the right way to do this? My Silverlight page has the following XAML: <navigation:Page x:Class="Demo.UI.Pages.WidgetPage" // the usual xmlns stuff here... xmlns:local="clr-namespace:Demo.UI.Pages" mc:Ignorable="d" xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" d:DataContext="{d:DesignInstance Type=local:WidgetPageModel, IsDesignTimeCreatable=False}" d:DesignWidth="640" d:DesignHeight="480" Title="Widget Page"> <Canvas x:Name="LayoutRoot"> <ListBox ItemsSource="{Binding RedWidgets}" Width="150" Height="500" /> </Canvas> </navigation:Page> My ViewModel looks like this: public class WidgetPageModel { private WidgetDomainContext WidgetContext { get; set; } public WidgetPageModel() { this.WidgetContext = new WidgetDomainContext(); WidgetContext.Load(WidgetContext.GetAllWidgetsQuery(), false); } public IEnumerable<Widget> RedWidgets { get { return this.WidgetContext.Widgets.Where(w => w.Colour == "Red"); } } }

    Read the article

  • Show models.ManyToManyField as inline, with the same form as models.ForeignKey inline

    - by Kristian
    I have a model similar to the following (simplified): models.py class Sample(models.Model): name=models.CharField(max_length=200) class Action(models.Model): samples=models.ManyToManyField(Sample) title=models.CharField(max_length=200) description=models.TextField() Now, if Action.samples would have been a ForeignKey instead of a ManyToManyField, when I display Action as a TabularInline in Sample in the Django Admin, I would get a number of rows, each containing a nice form to edit or add another Action. However; when I display the above as an inline using the following: class ActionInline(admin.TabularInline): model=Action.samples.through I get a select box listing all available actions, and not a nifty form to create a new Action. My question is really: How do I display the ManyToMany relation as an inline with a form to input information as described? In principle it should be possible since, from the Sample's point of view, the situation is identical in both cases; Each Sample has a list of Actions regardless if the relation is a ForeignKey or a ManyToManyRelation. Also; Through the Sample admin page, I never want to choose from existing Actions, only create new or edit old ones.

    Read the article

  • Getting the median of 3 values using scheme's

    - by kristian Roger
    The problem this time is to get the median of three values (easy) I did this: (define (med x y z) (car(cdr(x y z))) and it was accepted but when testing it: (med 3 4 5) I get this error: Error: attempt to call a non-procedure (2 3 4) And when entering letters instead of number i get: (md x y z) Error: undefined varia y (package user) Using something besides x y z I get: (md d l m) Error: undefined variable d (package user) the question was deleted dont know how anyway write a function that return the median of 3 values Sorry for editing the question I got that I should put the values in order first not just a sill car and cdr thing so I did so 33> (define (med x y z) (if(and( (<x y) (<y z) y if(and( (<y x) (<x z) x z))))) Warning: invalid expression (if (and< (<x y) (<y z) y if (and ((<y x) (<x z) x z)))) but as u see Im getting a warning so what is wronge ?

    Read the article

  • geting the median of 3 values using sheme car & cdr

    - by kristian Roger
    Hi still stuck with the ugly scheme the problem this time is to get the median of three values (easy) I did all these : (define (med x y z) (car(cdr(x y z))) and it was accepted but when testing it (med 3 4 5) I will get this error Error: attempt to call a non-procedure (2 3 4) and when entering letters inetead of number i got (md x y z) Error: undefined varia y (package user) using somthin else than x y z i got (md d l m) Error: undefined variable d (package user) so what is wronge ?!

    Read the article

  • car and cdr in scheme is driving me crazy ...

    - by kristian Roger
    Hi Im facing a probem with the car and cdr functions for example: first I defined a list caled it x (define x (a (bc) d ( (ef) g ) )) so x now is equal to (a (bc) d ( (ef) g ) now for example I need to get the g from this list using only car and cdr (!! noshortcuts as caddr cddr !!) the correct answer is: (car(cdr(car(cdr(cdr(cdr x)))))) BUT how ? :-( I work according to the rule (the car gives the head of list and cdr gives the tail) and instead of getting the answer above I keep reaching wronge answers can any one help me in understanding this ... give me step or a way to solve it step by step thanx in advance Im really sick of scheme language.

    Read the article

  • Provide me with recources on Greibach & Chomsky Normal Form

    - by kristian Roger
    Hi, first please (bare with me)... :-( Im having a course at University ( Theory of Computation ) at first it was easy and simple BUT then we reach the context free grammer specialy the part where we should convert a grammer to Normal forms (Greibach & Chomsky) the thing that I couldnt understand so as usual I went to google and start searching for tutorials or videos I found many(tutorials not videos) but the problem that in tutorials they always explain things as if Im an expert or aware of every thing ... so can anyone please provide me with docs or links where they explaine the methods step by step ... (Please dont tell me to go back to my instructor because if he is useful I wont be asking your help ) thanx in advance

    Read the article

  • car and cdr in Scheme are driving me crazy ...

    - by kristian Roger
    Hi Im facing a problem with the car and cdr functions for example: first I defined a list called it x (define x (a (bc) d ( (ef) g ) )) so x now is equal to (a (bc) d ( (ef) g ) ) now for example I need to get the g from this list using only car and cdr (!! noshortcuts as caddr cddr !!) the correct answer is: (car(cdr(car(cdr(cdr(cdr x)))))) BUT how ? :-( I work according to the rules (the car gives the head of list and cdr gives the tail) and instead of getting the answer above I keep reaching wrong answers. Can any one help me in understanding this ... give me step or a way to solve it step by step Thanks in advance. I'm really sick of Scheme.

    Read the article

< Previous Page | 1 2 3  | Next Page >