I have the following structure:
<form>
<div class="content">
...
</div>
<div class="action">
<p>Select <a class="select_all" href="?select=1" title="Select All">All</a></p>
</div>
</form>
I am using Prototype's up() to traverse the DOM in order to find the <form> element in respect to the a.select_all. However the following doesn't work:
select_link.up('form'); // returns undefined
Yet, this does.
select_link.up().up().up(); // returns HTMLFormElement
Clearly this is an ancestor of a.select_all. The API Docs state Element.up() supports a CSSRule. What am I missing here?
I need to tag the current state of my source tree in svn. My problem is I don't care what the name is, I just need to mark the current revision in an immutable* manner. (*subject to malicious behavior)
What's the best way to do this?
branches/
tags/
???
trunk/
should ??? be the date, an incrementing sequence, the repository rev # ...?
I've had some trouble getting my Rails app to connect to PostgreSQL so I decided to just say screw it and use SQLite for now. (I'm using the tutorial here: http://guides.rubyonrails.org/getting_started.html)
I started a BRAND NEW, fresh Rails app from this tutorial. When I visit my app in the browser after deleting public/index.html, I get this the first time:
Please install the pg adapter: `gem install activerecord-pg-adapter` (no such file to load -- active_record/connection_adapters/pg_adapter)
That's odd to me because I'm not mentioning PostgreSQL anywhere. Here's my databases.yml:
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
To make things more confusing, I only get that "pg adapter" error on the first load. For every subsequent page request, I get this error:
ActiveRecord::ConnectionNotEstablished
So even though I removed all mention of PostgreSQL, I'm still getting errors. What could be going on?
Given two points in a 2D plane, and a circle of radius r that intersects both of those points, what would be the formula to calculate the centre of that circle?
I realise there would two places the circle can be positioned. I would want the circle whose centre is encountered first in a clockwise direction when sweeping the line that joins the two points around one of those points, starting from an arbitrary angle. I guess that is the next stage in my problem, after I find an answer for the first part.
I'm hoping the whole calculation can be done without trigonometry for speed. I'm starting with integer coordinates and will end with integer coordinates, if that helps.
I'm implementing Bagwell's Ideal Hash Trie in Haskell. To find an element in a sub-trie, he says to do the following:
Finding the arc for a symbol s,
requires ?nding its corresponding bit
in the bit map and then counting the
one bits below it in the map to
compute an index into the ordered
sub-trie.
What is the best way to do this? It sounds like the most straightforward way of doing this is to select the bits below that bit and do a population count on the resulting number. Is there a faster or better way to do this?
I have some of the basic coding down for the program but I do need assistance with something. My goal is to have an alarm go off on multiple PC's in a network indicating that a certain task needs done. Anyone who receives this alarm may stop it, complete the task and log that they did that. What would be the best way to accomplish this in a network? But not every computer in the network will be running this program, just a few.
I have a question regarding the use of the MVC framework for a blackjack game im writing in java. As I understand, my model would be a class that stores the state of the game, and more specifically, each players hand. Within the model class, I would have an array of listeners, which would be notified each time the game state changes (ie a player has drawn a new card).
These listeners would be my viewer, which is the class that handles the display of the game. This class would implement the ActionListener interface, and each time the model changes, it would call/"notify" my viewer's actionPerformed method.
My question is as follows:
I intend to have two JPanels, each devoted to displaying the respective player's hand. As a player draws a new card, a new ImageIcon would be added to the panel. My question is how would the viewer class know what card has been added to the player's hand?
I suppose I could store the player's hand before a notify event, and then upon the notification event, compare the new state with the old, to find out what has changed. I'm a complete novice here, so I could be completely wrong, but it seems a bit tedious to do this.
Is there a more efficient/common way of detecting what has changed in the model between the before and after state? Another solution would be to redraw the entire panel each time the notification occurs? Would this be a better idea?
I'm trying to restart the service from a remote machine. Here is my code. The problem is that I need to enter startinfo.filename = "sc.exe" since I'm putting "start /wait sc" this is causing an error. Here is my code, any thoughts. Also if anyone has any idea how to keep the cmd window open after this is ran so I could see the code that was ran that would be awesome.
string strCommandStop1;
string strCommandStop2;
string strCommandStart1;
string strCommandStart2;
string strServer = "\\" + txtServerName.Text;
string strDb1 = "SqlAgent$" + txtInsName.Text;
string strDb2 = "MSSQL$" + txtInsName.Text;
strCommandStop1 = @"start /wait sc " + strServer + " Stop " + strDb1;
strCommandStop2 = @"start /wait sc " + strServer + " Stop " + strDb2;
strCommandStart1 = @"start /wait sc " + strServer + " Start " + strDb2;
strCommandStart2 = @"start /wait sc " + strServer + " Start " + strDb1;
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.Arguments = strCommandStop1;
startInfo.Arguments = strCommandStop2;
startInfo.Arguments = strCommandStart1;
startInfo.Arguments = strCommandStart2;
startInfo .FileName = "sc.exe";
Process.Start(startInfo);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
I'm curious if there is an efficient way to wait for the front page of a site to load, and then pre-load CSS and script files that I know will likely be needed for the other pages on the site.
I want the front page of the site to be as fast as possible (lean and mean). It's likely that the user will not immediately click on a link. Since there will likely be some idle time, this seems like an opportune time to pre-load some of the external assets. Pre-loading should cause them to become cached. When the user does click on another page, the only request needed will be for the content and possibly some images, etc.
Has anyone done this?
Is it a bad idea?
Is there an elegant way to implement it?
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
onmouseover="text.show('<br /><b>XXXXXX</b><br />')"
Validation Output: Error:
character "<" is the first character of a delimiter but occurred as data
How can I fix it?
thanks
Duplicate of: What’s the simplest way to import a System.Data.DataSet into Excel?
Using c# under VS2008, we can create an excel app, workbook, and then worksheet fine by doing this:
Application excelApp = new Application();
Workbook excelWb = excelApp.Workbooks.Add(template);
Worksheet excelWs = (Worksheet)this.Application.ActiveSheet;
Then we can access each cell by "excelWs.Cells[i,j]" and write/save without problems. However with large numbers of rows/columns, we are expecting a loss in efficiency.
Is there a way to "data bind" from a DataSet object into the worksheet without using the cell-by-cell approach? Most of the methods we have seen at some point revert to the cell-by-cell approach. Thanks for any suggestions.
The company I work for develops a large application which is almost entirely based on stored procedures.
We use classic ASP and SQL Server and the major part of the business logic is contained inside those stored procedures.
For example, (I know, this is bad...) a single stored procedure can be used for different purposes (insert, update, delete, make some calculations, ...). Most of the time, a stored procedure is used for operations on related tables, but this is not always the case.
We are planning to move to ASP.NET in a near future.
I have read a lot of posts on StackOverflow recommending that I move the business logic outside the database.
The thing is, I have tried to convince the people who takes the decisions at our company and there is nothing I can do to change their mind.
Since I want to be able to use the advantages of object-oriented programming, I want to map the tables to actual classes.
So far, my solution is to use an ORM (Entity Framework 4 or nHibernate) to avoid mapping the objects manually (mostly to retrieve the data)
and use some kind of Data Access Layer to call the existing stored procedures (for saving).
I want your advice on this.
Do you think it is a good solution? Any ideas?
I constantly hear from other people about how much of the stuff they've used to customize their *nix setup they've shamelessly stolen from other people. So in that spirit, I'd like to start a place to share that stuff here on SO.
Here are the rules:
DON'T POST YOUR ENTIRE DOTFILE. Instead, just show us the cool stuff.
One recipe per answer
You may, however, post multiple versions of your recipe in the same answer. For example, you may post a version that works for bash, a version that works for zsh, and a version that works for csh in the same answer.
State what shells you know your recipe will work with in the answer.
Let's build this cookbook as a team. If you find out that an answer works with other shells other than the one the author posted, edit it in. If you like an idea and rewrite it to work with another shell, edit the modified version in to the original post.
Give credit where credit is due. If you got your idea from someone else, give them credit if possible.
And for those of you (justifiably) asking "Why do we need another one of these threads?":
Most of what I've seen is along the lines of "post your entire dotfile." Personally, I don't want to try to parse through a person's entire dotfile to figure out what I want. I just want to know about all the cool parts of it.
It's helpful to have a single dotfile thread. I think most of the stuff that works in bash will work in zsh and it may be adapted to work with csh fairly easily.
Using jQuery, how do you check for and replace the occurrence of stringA or stringB when it falls under a specific css class and ID?
stringA = " | "
stringB = "|"
css = .login #bav
<p id="nav">
<a href="#">oh ya</a> |
<a href="#" title="Password Lost and Found"></a>
</p>
I have variations of this:
jQuery(document).ready(function($) {
$(".login #nav").replaceText( /testA|testB/gi, "fooBar" );
});
});
I have a scheduled task that is very IO intensive (deleting hundreds of thousands of files). For disk space reasons, this job has to be performed reasonably quickly. On win2k8, scheduled tasks always have a low IO priority. Raising the priority of the process did not change the IO priority. Is there any way to get a scheduled task to have a normal IO priority?
I have to write a utility to enumerate and manage the owners of groups within a SharePoint site. I know I can use the Groups property of the SPWeb object to retrieve a collection of groups. And I know I can use the Owner property of the group to get back the owner.
My problem is that I do not know what to do next. The SPGroup.Owner property returns a SPMember object. The member object has one property called ID that returns the unique ID (an integer) of the member. What I cannot seem to find information on is how to use that integer value to determine if the member is a User or a Group and how to get back additional details (say the name).
Any ideas?
Thanks.
I'm having trouble simplifying this conditional statements logic. Is there a more effervescent way of writing this?
if(($x || $a) && ($x || $y))
{
if($x){
return true;
}
}
return false;
I want to put a circled number on a graph as a marker near (but not on) a point. Sounds easy, but I also want to be invariant of zoom/aspect ratio changes.
Because of this invariant, I can't draw a circle as a line object (without redrawing it upon rescale); if I use a circle marker, I'd have to adjust its offset upon rescale.
The simplest approach I can think of is to use the Unicode or Wingdings characters ① ② ③ etc. in a string for the text() function. But unicode doesn't seem to work right, and the following sample only works with ① and not for the other numbers (which yield rectangle boxes):
works:
clf; text(0.5,0.5,char(129),'FontName','WingDings')
doesn't work (should be a circled 2):
clf; text(0.5,0.5,char(130),'FontName','WingDings')
What gives, and can anyone suggest a workaround?
Here's the query:
INSERT INTO jobemails (jobid, to, subject, message, headers, datesent) VALUES ('340', '[email protected]', 'We\'ve received your request for a photo shoot called \'another\'.', 'message', 'headers', '2010-04-22 15:55:06')
The datatypes are all correct, it always fails at the subject, so it must be how I'm escaping the values, I assume.
I'm sure one of you will see my idiot mistake right away. A little help?
I have a project that I am working on that uses a little image to mark a record as a favorite on multiple rows in a table. The data gets pulled from a DB and the image is based on whether or not that item is a favorite. One image for a favorite, a different image if not a favorite. I want the user to be able to toggle the image and make it a favorite or not. Here's my code:
$(function () {
$('.FavoriteToggle').toggle(
function () {
$(this).find("img").attr({src:"../../images/icons/favorite.png"});
var ListText = $(this).find('.FavoriteToggleIcon').attr("title");
var ListID = ListText.match(/\d+/);
$.ajax({
url: "include/AJAX.inc.php",
type: "GET",
data: "action=favorite&ItemType=0&ItemID=" + ListID,
success: function () {}
});
},
function () {
$(this).find("img").attr({src:"../../images/icons/favorite_not.png"});
var ListText = $(this).find('.FavoriteToggleIcon').attr("title");
var ListID = ListText.match(/\d+/);
$.ajax({
url: "include/AJAX.inc.php",
type: "GET",
data: "action=favorite&ItemType=0&ItemID=" + ListID,
success: function () {}
});
}
);
});
Works great if the initial state is not a favorite. But you have to double click to get the image to change if it IS a favorite initially. This causes the AJAX to fire twice and essentially make it a favorite then not a favorite before the image responds. The user thinks he's made it a favorite because the image changed, but in fact, it's not. Help anybody?
Hi,
I just saw I can set call forwarding in gsm settings on my mobile, will my mobile make this phone call thus anyone that will call me will cost me more money because my mobile will call this new phone? or is it done on the "Sever" side, so it wont cost me money? (not on my mobile...)
Thanks
say you have 3 models : user, hair_color, and eye_color
user hasOne hair_color
user also hasOne eye_color
however
var $hasOne = 'hair_color';
var $hasOne = 'eye_color';
obviously wont work. So how do you implement many hasOne relationships in a single model?
I assume the answer is in the cookbook, Im going over that area now, I suspect it has something to do with passing an array to $hasOne, but no example of doing this.
My nested resources are working for form_for updates, but I have a few toggles that I need to setup to change a status field. So I am using link_to, and accessing the url helper.
link_to "toggle", edit_project_expense_path(@project[:id],expense_item[:id])
routes.rb
resources :projects do
resources :expenses
end
match '/submit_expense/:id' => 'expenses#submit_expense', :as => 'submit_expense'
rake routes
edit_project_expense GET /projects/:project_id/expenses/:id/edit(.:format) expenses#edit
My question is: How can I also send along :approval_status = "1", with my link_to?
Brand new to C. I am trying to dynamically allocate the array frags2 of size numberOfFrags and copy over the contents of the original array to it. I have tried numerous approaches and searching and do not understand what is going wrong here. Sizeof on the new array returns 0 instead of what I thought I malloc'd. Any help would be much appreciated!
int main(int argc, const char* argv[]) {
char* frags[MAX_FRAG_COUNT];
FILE* fp = fopen(argv[1], "r");
int numberOfFrags = ReadAllFragments(fp, frags, MAX_FRAG_COUNT);
fclose(fp);
char** frags2 = (char**)malloc(numberOfFrags * sizeof(char*));
for (int i = 0; i < numberOfFrags; i++) {
frags2[i] = frags[i];
}
qsort(frags2, sizeof(frags2) / sizeof(char *), sizeof(char*), cstring_cmp);