I don't remember which blog I was reading, because it seemed academic at the time, but there was a library being discussed where you could take a two concrete classes and bind the properties together if the names matched. Think ASP.NET MVC model binding.
Hi,
I'm looking to add a centered magnifying glass icon to my portfolio gallery.
Like the effect at http://jquerystyle.com/gallery.
I know I can do this with css at each instance, but I would like to find a way to do it automatically. Any jquery plugins that do this?
Thanks!
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);
}
Given this code:
void FrMemCopy(void *to, const void *from, size_t sz)
{
size_t sz8 = sz >> 3;
size_t sz1 = sz - (sz8 << 3);
while (sz8-- != 0) {
*((double *)to)++ = *((double *)from)++;
}
while (sz1-- != 0) {
*((char *)to)++ = *((char *)from)++;
}
}
I am receiving target of assignment not really an lvalue warnings on the 2 lines inside the while loops.
Can anyone break down those lines?
a cast then an increment?
What is a simplier way to write that?
What does the error mean?
I've been trying to get this working and I can't seem to figure it out. There is an Image control that when I click on it I need to zoom in (using the center/transform point where the mouse is clicked).
I have the zoom transition working great, but when I set transformX & tranformY (with autoCenterTransform false) it doesn't zoom into that point.
Here is my code that only zooms in (not to a specific point)
<fx:Script>
<![CDATA[
protected function imgLogo_clickHandler(event:MouseEvent):void
{
transformer.play();
}
]]>
</fx:Script>
<fx:Declarations>
<s:Parallel id="transformer" target="{imgLogo}">
<s:Scale scaleXBy="0.5" scaleYBy="0.5" />
</s:Parallel>
</fx:Declarations>
<mx:Image id="imgLogo" width="250" x="100" y="100"
maintainAspectRatio="true" source="@Embed('src/logo.png')"
click="imgLogo_clickHandler(event)" />
Any help is greatly appreciated.
Thanks
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 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?
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 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 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.
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?
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" );
});
});
<!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
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?
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'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?
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?
Hi,
Why would you create a proxy reference to an object in Ruby, by using the to_enum method rather than just using the object directly? I cannot think of any practical use for this, trying to understand this concept & where someone might use it, but all the examples I have seen seem very trivial.
For example, why use:
"hello".enum_for(:each_char).map {|c| c.succ }
instead of
"hello".each_char.map {|c| c.succ }
I know this is a very simple example, does anyone have any real-world examples?
Thanks!
I have been pulling my hair out trying to get Chrome to style my search input with a background image. Firefox has no problem, but I fear it's because it treats the input as a regular text input. Is this simply not possible?
Try this as a demo:
<input type="search" />
?input[type="search"] {
background: transparent
url(http://google.com/intl/en_ALL/images/srpr/logo1w.png) no-repeat 0 0;
}??????
If it worked correctly, it should put Google's logo (or part of it) as the background image for the "Search" input. But as you will see when you look at this in Chrome, it DOES NOT WORK. Any ideas, or is this just one of HTML5's quirks? :\
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.
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 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?
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?
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);