Daily Archives

Articles indexed Friday May 21 2010

Page 8/114 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Where are the function literals in c++?

    - by academicRobot
    First of all, maybe literals is not the right term for this concept, but its the closest I could think of (not literals in the sense of functions as first class citizens). The idea is that when you make a conventional function call, it compiles to something like this: callq <immediate address> But if you make a function call using a function pointer, it compiles to something like this: mov <memory location>,%rax callq *%rax Which is all well and good. However, what if I'm writing a template library that requires a callback of some sort with a specified argument list and the user of the library is expected to know what function they want to call at compile time? Then I would like to write my template to accept a function literal as a template parameter. So, similar to template <int int_literal> struct my_template {...};` I'd like to write template <func_literal_t func_literal> struct my_template {...}; and have calls to func_literal within my_template compile to callq <immediate address>. Is there a facility in C++ for this, or a work around to achieve the same effect? If not, why not (e.g. some cataclysmic side effects)? How about C++0x or another language? Solutions that are not portable are fine. Solutions that include the use of member function pointers would be ideal. I'm not particularly interested in being told "You are a <socially unacceptable term for a person of low IQ>, just use function pointers/functors." This is a curiosity based question, and it seems that it might be useful in some (albeit limited) applications. It seems like this should be possible since function names are just placeholders for a (relative) memory address, so why not allow more liberal use (e.g. aliasing) of this placeholder. p.s. I use function pointers and functions objects all the the time and they are great. But this post got me thinking about the don't pay for what you don't use principle in relation to function calls, and it seems like forcing the use of function pointers or similar facility when the function is known at compile time is a violation of this principle, though a small one.

    Read the article

  • How Do I Schedule Cron to Run at Specific intervals?

    - by Russ
    I have 6 scripts that each take about 20 minutes to run, I want to schedule cron to run the first 3 at 00, 20, and 40 on the odd hours and the second 3 at the same intervals on the even hours. How can I tell cron to do this? is it something like this: 0 2,4,6,8,10,12,14,16,18,20,22,24 * * * root Script1 20 2,4,6,8,10,12,14,16,18,20,22,24 * * * root Script2 40 2,4,6,8,10,12,14,16,18,20,22,24 * * * root Script3 0 1,3,5,7,9,11,13,17,19,21,23 * * * root Script4 20 1,3,5,7,9,11,13,17,19,21,23 * * * root Script5 40 1,3,5,7,9,11,13,17,19,21,23 * * * root Script6

    Read the article

  • SQL SERVER – Simple Example of Snapshot Isolation – Reduce the Blocking Transactions

    - by pinaldave
    To learn any technology and move to a more advanced level, it is very important to understand the fundamentals of the subject first. Today, we will be talking about something which has been quite introduced a long time ago but not properly explored when it comes to the isolation level. Snapshot Isolation was introduced in SQL Server in 2005. However, the reality is that there are still many software shops which are using the SQL Server 2000, and therefore cannot be able to maintain the Snapshot Isolation. Many software shops have upgraded to the later version of the SQL Server, but their respective developers have not spend enough time to upgrade themselves with the latest technology. “It works!” is a very common answer of many when they are asked about utilizing the new technology, instead of backward compatibility commands. In one of the recent consultation project, I had same experience when developers have “heard about it” but have no idea about snapshot isolation. They were thinking it is the same as Snapshot Replication – which is plain wrong. This is the same demo I am including here which I have created for them. In Snapshot Isolation, the updated row versions for each transaction are maintained in TempDB. Once a transaction has begun, it ignores all the newer rows inserted or updated in the table. Let us examine this example which shows the simple demonstration. This transaction works on optimistic concurrency model. Since reading a certain transaction does not block writing transaction, it also does not block the reading transaction, which reduced the blocking. First, enable database to work with Snapshot Isolation. Additionally, check the existing values in the table from HumanResources.Shift. ALTER DATABASE AdventureWorks SET ALLOW_SNAPSHOT_ISOLATION ON GO SELECT ModifiedDate FROM HumanResources.Shift GO Now, we will need two different sessions to prove this example. First Session: Set Transaction level isolation to snapshot and begin the transaction. Update the column “ModifiedDate” to today’s date. -- Session 1 SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN UPDATE HumanResources.Shift SET ModifiedDate = GETDATE() GO Please note that we have not yet been committed to the transaction. Now, open the second session and run the following “SELECT” statement. Then, check the values of the table. Please pay attention on setting the Isolation level for the second one as “Snapshot” at the same time when we already start the transaction using BEGIN TRAN. -- Session 2 SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN SELECT ModifiedDate FROM HumanResources.Shift GO You will notice that the values in the table are still original values. They have not been modified yet. Once again, go back to session 1 and begin the transaction. -- Session 1 COMMIT After that, go back to Session 2 and see the values of the table. -- Session 2 SELECT ModifiedDate FROM HumanResources.Shift GO You will notice that the values are yet not changed and they are still the same old values which were there right in the beginning of the session. Now, let us commit the transaction in the session 2. Once committed, run the same SELECT statement once more and see what the result is. -- Session 2 COMMIT SELECT ModifiedDate FROM HumanResources.Shift GO You will notice that it now reflects the new updated value. I hope that this example is clear enough as it would give you good idea how the Snapshot Isolation level works. There is much more to write about an extra level, READ_COMMITTED_SNAPSHOT, which we will be discussing in another post soon. If you wish to use this transaction’s Isolation level in your production database, I would appreciate your comments about their performance on your servers. I have included here the complete script used in this example for your quick reference. ALTER DATABASE AdventureWorks SET ALLOW_SNAPSHOT_ISOLATION ON GO SELECT ModifiedDate FROM HumanResources.Shift GO -- Session 1 SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN UPDATE HumanResources.Shift SET ModifiedDate = GETDATE() GO -- Session 2 SET TRANSACTION ISOLATION LEVEL SNAPSHOT BEGIN TRAN SELECT ModifiedDate FROM HumanResources.Shift GO -- Session 1 COMMIT -- Session 2 SELECT ModifiedDate FROM HumanResources.Shift GO -- Session 2 COMMIT SELECT ModifiedDate FROM HumanResources.Shift GO Reference: Pinal Dave (http://blog.sqlauthority.com) Filed under: Pinal Dave, SQL, SQL Authority, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology Tagged: Transaction Isolation

    Read the article

  • how to grep for the whole word

    - by josh
    I am using the following command to grep stuff in subdirs find . | xargs grep -s 's:text' However, this also finds stuff like <s:textfield name="sdfsf"...../> What can I do to avoid that so it just finds stuff like <s:text name="sdfsdf"/> OR for that matter....also finds <s:text somethingElse="lkjkj" name="lkkj" basically s:text and name should be on same line....

    Read the article

  • statistical cosinor analysis,

    - by Jared
    Hey i am trying to calculate a cosinor analysis in statistica but am at a loss as to how to do so. I need to calculate the MESOR, AMPLITUDE, and ACROPHASE of ciracadian rhythm data. http://www.wepapers.com/Papers/73565/Cosinor_analysis_of_accident_risk_using__SPSS%27s_regression_procedures.ppt there is a link that shows how to do it, the formulas and such, but it has not given me much help. Does anyone know the code for it, either in statistica or SPSS?? I really need to get this done because it is for my thesis paper at UC Berkeley, if anyone can offer any help it would be so awesome.

    Read the article

  • How to load static files from view HTML in web2py?

    - by MikeWyatt
    Given a view with layout, how can I load static files (CSS and JS, essentially) into the <head> from the view file? layout.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{{=T.accepted_language or 'en'}}"> <head> <title>{{=response.title or request.application}}</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!-- include requires CSS files {{response.files.append(URL(request.application,'static','base.css'))}} {{response.files.append(URL(request.application,'static','ez-plug-min.css'))}} --> {{include 'web2py_ajax.html'}} </head> <body> {{include}} </body> </html> myview.html {{extend 'layout.html'}} {{response.files.append(URL(r=request,c='static',f='myview.css'))}} <h1>Some header</h1> <div> some content </div> In the above example, the "myview.css" file is either ignored by web2py or stripped out by the browser. So what is the best way to load page-specific files like this CSS file? I'd rather not stuff all my static files into my layout.

    Read the article

  • jQuery click event still firing on filtered element

    - by Phil.Wheeler
    I'm trying to filter button events based on whether they have a CSS class assigned to them or not. Assume I have a button like this: <button id="save-button" class="ui-state-default ui-corner-all">Save</button> I want to get jQuery to select all buttons that currently do not have a class of "ui-state-disabled". The selector I'm using looks like this: $('#save-button:not(.ui-state-disabled)').click(function() { ... }); When the button is clicked, I'll call a different function, do some stuff and then add the class 'ui-state-disabled' to the button. However the button still continues to accept click events. I'm guessing this is because of two possible causes: The event binder looks only at the initial state when binding the click event and doesn't recognise that a new class has been added later on My filter ['... :not(.ui-state-disabled)] is not correct Any observations?

    Read the article

  • How do I override ToString in C# enums?

    - by scraimer
    In the post Enum ToString, a method is described to use the custom attribute DescriptionAttribute like this: Enum HowNice { [Description("Really Nice")] ReallyNice, [Description("Kinda Nice")] SortOfNice, [Description("Not Nice At All")] NotNice } And then, you call a function GetDescription, using syntax like: GetDescription<HowNice>(NotNice); // Returns "Not Nice At All" But that doesn't really help me when I want to simply populate a ComboBox with the values of an enum, since I cannot force the ComboBox to call GetDescription. What I want has the following requirements: Reading (HowNice)myComboBox.selectedItem will return the selected value as the enum value. The user should see the user-friendly display strings, and not just the name of the enumeration values. So instead of seeing "NotNice", the user would see "Not Nice At All". Hopefully, the solution will require minimal code changes to existing enumerations. Obviously, I could implement a new class for each enum that I create, and override its ToString(), but that's a lot of work for each enum, and I'd rather avoid that. Any ideas? Heck, I'll even throw in a hug as a bounty :-)

    Read the article

  • PLT Scheme URL dispatch

    - by Inaimathi
    I'm trying to hook up URL dispatch with PLT Scheme. I've taken a look at the tutorial and the server documentation. I can figure out how to route requests to the same servlets. Specific example: (define (start request) (blog-dispatch request)) (define-values (blog-dispatch blog-url) (dispatch-rules (("") list-posts) (("posts" (string-arg)) review-post) (("archive" (integer-arg) (integer-arg)) review-archive) (else list-posts))) (define (list-posts req) `(list-posts)) (define (review-post req p) `(review-post ,p)) (define (review-archive req y m) `(review-archive ,y ,m)) Assuming the above code running on a server listening 8080, localhost:8080/ goes to a page that says "list-posts". Going to localhost:8080/posts/test goes to a PLT "file not found" page (with the above code, I'd expect it to go to a page that says "review-post test"). It feels like I'm missing something small and obvious. Can anyone give me a hint?

    Read the article

  • Saving current directory to zsh history

    - by user130208
    I wanted to achieve the same as asked here http://stackoverflow.com/questions/945288/saving-current-directory-to-bash-history but within zsh shell. I haven't done any zsh trickry before but so far I have: function precmd { hpwd=$history[$((HISTCMD-1))] if [[ $hpwd == "cd" ]]; then cwd=$OLDPWD else cwd=$PWD fi hpwd="${hpwd% ### *} ### $cwd" echo "$hpwd" ~/.hist_log } Right now I save the command annotated with the directory name to a log file. This works fine for me. Just thought there might be a way to make replacement in the history buffer itself.

    Read the article

  • Cross-platform HTML application options

    - by Charles
    I'd like to develop a stand-alone desktop application targeting Windows (XP through 7) and Mac (Tiger through Snow Leopard), and if possible iPhone and Android. In order to make it all work with as much common code as possible (and because it's the only thing I'm good at), I'd like to handle the main logic with HTML and JS. Using Adobe AIR is a possibility. And I think I can do this with various application wrappers, using .NET for Windows XP, Objective C for iPhone, Java for Android and native "widget" platform support for Mac and Windows Vista & 7 (though I'd like to keep the widget in the foreground, so the Mac dashboard isn't ideal). Does anyone have any suggestions on where to start? The two sticking points are: I'll certainly need some form of persistent storage (cookies perhaps) to keep state between sessions I'll also probably need access to remote data files, so if I use AJAX and the hosting HTML file resides on the device, it will need to be able to do cross-domain requests. I've done this on the iPhone without any problems, but I'd be surprised if this were possible on other platforms. For me, Android and iPhone will be the easiest to handle, and it looks like I can use Adobe AIR to handle the rest. But I wanted to know if there are any other alternatives. Does anyone have any suggesions?

    Read the article

  • Confusion about WPF binding...

    - by Vladislav
    I am trying to bind a 2D array of buttons arranged in stackpanels to a 2D ObservableCollection... Yet, I'm afraid I don't understand something very elementary about binding. My XAML: <Window.Resources> <DataTemplate x:Key="ItemsAsButtons"> <Button Content="{Binding}" Height="100" Width="100"/> </DataTemplate> <DataTemplate x:Key="PanelOfPanels"> <ItemsControl ItemsSource="{Binding Path=DayNumbers}" ItemTemplate=" {DynamicResource ItemsAsButtons}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </DataTemplate> </Window.Resources> ... <ItemsControl x:Name="DaysPanel" Grid.ColumnSpan="7" Grid.Row="2" ItemTemplate="{DynamicResource PanelOfPanels}"/> My C# code: The backend: /// <summary> /// Window BE for Calendar.xaml /// </summary> public partial class Calendar : Window { private CalendarViewModel _vm; public Calendar() { InitializeComponent(); _vm = new CalendarViewModel(); this.DataContext = _vm; } } The ViewModel: class CalendarViewModel { CalendarMonth _displayedMonth; EventCalendar _calendar; public CalendarViewModel() { _displayedMonth = new CalendarMonth(); } public ObservableCollection<ObservableCollection<int>> DayNumbers { get { return _displayedMonth.DayNumbers; } } } I'm trying to populate the buttons with values from CalendarViewModel.DayNumbers - yet the buttons do not appear. I'm clearly doing something wrong with my binding.

    Read the article

  • How can I pin a div in my sidebar column to the bottom?

    - by vg1890
    I have a simple two column layout with a footer at the bottom. When the content in the sidebar is taller than the content in the main column, everything looks great. But when the height of the main column is greater than the sidebar, I need the sidebar to grow to the same height as the main column and for the last <div> in the sidebar to be pinned to the very bottom. Here's my sample code: http://jsfiddle.net/mqnML/1/

    Read the article

  • Getting Emacs ansi-term and Zsh to play nicely

    - by mronge
    I've been trying to use Zsh within my emacs session, without emacs remapping all the Zsh keys. I found ansi-term works pretty well for this but, I'm still having some problems. I was getting lots of junk characters outputted with, I was able to fix it with: ## Setup proper term information for emacs ansi-term mode [[ $TERM == eterm-color ]] && export TERM=xterm But everything still doesn't work perfectly. Now I am having trouble with output being drawn offscreen , especially when using something like C-r for search. Any thoughts. Anyone else have Zsh + Ansi-term working properly?

    Read the article

  • Automate the installation of postfix on Ubuntu

    - by sutch
    My system configuration script does an "apt-get install -y postfix". Unfortunately the script is halted when the postfix installer displays a configuration page. Is there a method to force postfix to use the defaults during installation so that an automated script can continue to the end?

    Read the article

  • Which are the most important directories to backup on a Linux server?

    - by QAH
    Hello everyone! I'm running an Ubuntu 9.10 Linux server. I'm trying to find a way to backup the machine while it is running and from what I see, this eliminates the disk clone utilities. All of the disk clone stuff I have seen for Linux requires that you reboot into a special live CD. So my question is this, what is the best solution for backing up the system while it is running? Also, I don't really care about the OS config too much, I just want to be able to keep my stored files and my programs that I have installed on it. Thanks

    Read the article

  • Why release the NSURLConnection instance in this statement?

    - by aquaibm
    I read this in a book. -(IBAction) updateTweets { tweetsView.text = @""; [tweetsData release]; tweetsData = [[NSMutableData alloc] init]; NSURL *url = [NSURL URLWithString:@"http://twitter.com/statuses/public_timeline.xml" ]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL: url]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [connection release]; [request release]; [activityIndicator startAnimating]; } In this statement,is that correct to release the "connection" instance at that time? After releasing it which means this NSURLConnection instance will be destroyed since it's reference count is 0 ,how are we going to make this connection operation work? THANKS.

    Read the article

  • PHP Associative Array Duplicate Key?

    - by Steven
    Hello, I have an associative array, however when I add values to it using the below function it seems to overwrite the same keys. Is there a way to have multiple of the same keys with different values? Or is there another form of array that has the same format? I want to have 42=56 42=86 42=97 51=64 51=52 etc etc function array_push_associative(&$arr) { $args = func_get_args(); foreach ($args as $arg) { if (is_array($arg)) { foreach ($arg as $key => $value) { $arr[$key] = $value; $ret++; } }else{ $arr[$arg] = ""; } } return $ret; }

    Read the article

  • Servlets response.sendRedirect(String url) doesn't seems to send the encoding, why?

    - by Daziplqa
    Hi folks, I have some Servlet that explicity sets the character encoding and redirect to some servlet class Servlet1 extends HttpServle{ void doGet(..... ){ // ... request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"): //...... response.redirect(servlet2); } } class Servlet2 extends HttpServle{ void doGet(..... ){ // ... request.getCharacterEncoding(); // prints null ?? why??? //...... } } So, why the character encoding not being send with the request?

    Read the article

  • bash grep finding java declarations

    - by Amarsh
    i have a huge .java file and i want to find all declared objects given the className. i think the declaration will always have the following signature: className objName; or className objName = or className objName= can someone suggest me a grep pattern which will find these signatures. I have the following (incomplete) : cat $rootFile | grep "$className "

    Read the article

  • Any Name Entity Recognition - web services available

    - by Gublooo
    Hello I wanted to know if there are any paid or free named entity recognition web services available. Basically I'm looking for something - where if I pass a text like: "John had french fries at Burger King" It should be identify - something along the lines: Person: John Organization: Burger King I've heard of Annie from GATE - but I dont think it has a web service available. Thanks

    Read the article

  • Locking NFS files in PHP

    - by Oli
    Part of my latest webapp needs to write to file a fair amount as part of its logging. One problem I've noticed is that if there are a few concurrent users, the writes can overwrite each other (instead of appending to file). I assume this is because of the destination file can be open in a number of places at the same time. flock(...) is usually superb but it doesn't appear to work on NFS... Which is a huge problem for me as the production server uses a NFS array. The closest thing I've seen to an actual solution involves trying to create a lock dir and waiting until it can be created. To say this lacks elegance is understatement of the year, possibly decade. Any better ideas? Edit: I should add that I don't have root on the server and doing the storage in another way isn't really feasible any time soon, not least within my deadline.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >