Search Results

Search found 5176 results on 208 pages for 'max fraser'.

Page 32/208 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • Sql server query using function and view is slower

    - by Lieven Cardoen
    I have a table with a xml column named Data: CREATE TABLE [dbo].[Users]( [UserId] [int] IDENTITY(1,1) NOT NULL, [FirstName] [nvarchar](max) NOT NULL, [LastName] [nvarchar](max) NOT NULL, [Email] [nvarchar](250) NOT NULL, [Password] [nvarchar](max) NULL, [UserName] [nvarchar](250) NOT NULL, [LanguageId] [int] NOT NULL, [Data] [xml] NULL, [IsDeleted] [bit] NOT NULL,... In the Data column there's this xml <data> <RRN>...</RRN> <DateOfBirth>...</DateOfBirth> <Gender>...</Gender> </data> Now, executing this query: SELECT UserId FROM Users WHERE data.value('(/data/RRN)[1]', 'nvarchar(max)') = @RRN after clearing the cache takes (if I execute it a couple of times after each other) 910, 739, 630, 635, ... ms. Now, a db specialist told me that adding a function, a view and changing the query would make it much more faster to search a user with a given RRN. But, instead, these are the results when I execute with the changes from the db specialist: 2584, 2342, 2322, 2383, ... This is the added function: CREATE FUNCTION dbo.fn_Users_RRN(@data xml) RETURNS varchar(100) WITH SCHEMABINDING AS BEGIN RETURN @data.value('(/data/RRN)[1]', 'varchar(max)'); END; The added view: CREATE VIEW vwi_Users WITH SCHEMABINDING AS SELECT UserId, dbo.fn_Users_RRN(Data) AS RRN from dbo.Users Indexes: CREATE UNIQUE CLUSTERED INDEX cx_vwi_Users ON vwi_Users(UserId) CREATE NONCLUSTERED INDEX cx_vwi_Users__RRN ON vwi_Users(RRN) And then the changed query: SELECT UserId FROM Users WHERE dbo.fn_Users_RRN(Data) = '59021626919-61861855-S_FA1E11' Why is the solution with a function and a view going slower?

    Read the article

  • Problem with Clojure function

    - by Bozhidar Batsov
    Hi, everyone, I've started working yesterday on the Euler Project in Clojure and I have a problem with one of my solutions I cannot figure out. I have this function: (defn find-max-palindrom-in-range [beg end] (reduce max (loop [n beg result []] (if (>= n end) result (recur (inc n) (concat result (filter #(is-palindrom? %) (map #(* n %) (range beg end))))))))) I try to run it like this: (find-max-palindrom-in-range 100 1000) and I get this exception: java.lang.Integer cannot be cast to clojure.lang.IFn [Thrown class java.lang.ClassCastException] which I presume means that at some place I'm trying to evaluate an Integer as a function. I however cannot find this place and what puzzles me more is that everything works if I simply evaluate it like this: (reduce max (loop [n 100 result []] (if (>= n 1000) result (recur (inc n) (concat result (filter #(is-palindrom? %) (map #(* n %) (range 100 1000)))))))) (I've just stripped down the function definition and replaced the parameters with constants) Thanks in advance for your help and sorry that I probably bother you with idiotic mistake on my part. Btw I'm using Clojure 1.1 and the newest SLIME from ELPA.

    Read the article

  • Eliminate subquery for average numeric value

    - by Dave Jarvis
    Quest A query selects locations that begin with Vancouver, which are in a 5 minute radius from one another. SQL Code The following SQL abomination does the trick: SELECT NAME FROM STATION WHERE DISTRICT_ID = '110' AND NAME LIKE 'Vancouver%' AND LATITUDE BETWEEN (SELECT round((min(LATITUDE) + max(LATITUDE)) / 2)-5 FROM STATION WHERE DISTRICT_ID = '110' AND NAME LIKE 'Vancouver%') and (SELECT round((min(LATITUDE) + max(LATITUDE)) / 2)+5 FROM STATION WHERE DISTRICT_ID = '110' AND NAME LIKE 'Vancouver%') AND LONGITUDE BETWEEN (SELECT round((min(LONGITUDE) + max(LONGITUDE)) / 2)-5 FROM STATION WHERE DISTRICT_ID = '110' AND NAME LIKE 'Vancouver%') and (SELECT round((min(LONGITUDE) + max(LONGITUDE)) / 2)+5 FROM STATION WHERE DISTRICT_ID = '110' AND NAME LIKE 'Vancouver%') ORDER BY LATITUDE Question How can this query be simplified to remove the redundancy, without using a view? Restrictions The database is MySQL, but ANSI SQL is always nice. Thank you!

    Read the article

  • vba excel: do something every time a certain variable is changed

    - by every_answer_gets_a_point
    im doing a bunch of stuff to the variable St For i = 1 To 30000 Randomize e1 = Rnd e2 = Rnd z1 = Sqr(-2 * Log(e1)) * Cos(2 * 3.14 * e2) z2 = Sqr(-2 * Log(e1)) * Sin(2 * 3.14 * e2) St = So * Exp((r - (sigma ^ 2) / 2) * T + sigma * Sqr(T) * z1) C = C + Application.WorksheetFunction.Max(St - K, 0) St = So * Exp((r - (sigma ^ 2) / 2) * T - sigma * Sqr(T) * z1) C = C + Application.WorksheetFunction.Max(St - K, 0) St = So * Exp((r - (sigma ^ 2) / 2) * T + sigma * Sqr(T) * z2) C = C + Application.WorksheetFunction.Max(St - K, 0) St = So * Exp((r - (sigma ^ 2) / 2) * T - sigma * Sqr(T) * z2) C = C + Application.WorksheetFunction.Max(St - K, 0) Next i how do i get notified every time the variable changes?

    Read the article

  • Java algorithm for normalizing audio

    - by Marty Pitt
    I'm trying to normalize an audio file of speech. Specifically, where an audio file contains peaks in volume, I'm trying to level it out, so the quiet sections are louder, and the peaks are quieter. I know very little about audio manipulation, beyond what I've learnt from working on this task. Also, my math is embarrassingly weak. I've done some research, and the Xuggle site provides a sample which shows reducing the volume using the following code: (full version here) @Override public void onAudioSamples(IAudioSamplesEvent event) { // get the raw audio byes and adjust it's value ShortBuffer buffer = event.getAudioSamples().getByteBuffer().asShortBuffer(); for (int i = 0; i < buffer.limit(); ++i) buffer.put(i, (short)(buffer.get(i) * mVolume)); super.onAudioSamples(event); } Here, they modify the bytes in getAudioSamples() by a constant of mVolume. Building on this approach, I've attempted a normalisation modifies the bytes in getAudioSamples() to a normalised value, considering the max/min in the file. (See below for details). I have a simple filter to leave "silence" alone (ie., anything below a value). I'm finding that the output file is very noisy (ie., the quality is seriously degraded). I assume that the error is either in my normalisation algorithim, or the way I manipulate the bytes. However, I'm unsure of where to go next. Here's an abridged version of what I'm currently doing. Step 1: Find peaks in file: Reads the full audio file, and finds this highest and lowest values of buffer.get() for all AudioSamples @Override public void onAudioSamples(IAudioSamplesEvent event) { IAudioSamples audioSamples = event.getAudioSamples(); ShortBuffer buffer = audioSamples.getByteBuffer().asShortBuffer(); short min = Short.MAX_VALUE; short max = Short.MIN_VALUE; for (int i = 0; i < buffer.limit(); ++i) { short value = buffer.get(i); min = (short) Math.min(min, value); max = (short) Math.max(max, value); } // assign of min/max ommitted for brevity. super.onAudioSamples(event); } Step 2: Normalize all values: In a loop similar to step1, replace the buffer with normalized values, calling: buffer.put(i, normalize(buffer.get(i)); public short normalize(short value) { if (isBackgroundNoise(value)) return value; short rawMin = // min from step1 short rawMax = // max from step1 short targetRangeMin = 1000; short targetRangeMax = 8000; int abs = Math.abs(value); double a = (abs - rawMin) * (targetRangeMax - targetRangeMin); double b = (rawMax - rawMin); double result = targetRangeMin + ( a/b ); // Copy the sign of value to result. result = Math.copySign(result,value); return (short) result; } Questions: Is this a valid approach for attempting to normalize an audio file? Is my math in normalize() valid? Why would this cause the file to become noisy, where a similar approach in the demo code doesn't?

    Read the article

  • MySQL - how to retrieve columns in same row as the values returned by min/mx

    - by Gala101
    I couldn't frame the Question's title properly.. Suppose a table of weekly movie Earnings as below, MovieName MovieGross WeekofYear Year So how do I get the names of top grossers for each week of this year If I do select MovieName , Max(MovieGross) , WeekofYear from earnings where year = 2010 group by WeekofYear; Then obviously query wont run, select Max(MovieName) , Max(MovieGross) , WeekofYear from earnings where year = 2010 group by WeekofYear; would just give movies starting with lowest alphabet Is using group-concat and then substring-index the only option here? select substring_index(group_concat(MovieName order by MovieGross desc),',',1), Max(MovieGross) , WeekofYear from earnings where year = 2010 group by WeekofYear ; Seems clumsy.. Is there any better way of acieveing this?

    Read the article

  • C# program for finding how many numbers are devidable by 5 in give range

    - by user1639735
    My task is: Write a program that reads two positive integer numbers and prints how many numbers p exist between them such that the reminder of the division by 5 is 0 (inclusive). Example: p(17,25) = 2. Console.Write("Enter min: "); int min = int.Parse(Console.ReadLine()); Console.Write("Enter max: "); int max = int.Parse(Console.ReadLine()); Console.WriteLine("The numbers devidable by 5 without remainder from {0} to {1} are: ",min,max); for (int i = min; i <= max; i++) { if (i % 5 == 0) { Console.WriteLine(i); } } This prints out the numbers that are devidable by 5 in the range...How do I count how many are there and print the count in the console? Thanks.

    Read the article

  • Am I doing something wrong here (references in C++)?

    - by m4design
    I've been playing around with references (I'm still having issues in this regard). 1- I would like to know if this is an acceptable code: int & foo(int &y) { return y; // is this wrong? } int main() { int x = 0; cout << foo(x) << endl; foo(x) = 9; // is this wrong? cout << x << endl; return 0; } 2- Also this is from an exam sample: Week & Week::highestSalesWeek(Week aYear[52]) { Week max = aYear[0]; for(int i = 1; i < 52; i++) { if (aYear[i].getSales() > max.getSales()) max = aYear[i]; } return max; } It asks about the mistake in this code, also how to fix it. My guess is that it return a local reference. The fix is: Week & max = aYear[0]; Is this correct/enough?

    Read the article

  • How to remove duplicates from multidimensional array in php

    - by JackTurky
    i have an array like: Array ( [prom] => Array ( [cab] => Array ( [0] => Array ( [code] => 01 [price1] => 1000 [price2] => 2000 [available] => 2 [max] => 2 [gca] => 2 ) [1] => Array ( [code] => 04 [price1] => 870 [price2] => 2500 [available] => 3 [max] => 4 [gca] => 10 ) [2] => Array ( [code] => 01 [price1] => 1000 [price2] => 2000 [available] => 2 [max] => 2 [gca] => 2 ) [3] => Array ( [code] => 05 [price1] => 346 [price2] => 1022 [available] => 10 [max] => 2 [gca] => 20 ) ) [cab1] => Array........ ) [prom1] = Array.... ) What i have to do is to remove duplicates inside every [cab*] array.. so to have something like: Array ( [prom] => Array ( [cab] => Array ( [0] => Array ( [code] => 01 [price1] => 1000 [price2] => 2000 [available] => 2 [max] => 2 [gca] => 2 ) [1] => Array ( [code] => 04 [price1] => 870 [price2] => 2500 [available] => 3 [max] => 4 [gca] => 10 ) [2] => Array ( [code] => 05 [price1] => 346 [price2] => 1022 [available] => 10 [max] => 2 [gca] => 20 ) ) [cab1] => Array........ ) [prom1] = Array.... ) In know that there is array_unique combined with array_map to remove duplicates.. but i know that it works only on 2D array.. what can i do? can someone help me pls? thanks!!!

    Read the article

  • Counting a cell up per Objects

    - by Auro
    hey i got a problem once again :D a little info first: im trying to copy data from one table to an other table(structure is the same). now one cell needs to be incremented, beginns per group at 1 (just like a histroy). i have this table: create table My_Test/My_Test2 ( my_Id Number(8,0), my_Num Number(6,0), my_Data Varchar2(100)); (my_Id, my_Num is a nested PK) if i want to insert a new row, i need to check if the value in my_id already exists. if this is true then i need to use the next my_Num for this Id. i have this in my Table: My_Id My_Num My_Data 1 1 'test1' 1 2 'test2' 2 1 'test3' if i add now a row for my_Id 1, the row would look like this: i have this in my Table: My_Id My_Num My_Data 1 3 'test4' this sounds pretty easy ,now i need to make it in a SQL and on SQL Server i had the same problem and i used this: Insert Into My_Test (My_Id,My_Num,My_Data) SELECT my_Id, ( SELECT CASE ( CASE MAX(a.my_Num) WHEN NULL THEN 0 Else Max(A.My_Num) END) + b.My_Num WHEN NULL THEN 1 ELSE ( CASE MAX(a.My_Num) WHEN NULL THEN 0 Else Max(A.My_Num) END) + b.My_Num END From My_Test A where my_id = 1 ) ,My_Data From My_Test2 B where my_id = 1; this Select gives null back if no Rows are found in the subselect is there a way so i could use max in the case? and if it give null back it should use 0 or 1? greets Auro

    Read the article

  • SQL: HAVING clause

    - by Craig Johnston
    See the following SQL statement: SELECT datediff("d", MAX(invoice.date), Now) As Date_Diff, MAX(invoice.date) AS max_invoice_date, customer.number AS customer_number FROM invoice INNER JOIN customer ON invoice.customer_number = customer.number GROUP BY customer.number If the the following was added: HAVING datediff("d", MAX(invoice.date), Now) > 365 would this simply exclude rows with Date_Diff <= 365? What should be the effect of the HAVING clause here?

    Read the article

  • How to call a set of variables functions based on class on a group of elements

    - by user1547007
    I have the following html code: <i class="small ele class1"></i> <i class="medium ele class1"></i> <i class="large ele class1"></i> <div class="clear"></div> <i class="small ele class2"></i> <i class="medium ele class2"></i> <i class="large ele class2"></i> <div class="clear"></div> <i class="small ele class3"></i> <i class="medium ele class3"></i> <i class="large ele class3"></i> <div class="clear"></div> <i class="small ele class4"></i> <i class="medium ele class4"></i> <i class="large ele class4"></i>? And my javascript looks like so: var resize = function(face, s) { var bb = face.getBBox(); console.log(bb); var w = bb.width; var h = bb.height; var max = w; if (h > max) { max = h; } var scale = s / max; var ox = -bb.x+((max-w)/2); var oy = -bb.y+((max-h)/2); console.log(s+' '+h+' '+bb.y); face.attr({ "transform": "s" + scale + "," + scale + ",0,0" + "t" + ox + "," + oy }); } $('.ele').each(function() { var s = $(this).innerWidth(); var paper = Raphael($(this)[0], s, s); var face = $(this).hasClass("class1") ? class1Generator(paper) : class4Generator(paper); /*switch (true) { case $(this).hasClass('class1'): class1Generator(paper); break; case $(this).hasClass('class2'): class2Generator(paper) break; case $(this).hasClass('class3'): class3Generator(paper) break; case $(this).hasClass('class4'): class4Generator(paper) break; }*/ resize(face, s); }); my question is, how could I make this line of code more scalable? I tried using a switch but The script below is calling two functions if one of the elements has a class, but what If i have 10 classes? I don't think is the best solution I created a jsFiddle http://jsfiddle.net/7uUgz/6/ //var face = $(this).hasClass("awesome") ? awesomeGenerator(paper) : awfulGenerator(paper);

    Read the article

  • Javascript : random number between variables issue

    - by Mayhem
    I've seen the other examples on this site but I just can't get it to work. I'm trying to generate a random number between 2 user input variables on a form. The numbers will always be positive numbers. min = document.getElementById('min').value; max = document.getElementById('max').value; waitTimer = Math.floor(Math.random() * (max - min + 1)) + min; When min = 5 / max = 10, waitTimer is sometimes returning results like 2, 4 and 28 and so on. What am I doing wrong?

    Read the article

  • Javascript int variable from ASP.NET MVC Model data?

    - by Anders Svensson
    I need to get model data into a javascript variable and use it as an int to compare values. But I can only figure out how to get the model data as strings, otherwise the compiler complains. So how can I get the max and taskBudgetHours as int variables in the Javascript? <script type="text/javascript"> $(document).ready(function () { $("#taskForm").submit(function (e) { var taskBudgetHours = $('#BudgetHours').val(); var max = '<%: Model.Project.RemainingBudgetHours %>'; var test = 'test'; alert(taskBudgetHours); alert(max); if (taskBudgetHours <= max) { //This doesn't work, seems to treat it as strings... return true; } else { //Prevent the submit event and remain on the screen e.preventDefault(); alert('There are only ' + max + ' hours left of the project hours.'); return false; } }); return; }); </script>

    Read the article

  • session variable values are not being passed between pages

    - by ravi nankani
    hi, i am a little new to php and although i have managed to pass values of session variables before this piece of code is leaving me puzzled <form action="team_reg2.php" method="post" name="form1" class="cent" id="form1"> Team Registration "; print "member$i"; print "\n"; print "\n"; print "Please enter only id\n"; } ? now this will pass via post to team_reg2.php echo " please note your team id is 1 "; echo " your team members are : "; for($i=1;$i<=$num;$i++) { $name='mem'.$i; echo "$_POST[$name]"; } } else { $str="select * from $query where ("; for($i=1;$i<=$num;$i++) { $name='mem'.$i; $text="p_id='$_POST[$name]'"; if($i==1) $str=$str.$text; else $str=$str.' or '.$text; } $str=$str.')'; $query2=$str; echo "$str"; // echo "$query2"; $que=mysql_query($query2,$con) or die(mysql_error()); $num=mysql_num_rows($que); if($num!=0) { while($result=mysql_fetch_array($que)) { echo "$result[p_id] is already registered in team $result[t_id]"; } //include("reg_team.html"); } else if($num==0) { //echo $query; $query2="select max(t_id) from $query"; $que=mysql_query($query2,$con) or die(mysql_error()); //echo "$que"; $result=mysql_fetch_array($que); $max=$result['max(t_id)']; $max++; $num=$_SESSION['max_team']; for($i=1;$i<=$num;$i++) { $name='mem'.$i; if($_POST[$name]!="") { $query2="insert into $query values($max,'$_POST[$name]')"; $que=mysql_query($query2,$con); } } echo " please note your team id is $max "; echo " your team members are : "; for($i=1;$i<=$num;$i++) { $name='mem'.$i; echo "$_POST[$name]"; } } } ? i have done session_start(); at the beginning of the page itself. The problem is that echoing $_SESSION variables in second file is not printing anything. someone please explain me whats going on. thank you

    Read the article

  • Why is my long polling code for a notification system not updating in real time? PHP MYSQL

    - by tjones
    I am making a notification system similar to the red notification on facebook. It should update the number of messages sent to a user in real time. When the message MYSQL table is updated, it should instantly notify the user, but it does not. There does not seem to be an error inserting into MYSQL because on page refresh the notifications update just fine. I am essentially using code from this video tutorial: http://www.screenr.com/SNH (which updates in realtime if a data.txt file is changed, but it is not written for MYSQL like I am trying to do) Is there something wrong with the below code: **Javascript** <script type="text/javascript"> $(document).ready(function(){ var timestamp = null; function waitForMsg(){ $.ajax({ type: "GET", url: "getData.php", data: "userid=" + userid, async: true, cache: false, success: function(data){ var json = eval('(' + data + ')'); if (json['msg'] != "") { $('.notification').fadeIn().html(json['msg']); } setTimeout('waitForMsg()',30000); }, error: function(XMLHttpRequest, textStatus, errorThrown){ setTimeout('waitForMsg()',30000); } }); } waitForMsg(); </script> <body> <div class="notification"></div> **PHP*** <?php if ($_SERVER['REQUEST_METHOD'] == 'GET' ) { $userid = $_GET['userid']; include("config.php"); $sql="SELECT MAX(time) FROM notification WHERE userid='$userid'"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $currentmodif = $row['MAX(time)']; $s="SELECT MAX(lasttimeread) FROM notificationsRead WHERE submittedby='$userid'"; $r = mysql_query($s); $rows = mysql_fetch_assoc($r); $lasttimeread = $rows['MAX(lasttimeread)']; while ($currentmodif <= $lasttimeread) { usleep(10000); clearstatcache(); $currentmodif = $row['MAX(time)']; } $response = array(); $response['msg'] = You have new messages; echo json_encode($response); } ?>

    Read the article

  • How can we find second maximum from array efficiently?

    - by Xinus
    Is it possible to find the second maximum number from an array of integers by traversing the array only once? As an example, I have a array of five integers from which I want to find second maximum number. Here is an attempt I gave in the interview: #define MIN -1 int main() { int max=MIN,second_max=MIN; int arr[6]={0,1,2,3,4,5}; for(int i=0;i<5;i++){ cout<<"::"<<arr[i]; } for(int i=0;i<5;i++){ if(arr[i]>max){ second_max=max; max=arr[i]; } } cout<<endl<<"Second Max:"<<second_max; int i; cin>>i; return 0; } The interviewer, however, came up with the test case int arr[6]={5,4,3,2,1,0};, which prevents it from going to the if condition the second time. I said to the interviewer that the only way would be to parse the array two times (two for loops). Does anybody have a better solution?

    Read the article

  • Rails 3 - raw/html_safe not working in some cases?

    - by Frexuz
    I'm having difficulties with output not being encoded even though I'm using raw or html_safe. This one is writing out the &nbsp in my final HTLM page. def build_tag_cloud(tag_cloud, style_list) tag_cloud.sort!{ |x,y| x.permalink <=> y.permalink } max, min = 0, 0 tag_cloud.each do |tag| max = tag.followers.to_i if tag.followers.to_i > max min = tag.followers.to_i if tag.followers.to_i < min end divisor = ((max - min) / style_list.size) + 1 html = "" tag_cloud.each do |tag| name = raw(tag.name.gsub('&','&amp;').gsub(' ','&nbsp;')) link = raw(link_to "#{name}", {:controller => "/shows", :action => "show", :permalink => tag.permalink}, :class => "#{style_list[(tag.followers.to_i - min) / divisor]}") html += raw("<li>#{link}</li> ") end return raw(html.to_s) end What is allowed in using raw and html_safe? And how should my example above be fixed?

    Read the article

  • Date & time query question (sql-server 2008)

    - by Gold
    hi i have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45 4|01/04/2004|12:55 i need to know the difference between the MAX(date) and the MIN(date) and the MAX(time) and the MIN(time) something like.... MAX(date)-MIN(date) ???..... thank's in advance

    Read the article

  • How can i access the value of the moving slider in a jquery variable

    - by user1673591
    html <h1>HTML Slider Test</h1> <div class="slider" data-max="10"></div> <p>Your slider has a value of <span class="slider-value"></span></p> <div class="slider" data-max="100"></div> <p>Your slider has a value of <span class="slider-value"></span></p> jquery $(".slider").each(function() { $(this).slider({ value : 1, min : 1, max : $(this).data('max'), step : 1, slide : function (event, ui) { var a= $(this).next().find('span.slider-value').html(ui.value); } }); }); I want the value of the moving slider in a jquery variable

    Read the article

  • PHP cache header override

    - by Soyo
    I've been through over 100 answers here, lots to try, NOTHING working?? Have a PHP based site. I need caching OFF for all .php files EXCEPT A SELECT FEW. So, in .htaccess, I have the following: ExpiresActive On # Eliminate caching for certain dynamic files <FilesMatch "\.(php|cgi|pl)$"> ExpiresDefault A0 Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform" Header set Pragma "no-cache" </FilesMatch> Using Firebug, I see the following: Cache-Control no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform Connection Keep-Alive Content-Type text/html Date Sun, 02 Sep 2012 19:22:27 GMT Expires Sun, 02 Sep 2012 19:22:27 GMT Keep-Alive timeout=3, max=100 Pragma no-cache Server Apache Transfer-Encoding chunked X-Powered-By PHP/5.2.17 Hey, Looks great! BUT, I have a couple .php pages I need some very short caching on. I thought the simple answer was having this added to the very top of each php page in which I want caching enabled: <?php header("Cache-Control: max-age=360"); ?> Nope. Then I tried various versions of the above. Nope. Then I tried meta http-equiv variations. Nope. Then I tried variations of the .htaccess code along with the above variations, such as limiting it to: # Eliminate caching for certain dynamic files <FilesMatch "\.(php|cgi|pl)$"> Header set Cache-Control "no-cache, max-age=0" </FilesMatch> Nope. It seems nothing I do will allow a single .php to be cache enabled with the .htaccess code in place, short of removing the statements from the .htaccess file altogether. Where am I going wrong? What do I have to do to get individual php pages to be cacheable while the rest remain off?? Thank you for any thoughts.

    Read the article

  • Querying for a unique value based on the aggregate of another value while grouping on a third value

    - by Justin Swartsel
    So I know this problem isn't a new one, but I'm trying to wrap my head around it and understand the best way to deal with scenarios like this. Say I have a hypothetical table 'X' that looks like this: GroupID ID (identity) SomeDateTime -------------------------------------------- 1 1000 1/1/01 1 1001 2/2/02 1 1002 3/3/03 2 1003 4/4/04 2 1004 5/5/05 I want to query it so the result set looks like this: ---------------------------------------- 1 1002 3/3/03 2 1004 5/5/05 Basically what I want is the MAX SomeDateTime value grouped by my GroupID column. The kicker is that I DON'T want to group by the ID column, I just want to know the 'ID' that corresponds to the MAX SomeDateTime. I know one pseudo-solution would be: ;WITH X1 as ( SELECT MAX(SomeDateTime) as SomeDateTime, GroupID FROM X GROUP BY GroupID ) SELECT X1.SomeDateTime, X1.GroupID, X2.ID FROM X1 INNER JOIN X as X2 ON X.DateTime = X2.DateTime But this doesn't solve the fact that a DateTime might not be unique. And it seems sloppy to join on a DateTime like that. Another pseudo-solution could be: SELECT X.GroupID, MAX(X.ID) as ID, MAX(X.SomeDateTime) as SomeDateTime FROM X GROUP BY X.GroupID But there are no guarantees that ID will actually match the row that SomeDateTime comes from. A third less useful option might be: SELECT TOP 1 X.GroupID, X.ID, X.SomeDateTime FROM X WHERE X.GroupID = 1 ORDER BY X.SomeDateTime DESC But obviously that only works with a single, known, GroupID. I want to be able to join this result set on GroupID and/or ID. Does anyone know of any clever solutions? Any good uses of windowing functions? Thanks!

    Read the article

  • C++ Problem resolution - is it the best way to simulate a "tuple"?

    - by fbin
    Hi everyone! I've got the following problem: "Write a template function vectorMAXMIN() that will accept a vector and a number indicating the size of the vector and will return the max and the min values of the vector"... So i think in it... Create a class vector to avoid the "size" passing value and control the insertions and can get from this the max and min values... ( dunno if it's a good idea ) The problem is "how to return a tuple?" When i read the problem, i thought in a tuple to return "max, min values" is it correct? The code: #include <iostream> template < typename T > class _tuple { public: T _Max; T _Min; }; template < typename T > class _vector { public: _vector( int cnt = 0); ~_vector(); _tuple< T > get_tuple( void ); void insert( const T ); private: T *ptr; int cnt; int MAX; }; template < typename T > _vector< T >::_vector( int N ) { ptr = new T [N] ; MAX = N; cnt = 0; } template < typename T > _tuple<T> _vector< T >::get_tuple( void ) { _tuple< T > _mytuple; _mytuple._Max = ptr[0]; _mytuple._Min = ptr[0]; for( int i = 1; i < cnt; i++) { if( _mytuple._Max > ptr[i] ) _mytuple._Max = ptr[i]; if( _mytuple._Min < ptr[i] ) _mytuple._Min = ptr[i]; } return _mytuple; } template < typename T > void _vector< T >::insert( const T element) { if( cnt == MAX ) std::cerr << "Error: Out of range!" << std::endl; else { ptr[cnt] = element; cnt++; } } template < typename T > _vector< T >::~_vector() { delete [] ptr; } int main() { _vector< int > v; _tuple < int > t; v.insert(2); v.insert(1); v.insert(5); v.insert(0); v.insert(4); t = v.get_tuple(); std::cout << "MAX:" << t._Max; std::cout << " MIN:" << t._Min; return 0; }

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >