Search Results

Search found 67 results on 3 pages for 'knorv'.

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

  • How do I (or should I?) access the service layer from a SiteMesh template (views/layouts/main.gsp) in Grails?

    - by knorv
    I need to create a toplist in the page footer on a site that I'm building. The footer is created in the default SiteMesh layout template (views/layouts/main.gsp). In order to create the toplist access to the database is needed, so I've encapsulated all logic needed for the toplist creation in a service class (services/FooService). Please note that while services are usually accessed from the controller layer, in this case the default layout template (views/layouts/main.gsp) is not generated from a controller. Can the layout view (views/layouts/main.gsp) access a service class? How? Is this the correct design decision? If not, what is a better encapsulation and how do I interact with said encapsulation from the layout view (views/layouts/main.gsp)?

    Read the article

  • How do I programmatically trigger a mx:Button click event?

    - by knorv
    Consider the following mx:Button: <mx:Button click="doSomething()" id="myButton"/> Is there some way to programmatically emulate the user clicking the button? One obvious way to do it would simply be to call doSomething() which would give the same end result as clicking the button. But I'm specifically looking for ways to emulate the click -- that is something along the lines of myButton.click() (if that should have existed).

    Read the article

  • Why use <g:textField /> in Grails?

    - by knorv
    What is the reason to use g:textField in Grails if you're already familiar with standard HTML form tags? If I understand correctly the following two markup alternatives are equivalent: <input type="text" name="name" value="${params.name}" id="name" /> <g:textField name="name" value="${params.name}" /> Are there any circumstances under which using g:textField would add value? Am I missing something?

    Read the article

  • Forcing a mixed ISO-8859-1 and UTF-8 multi-line string into UTF-8 in Perl

    - by knorv
    Consider the following problem: A multi-line string $junk contains some lines which are encoded in UTF-8 and some in ISO-8859-1. I don't know a priori which lines are in which encoding, so heuristics will be needed. I want to turn $junk into pure UTF-8 with proper re-encoding of the ISO-8859-1 lines. Also, in the event of errors in the processing I want to provide a "best effort result" rather than throwing an error. My current attempt looks like this: $junk = &force_utf8($junk); sub force_utf8 { my $input = shift; my $output = ''; foreach my $line (split(/\n/, $input)) { if (utf8::valid($line)) { utf8::decode($line); } $output .= "$line\n"; } return $output; } While this appears to work I'm certain this is not the optimal solution. How would you improve the force_utf8(...) sub?

    Read the article

  • R: Given a set of random numbers drawn from a continuous univariate distribution, find the distribut

    - by knorv
    Given a set of real numbers drawn from a unknown continuous univariate distribution (let's say is is one of beta, Cauchy, chi-square, exponential, F, gamma, Laplace, log-normal, normal, Pareto, Student's t, uniform and Weibull).. x <- c(15.771062,14.741310,9.081269,11.276436,11.534672,17.980860,13.550017,13.853336,11.262280,11.049087,14.752701,4.481159,11.680758,11.451909,10.001488,11.106817,7.999088,10.591574,8.141551,12.401899,11.215275,13.358770,8.388508,11.875838,3.137448,8.675275,17.381322,12.362328,10.987731,7.600881,14.360674,5.443649,16.024247,11.247233,9.549301,9.709091,13.642511,10.892652,11.760685,11.717966,11.373979,10.543105,10.230631,9.918293,10.565087,8.891209,10.021141,9.152660,10.384917,8.739189,5.554605,8.575793,12.016232,10.862214,4.938752,14.046626,5.279255,11.907347,8.621476,7.933702,10.799049,8.567466,9.914821,7.483575,11.098477,8.033768,10.954300,8.031797,14.288100,9.813787,5.883826,7.829455,9.462013,9.176897,10.153627,4.922607,6.818439,9.480758,8.166601,12.017158,13.279630,14.464876,13.319124,12.331335,3.194438,9.866487,11.337083,8.958164,8.241395,4.289313,5.508243,4.737891,7.577698,9.626720,16.558392,10.309173,11.740863,8.761573,7.099866,10.032640) .. is there some easy way in R to programmatically and automatically find the most likely distribution and the estimated distribution parameters?

    Read the article

  • No difference between nullable:true and nullable:false in Grails 1.3.6?

    - by knorv
    The following domain model definition .. class Test { String a String b static mapping = { version(false) table("test_table") a(nullable: false) b(nullable: true) } } .. yields the following MySQL schema .. CREATE TABLE test_table ( id bigint(20) NOT NULL AUTO_INCREMENT, a varchar(255) NOT NULL, b varchar(255) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Please note that a and b get identical MySQL column definitions despite the fact a is defined as non-nullable and b is nullable in the GORM mappings. What am I doing wrong? I'm running Grails 1.3.6.

    Read the article

  • What is the cleanest way to do a sort plus uniq on a Python list?

    - by knorv
    Consider a Python list my_list containing ['foo', 'foo', 'bar']. What is the most Pythonic way to uniqify:ing and sorting and the list (think cat my_list | sort | uniq)? This is how I currently do it and while it works I'm sure there are better ways to do it. my_list = [] ... my_list.append("foo") my_list.append("foo") my_list.append("bar") ... my_list = set(my_list) my_list = list(my_list) my_list.sort()

    Read the article

  • Which Cassandra API provides the highest level of abstraction?

    - by knorv
    There are a lot of Cassandra API:s available and usually the programming language preference determines the choice of API. However, if we take the programming language component out of the equation, what Cassandra API provides the highest level of abstraction? Definition of "level of abstraction" in this context: An API providing a lot of extra goodies such as index handling, etc would be considered being at a higher abstraction layer than a bare bones "close to Thrift" API.

    Read the article

  • Fetching Cassandra row keys

    - by knorv
    Assume a Cassandra datastore with 20 rows, with row keys named "r1" .. "r20". Questions: How do I fetch the row keys of the first ten rows (r1 to r10)? How do I fetch the row keys of the next ten rows (r11 to r20)? I'm looking for the Cassandra analogy to: SELECT row_key FROM table LIMIT 0, 10; SELECT row_key FROM table LIMIT 10, 10;

    Read the article

  • Valid JavaScript code that is NOT valid ActionScript 3.0 code?

    - by knorv
    Most JavaScript code is also syntactically valid ActionScript 3.0 code. However, there are exceptions which leads me to my question: Which constructs/features in JavaScript are syntactically invalid in ActionScript 3.0? Please provide concrete examples of JavaScript code (basic JavaScript code without DOM API usage) that is NOT valid ActionScript 3.0 code.

    Read the article

  • Origin of discouraged perl idioms: &x(...) and sub x($$) { ... }

    - by knorv
    In my perl code I've previously used the following two styles of writing which I've later found are being discouraged in modern perl: # Style #1: Using & before calling a user-defined subroutine &name_of_subroutine($something, $something_else); # Style #2: Using ($$) to show the number of arguments in a user-defined sub sub name_of_subroutine($$) { # the body of a subroutine taking two arguments. } Since learning that those styles are not recommended I've simply stopped using them. However, out of curiosity I'd like to know the following: What is the origin of those two styles of writing? (I'm sure I've not dreamt up the styles myself.) Why are those two styles of writing discouraged in modern perl? Have the styles been considered best practice at some point in time?

    Read the article

  • Equivalent of alarm(3600) in Python

    - by knorv
    Starting a Perl script with alarm(3600) will make the script abort if it is still running after one hour (3600 seconds). Assume I want to set an upper bound on the running time of a Python script, what is the easiest way to achieve that?

    Read the article

  • Simple Java library for storing statistical observations and calculating statistics such as stddev,

    - by knorv
    For logging purposes I want to collect the response times of an external system, and periodically fetch various statistics (such as min/max/stddev) of the response times. I'm looking for a pure in-memory solution. What Java library can help me with this simple task? I'm looking for an API that would ideally look something along the lines of: StatisticsCollector s = new StatisticsCollector(); while (...) { double responseTime = ...; s.addObservation(responseTime); } double stddev = s.getStandardDeviation(); double mean = s.getMean();

    Read the article

< Previous Page | 1 2 3