Search Results

Search found 392 results on 16 pages for 'mad cow'.

Page 1/16 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to Build a Website Into a Cash Cow

    There are myriads of people who have all discovered that a lot of money stands to be made on the internet. Their main problem however is that they do not know how to build a website from the ground up, and turn it into a prospective business.

    Read the article

  • 555 Footstool Turns Tech into Mad Scientist Decor

    - by Jason Fitzpatrick
    If you just can’t find the appropriate footstool for your laboratory, this laser-cut footstool styled to look like the ubiquitous 555 Timer should fit the bill. At Evil Mad Scientist Laboratories they were in search for the perfect footstool. Never ones to do something halfway they set out to build a footstool shaped like the famous integrated circuit design the 555 Timer. The project involved computer design, CNC routers, laser engraving, lots of plywood and glue, and paint. Hit up the link below to see pictures of the entire build process. 555 Footstool [Evil Mad Scientist Laboratories] How To Encrypt Your Cloud-Based Drive with BoxcryptorHTG Explains: Photography with Film-Based CamerasHow to Clean Your Dirty Smartphone (Without Breaking Something)

    Read the article

  • Friday Fun: Mad Virus

    - by Asian Angel
    In this week’s game infection of all cell-kind is the ultimate goal as you lead your virus army to victory. Will you succeed in infecting everything in your path or will you be stopped just short of total domination? HTG Explains: Learn How Websites Are Tracking You Online Here’s How to Download Windows 8 Release Preview Right Now HTG Explains: Why Linux Doesn’t Need Defragmenting

    Read the article

  • Linux: prevent VNC from swapping like mad

    - by Weezy
    I'm accessing a MacMini (with MacOS X 10.4) from my Linux machine using VNC and there's an issue that is driving me crazy... My Linux machine has 4 GB of ram and I run a lot of various apps on it and I've got no issue at all. It's all snappy and don't hear the hard disk swapping/read/writing too often. Now with VNC, the hard disk is swapping like mad... When I'm moving things on the OS X desktop. So I was thinking of creating a ramdisk and forcing the temp VNC files to go into that ramdisk but the problem is I can't find any temp files. I've attempted to do that: #!/bin/bash while [ true ] do lsof | grep vnc done And eyeball parse the output to try to find some temp file: no luck. The VNC version I'm using is this one: $ vncviewer -version VNC Viewer Free Edition 4.1.1 for X - built Jan 30 2009 19:33:16 Copyright (C) 2002-2005 RealVNC Ltd. No matter how much data is coming from the Mac, there should be plenty of memory (4 GB of ram) so there's really no reason to swap like crazy. This is driving me mad. Any help as to how I could solve this problem is most welcome because this is literally driving me nuts.

    Read the article

  • MacBookPro running Windows 7: accidental trackpad input is driving me mad

    - by Ben Hammond
    I am running Windows7 Professional 64bit on a 2010 MacBookPro using BootCamp 3.1. I am using an external trackball. When I am typing, I accidently brushing the trackpad and accidently overtyping randomly selected pieces of text. Which is driving me mad. I have tried to install TrackPad++, but I could not get the Trackpad++ control panel to recognise that the driver software was installed. I tried TrackPad Magic, but although it gives me a system tray icon telling me it is working, but it does not appear to disable the track pad. A quick Google implies that there should be an option in the BootCamp Control Panel 'Ignore accidental Input while typing'. But I can't see one of those in my BootCamp Control Panel. Am I looking in the wrong place? Is this feature 32bit only? Is there anything else I should try?

    Read the article

  • gVIM "put" driving me mad, how do I "put" at the beginning of a line

    - by crgnz
    I'm learning gVIM on Windows, and as I slowly learn more of the keystrokes I find myself using the mouse less and less, which is great. I have a couple of questions I've yet to figure out: I do a lot of copy and paste. So I use 'v' to enter VISUAL mode, use k/j to move up/down and select the lines, then hit 'y' to yank. I then go to the line where I want to insert, and hit 'p' to put, BUT the darn thing pastes after the 1st character. I can't move any further left, so I am definitely at the start of the line, so I find the 'p'ut behaviour of pasting 1 char after my cursor position to be supremely annoying. I switch between edit and command mode an awful lot, and my poor little finger on my left hand is getting sore from being stretched out to hit the 'Esc' key (to enter command mode) every few seconds. Is there a more finger-friendly way to enter command mode?

    Read the article

  • Why does Python's 'for ... in' work differently on a list of values vs. a list of dictionaries?

    - by Code Duck
    I'm wondering about some details of how for ... in works in Python. My understanding is for var in iterable on each iteration creates a variable, var, bound to the current value of iterable. So, if you do for c in cows; c = cows[whatever], but changing c within the loop does not affect the original value. However, it seems to work differently if you're assigning a value to a dictionary key. cows=[0,1,2,3,4,5] for c in cows: c+=2 #cows is now the same - [0,1,2,3,4,5] cows=[{'cow':0},{'cow':1},{'cow':2},{'cow':3},{'cow':4},{'cow':5}] for c in cows: c['cow']+=2 # cows is now [{'cow': 2}, {'cow': 3}, {'cow': 4}, {'cow': 5}, {'cow': 6}, {'cow': 7} #so, it's changed the original, unlike the previous example I see one can use enumerate to make the first example work, too, but that's a different story, I guess. cows=[0,1,2,3,4,5] for i,c in enumerate(cows): cows[i]+=1 # cows is now [1, 2, 3, 4, 5, 6] Why does it affect the original list values in the second example but not the first?

    Read the article

  • MAD method compression function

    - by Jacques
    I ran across the question below in an old exam. My answers just feels a bit short and inadequate. Any extra ideas I can look into or reasons I have overlooked would be great. Thanx Consider the MAD method compression function, mapping an object with hash code i to element [(3i + 7)mod9027]mod6000 of the 6000-element bucket array. Explain why this is a poor choice of compression function, and how it could be improved. I basically just say that the function could be improved by changing the value for p (or 9027) to an prime number and choosing an other constant for a (or 3) could also help.

    Read the article

  • infix operation to postfix using stacks

    - by Chris De La O
    We are writing a program that needs to convert an infix operation (4 5/3) to postfix (4 5 3 / ) using stacks. however my convert to postfix does not work as it doesnt not output the postFix array that is supposed to store the conversion from infix notation to postfix notation. here is the code for the convertToPostix fuction. //converts infix expression to postfix expression void ArithmeticExpression::convertToPostfix(char *const inFix, char *const postFix) { //create a stack2 object named cow Stack2<char> cow; cout<<postFix; char thing = '('; //push a left parenthesis onto the stack cow.push(thing); //append a right parenthesis to the end of inFix array strcat(inFix, ")"); int i = 0;//declare an int that will control posFix position //if the stack is not empty if (!cow.isEmpty()) { //loop to run until the last character in inFix array for (int x = 0; inFix[x]!= '\0'; x++ ) { //if the inFix element is a digit if (isdigit(inFix[x])) { postFix[i]=inFix[x];//it is assigned to the next element in postFix array i++;//move on to next element in postFix } //if the inFix element is a left parenthesis else if (inFix[x]=='(') { cow.push(inFix[x]);//push it unto the stack } //if the inFix element is an operator else if (isOperator(inFix[x])) { char oper2 = inFix[x];//char variable holds inFix operator if (isOperator(cow.stackTop()))//if the top node in the stack is an operator { while (isOperator(cow.stackTop()))//and while the top node in the stack is an operator { char oper1 = cow.stackTop();//char variable holds node operator if(precedence( oper1, oper2))//if the node operator has higher presedence than node operator { postFix[i] = cow.pop();//we pop such operator and insert it in postFix array's next element cow.push(inFix[x]);//and push inFix operator unto the stack i++;//move to the next element in posFix } } } //if the top node is not an operator //we push the current inFix operator unto the top of the stack else cow.push(inFix[x]); } //if the inFix element is a right parenthesis else if (inFix[x]==')') { //we pop everything in the stack and insert it in postFix //until we arrive at a left paranthesis while (cow.stackTop()!='(') { postFix[i] = cow.pop(); i++; } //we then pop and discard left parenthesis cow.pop(); } } postFix[i]='\0'; //print !!postFix array!! (not stack) print();//code for this is just cout<<postFix; }

    Read the article

  • Javascript - jquery ajax post error driving me mad

    - by Exception Duck
    Can't seem to figure this one out. I have a web service defined as (c#,.net) [WebMethod] public string SubmitOrder(string sessionid, string lang,int invoiceno,string email,string emailcc) { //do stuff. return stuff; } Which works fine, when I test it from the autogenerated test thingy in Vstudio. But when I call it from jquery as $j.ajax({ type: "POST", url: "/wservice/baby.asmx/SubmitOrder", data: "{'sessionid' : '"+sessionid+"',"+ "'lang': '"+usersettings.Currlang+"',"+ "'invoiceno': '"+invoicenr+"',"+ "'email':'"+$j(orderids.txtOIEMAIL).val()+"',"+ "'emailcc':'"+$j(orderids.txtOICC).val()+"'}", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (msg) { submitordercallback(msg); }, error: AjaxFailed }); I get this fun error: responseText: System.InvalidOperationException: Missing parameter: sessionid. at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection) at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request) at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest() data evaluates to: {'sessionid' : 'f61f8da737c046fea5633e7ec1f706dd','lang': 'SE','invoiceno': '11867','email':'[email protected]','emailcc':''} Ok, fair enough, but this function from jquery communicates fine with another webservice. Defined: c#: [WebMethod] public string CheckoutClicked(string sessionid,string lang) { //*snip* //jquery: var divCheckoutClicked = function() { $j.ajax({ type: "POST", url: "/wservice/baby.asmx/CheckoutClicked", data: "{'sessionid': '"+sessionid+"','lang': '"+usersettings.Currlang+"'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { divCheckoutClickedCallback(msg); }, error: AjaxFailed }); }

    Read the article

  • Apache mod_rewrite driving me mad

    - by WishCow
    The scenario I have a webhost that is shared among multiple sites, the directory layout looks like this: siteA/ - css/ - js/ - index.php siteB/ - css/ - js/ - index.php siteC/ . . . The DocumentRoot is at the top level, so, to access siteA, you type http://webhost/siteA in your browser, to access siteB, you type http://webhost/siteB, and so on. Now I have to deploy my own site, which was designed with having 3 VirtualHosts in mind, so my structure looks like this: siteD/ - sites/sitename.com/ - log/ - htdocs/ - index.php - sites/static.sitename.com - log/ - htdocs/ - css - js - sites/admin.sitename.com - log/ - htdocs/ - index.php As you see, the problem is that my index.php files are not at the top level directory, unlike the already existing sites on the webhost. Each VirtualHost should point to the corresponding htdocs/ folder: http://siteD.com -> siteD/sites/sitename.com/htdocs http://static.siteD.com -> siteD/sites/static.sitename.com/htdocs http://admin.siteD.com -> siteD/sites/admin.sitename.com/htdocs The problem I cannot have VirtualHosts on this host, so I have to emulate it somehow, possibly with mod_rewrite. The idea Have some predefined parts in all of the links on the site, that I can identify, and route accordingly to the correct file, with mod_rewrite. Examples: http://webhost/siteD/static/js/something.js -> siteD/sites/static.sitename.com/htdocs/js/something.js http://webhost/siteD/static/css/something.css -> siteD/sites/static.sitename.com/htdocs/css/something.css http://webhost/siteD/admin/something -> siteD/sites/admin.sitename.com/htdocs/index.php http://webhost/siteD/admin/sub/something -> siteD/sites/admin.sitename.com/htdocs/index.php http://webhost/siteD/something -> siteD/sites/sitename.com/htdocs/index.php http://webhost/siteD/sub/something -> siteD/sites/sitename.com/htdocs/index.php Anything that starts with http://url/sitename/admin/(.*) will get rewritten, to point to siteD/sites/admin.sitename.com/htdocs/index.php Anything that starts with http://url/sitename/static/(.*) will get rewritten, to point to siteD/sites/static.sitename.com/htdocs/$1 Anything that starts with http://url/sitename/(.*) AND did not have a match already from above, will get rewritten to point to siteD/sites/sitename.com/htdocs/index.php The solution Here is the .htaccess file that I've come up with: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/siteD/static/(.*)$ [NC] RewriteRule ^siteD/static/(.*)$ siteD/sites/static/htdocs/$1 [L] RewriteCond %{REQUEST_URI} ^/siteD/admin/(.*)$ [NC] RewriteRule ^siteD/(.*)$ siteD/sites/admin/htdocs/index.php [L,QSA] So far, so good. It's all working. Now to add the last rule: RewriteCond %{REQUEST_URI} ^/siteD/(.*)$ [NC] RewriteRule ^siteD/(.*)$ siteD/sites/public/htdocs/index.php [L,QSA] And it's broken. The last rule catches everything, even the ones that have static/ or admin/ in them. Why? Shouldn't the [L] flag stop the rewriting process in the first two cases? Why is the third case evaluated? Is there a better way of solving this? I'm not sticking to rewritemod, anything is fine as long as it does not need access to server-level config. I don't have access to RewriteLog, or anything like that. Please help :(

    Read the article

  • Git diff gone mad?

    - by dr Hannibal Lecter
    I'm trying to figure out what's going on with my local Git repo. I edit a file. Git reports everything has changed in the file (I only changed one line) At first I think "must be a newline problem", but it's not. I do a diff in TortoiseGit, everything looks fine. I do a diff with Netbeans (git plugin), everything seems fine. I do a reset, backup the file, modify it, git again reports everything has changed. I do a binary compare in Total Commander, the files have no differences except for the single line I changed. I do a hard reset again. Git tells me it was done successfully. Git status still says my file has changed. I diff the thing and there are no differences - bug git says there are. I've tried using both git bash and gui, with same results (I'm on Windows). Any clues, what's going on here?

    Read the article

  • Creating Facebook Apps .. going mad

    - by ArneRie
    Hi, iam trying to create my first Application running inside an Facebook Canvas. Iam using Zend Framework (PHP) for this project. But iam not able to understand all the different ways facebook is offering. There is an PHP SDK wich works so far. There is an Javascript SDK and something called FBJS? Does someone knows a good point to start? The Documentation is not actual most times. I have managed it to login, and show my picture and name inside the app, the basic stuff is working.

    Read the article

  • Linq2SQL vs NHibernate performance (have I gone mad?)

    - by HeavyWave
    I have written the following tests to compare performance of Linq2SQL and NHibernate and I find results to be somewhat strange. Mappings are straight forward and identical for both. Both are running against a live DB. Although I'm not deleting Campaigns in case of Linq, but that shouldn't affect performance by more than 10 ms. Linq: [Test] public void Test1000ReadsWritesToAgentStateLinqPrecompiled() { Stopwatch sw = new Stopwatch(); Stopwatch swIn = new Stopwatch(); sw.Start(); for (int i = 0; i < 1000; i++) { swIn.Reset(); swIn.Start(); ReadWriteAndDeleteAgentStateWithLinqPrecompiled(); swIn.Stop(); Console.WriteLine("Run ReadWriteAndDeleteAgentState: " + swIn.ElapsedMilliseconds + " ms"); } sw.Stop(); Console.WriteLine("Total Time: " + sw.ElapsedMilliseconds + " ms"); Console.WriteLine("Average time to execute queries: " + sw.ElapsedMilliseconds / 1000 + " ms"); } private static readonly Func<AgentDesktop3DataContext, int, EntityModel.CampaignDetail> GetCampaignById = CompiledQuery.Compile<AgentDesktop3DataContext, int, EntityModel.CampaignDetail>( (ctx, sessionId) => (from cd in ctx.CampaignDetails join a in ctx.AgentCampaigns on cd.CampaignDetailId equals a.CampaignDetailId where a.AgentStateId == sessionId select cd).FirstOrDefault()); private void ReadWriteAndDeleteAgentStateWithLinqPrecompiled() { int id = 0; using (var ctx = new AgentDesktop3DataContext()) { EntityModel.AgentState agentState = new EntityModel.AgentState(); var campaign = new EntityModel.CampaignDetail { CampaignName = "Test" }; var campaignDisposition = new EntityModel.CampaignDisposition { Code = "123" }; campaignDisposition.Description = "abc"; campaign.CampaignDispositions.Add(campaignDisposition); agentState.CallState = 3; campaign.AgentCampaigns.Add(new AgentCampaign { AgentState = agentState }); ctx.CampaignDetails.InsertOnSubmit(campaign); ctx.AgentStates.InsertOnSubmit(agentState); ctx.SubmitChanges(); id = agentState.AgentStateId; } using (var ctx = new AgentDesktop3DataContext()) { var dbAgentState = ctx.GetAgentStateById(id); Assert.IsNotNull(dbAgentState); Assert.AreEqual(dbAgentState.CallState, 3); var campaignDetails = GetCampaignById(ctx, id); Assert.AreEqual(campaignDetails.CampaignDispositions[0].Description, "abc"); } using (var ctx = new AgentDesktop3DataContext()) { ctx.DeleteSessionById(id); } } NHibernate (the loop is the same): private void ReadWriteAndDeleteAgentState() { var id = WriteAgentState().Id; StartNewTransaction(); var dbAgentState = agentStateRepository.Get(id); Assert.IsNotNull(dbAgentState); Assert.AreEqual(dbAgentState.CallState, 3); Assert.AreEqual(dbAgentState.Campaigns[0].Dispositions[0].Description, "abc"); var campaignId = dbAgentState.Campaigns[0].Id; agentStateRepository.Delete(dbAgentState); NHibernateSession.Current.Transaction.Commit(); Cleanup(campaignId); NHibernateSession.Current.BeginTransaction(); } Results: NHibernate: Total Time: 9469 ms Average time to execute 13 queries: 9 ms Linq: Total Time: 127200 ms Average time to execute 13 queries: 127 ms Linq lost by 13.5 times! Event with precompiled queries (both read queries are precompiled). This can't be right, although I expected NHibernate to be faster, this is just too big of a difference, considering mappings are identical and NHibernate actually executes more queries against the DB.

    Read the article

  • Rails routing to XML/JSON without views gone mad

    - by John Schulze
    I have a mystifying problem. In a very simple Ruby app i have three classes: Drivers, Jobs and Vehicles. All three classes only consist of Id and Name. All three classes have the same #index and #show methods and only render in JSON or XML (this is in fact true for all their CRUD methods, they are identical in everything but name). There are no views. For example: def index @drivers= Driver.all respond_to do |format| format.js { render :json => @drivers} format.xml { render :xml => @drivers} end end def show @driver = Driver.find(params[:id]) respond_to do |format| format.js { render :json => @driver} format.xml { render :xml => @driver} end end The models are similarly minimalistic and only contain: class Driver< ActiveRecord::Base validates_presence_of :name end In routes.rb I have: map.resources :drivers map.resources :jobs map.resources :vehicles map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' I can perform POST/create, GET/index and PUT/update on all three classes and GET/read used to work as well until I installed the "has many polymorphs" ActiveRecord plugin and added to environment.rb: require File.join(File.dirname(__FILE__), 'boot') require 'has_many_polymorphs' require 'active_support' Now for two of the three classes I cannot do a read any more. If i go to localhost:3000/drivers they all list nicely in XML but if i go to localhost:3000/drivers/3 I get an error: Processing DriversController#show (for 127.0.0.1 at 2009-06-11 20:34:03) [GET] Parameters: {"id"=>"3"} [4;36;1mDriver Load (0.0ms)[0m [0;1mSELECT * FROM "drivers" WHERE ("drivers"."id" = 3) [0m ActionView::MissingTemplate (Missing template drivers/show.erb in view path app/views): app/controllers/drivers_controller.rb:14:in `show' ...etc This is followed a by another unexpected error: Processing ApplicationController#show (for 127.0.0.1 at 2009-06-11 21:35:52)[GET] Parameters: {"id"=>"3"} NameError (uninitialized constant ApplicationController::AreaAccessDenied): ...etc What is going on here? Why does the same code work for one class but not the other two? Why is it trying to do a #view on the ApplicationController? I found that if I create a simple HTML view for each of the three classes these work fine. To each class I add: format.html # show.html.erb With this in place, going to localhost:3000/drivers/3 renders out the item in HTML and I get no errors in the log. But if attach .xml to the URL it again fails for two of the classes (with the same error message as before) while one will output XML as expected. Even stranger, on the two failing classes, when adding .js to the URL (to trigger JSON rendering) I get the HTML output instead! Is it possible this has something to do with the "has many polymorphs" plugin? I have heard of people having routing issues after installing it. Removing "has many polymorphs" and "active support" from environment.rb (and rebooting the sever) seems to make no difference whatsoever. Yet my problems started after it was installed. I've spent a number of hours on this problem now and am starting to get a little desperate, Google turns up virtually no information which makes me suspect I must have missed something elementary. Any enlightenment or hint gratefully received! JS

    Read the article

  • P values in wilcox.test gone mad :(

    - by Error404
    I have a code that isn't doing what it should do. I am testing P value for a wilcox.test for a huge set of data. the code i am using is the following library(MASS) data1 <- read.csv("file1path.csv",header=T,sep=",") data2 <- read.csv("file2path.csv",header=T,sep=",") data3 <- read.csv("file3path.csv",header=T,sep=",") data4 <- read.csv("file4path.csv",header=T,sep=",") data1$K <- with(data1,{"N"}) data2$K <- with(data2,{"E"}) data3$K <- with(data3,{"M"}) data4$K <- with(data4,{"U"}) new=rbind(data1,data2,data3,data4) i=3 for (o in 1:4800){ x1 <- data1[,i] x2 <- data2[,i] x3 <- data3[,i] x4 <- data4[,i] wt12 <- wilcox.test(x1,x2, na.omit=TRUE) wt13 <- wilcox.test(x1,x3, na.omit=TRUE) wt14 <- wilcox.test(x1,x4, na.omit=TRUE) if (wt12$p.value=="NaN"){ print("This is wrong") } else if (wt12$p.value < 0.05){ print(wt12$p.value) mypath=file.path("C:", "all1-less-05", (paste("graph-data1-data2",names(data1[i]), ".pdf", sep="-"))) pdf(file=mypath) mytitle = paste("graph",names(data1[i])) boxplot(new[,i] ~ new$K, main = mytitle, names.arg=c("data1","data2","data3","data4")) dev.off() } if (wt13$p.value=="NaN"){ print("This is wrong") } else if (wt13$p.value < 0.05){ print(wt13$p.value) mypath=file.path("C:", "all2-less-05", (paste("graph-data1-data3",names(data1[i]), ".pdf", sep="-"))) pdf(file=mypath) mytitle = paste("graph",names(data1[i])) boxplot(new[,i] ~ new$K, main = mytitle, names.arg=c("data1","data2","data3","data4")) dev.off() } if (wt14$p.value=="NaN"){ print("This is wrong") } else if (wt14$p.value < 0.05){ print(wt14$p.value) mypath=file.path("C:", "all3-less-05", (paste("graph-data1-data4",names(data1[i]), ".pdf", sep="-"))) pdf(file=mypath) mytitle = paste("graph",names(data1[i])) boxplot(new[,i] ~ new$K, main = mytitle, names.arg=c("data1","data2","data3","data4")) dev.off() } i=i+1 } I am having 2 problems with this long command: 1- Without specifying a certain P value, the code gives me arouind 14,000 graphs, when specifying a p value less than 0.05 the number of graphs generated goes down to 9,0000. THE FIRST PROBLEM IS: Some P value are more than 0.05 and are still showing up! 2- I designed the program to give me a result of "This is wrong" when the Value of P is "NaN", I am getting results of "NaN" Here's a screenshot from the results do you know what the mistake i made with the command to get these errors? Thanks in advance

    Read the article

  • Selecting first instance of class but not nested instances via jQuery

    - by DA
    Given the following hypothetical markup: <ul class="monkey"> <li> <p class="horse"></p> <p class="cow"></p> </li> </ul> <dl class="monkey"> <dt class="horse"></dt> <dd class="cow"> <dl> <dt></dt> <dd></dd> </dl> <dl class="monkey"> <dt class="horse"></dt> <dd class="cow"></dd> </dl> </dd> </dl> I want to be able to grab the 'first level' of horse and cow classes within each monkey class. But I don't want the NESTED horse and cow classes. I started with .children, but that won't work with the UL example as they aren't direct children of .monkey. I can use find: $('.monkey').find('.horse, .cow') but that returns all instances, including the nested ones. I can filter the find: $('.monkey').find('.horse, .cow').not('.cow .horse, .cow .cow') but that prevents me from selecting nested instances on a second function call. So...I guess what I'm looking for is 'find first "level" of this descendant'. I could likely do this with some looping logic, but was wondering if there is a selector and/or some combo of selectors that would achieve that logic.

    Read the article

  • c++ Design pattern for CoW, inherited classes, and variable shared data?

    - by krunk
    I've designed a copy-on-write base class. The class holds the default set of data needed by all children in a shared data model/CoW model. The derived classes also have data that only pertains to them, but should be CoW between other instances of that derived class. I'm looking for a clean way to implement this. If I had a base class FooInterface with shared data FooDataPrivate and a derived object FooDerived. I could create a FooDerivedDataPrivate. The underlying data structure would not effect the exposed getters/setters API, so it's not about how a user interfaces with the objects. I'm just wondering if this is a typical MO for such cases or if there's a better/cleaner way? What peeks my interest, is I see the potential of inheritance between the the private data classes. E.g. FooDerivedDataPrivate : public FooDataPrivate, but I'm not seeing a way to take advantage of that polymorphism in my derived classes. class FooDataPrivate { public: Ref ref; // atomic reference counting object int a; int b; int c; }; class FooInterface { public: // constructors and such // .... // methods are implemented to be copy on write. void setA(int val); void setB(int val); void setC(int val); // copy constructors, destructors, etc. all CoW friendly private: FooDataPrivate *data; }; class FooDerived : public FooInterface { public: FooDerived() : FooInterface() {} private: // need more shared data for FooDerived // this is the ???, how is this best done cleanly? };

    Read the article

  • Inheritance, commands and event sourcing

    - by Arthis
    In order not to redo things several times I wanted to factorize common stuff. For Instance, let's say we have a cow and a horse. The cow produces milk, the horse runs fast, but both eat grass. public class Herbivorous { public void EatGrass(int quantity) { var evt= Build.GrassEaten .WithQuantity(quantity); RaiseEvent(evt); } } public class Horse : Herbivorous { public void RunFast() { var evt= Build.FastRun; RaiseEvent(evt); } } public class Cow: Herbivorous { public void ProduceMilk() { var evt= Build.MilkProduced; RaiseEvent(evt); } } To eat Grass, the command handler should be : public class EatGrassHandler : CommandHandler<EatGrass> { public override CommandValidation Execute(EatGrass cmd) { Contract.Requires<ArgumentNullException>(cmd != null); var herbivorous= EventRepository.GetById<Herbivorous>(cmd.Id); if (herbivorous.IsNull()) throw new AggregateRootInstanceNotFoundException(); herbivorous.EatGrass(cmd.Quantity); EventRepository.Save(herbivorous, cmd.CommitId); } } so far so good. I get a Herbivorous object , I have access to its EatGrass function, whether it is a horse or a cow doesn't matter really. The only problem is here : EventRepository.GetById<Herbivorous>(cmd.Id) Indeed, let's imagine we have a cow that has produced milk during the morning and now wants to eat grass. The EventRepository contains an event MilkProduced, and then come the command EatGrass. With the CommandHandler, we are no longer in the presence of a cow and the herbivorious doesn't know anything about producing milk . what should it do? Ignore the event and continue , thus allowing the inheritance and "general" commands? or throw an exception to forbid execution, it would mean only CowEatGrass, and HorseEatGrass might exists as commands ? Thanks for your help, I am just beginning with these kinds of problem, and I would be glad to have some news from someone more experienced.

    Read the article

  • Getting functions of inherited functions to be called

    - by wrongusername
    Let's say I have a base class Animal from which a class Cow inherits, and a Barn class containing an Animal vector, and let's say the Animal class has a virtual function scream(), which Cow overrides. With the following code: Animal.h #ifndef _ANIMAL_H #define _ANIMAL_H #include <iostream> using namespace std; class Animal { public: Animal() {}; virtual void scream() {cout << "aaaAAAAAAAAAAGHHHHHHHHHH!!! ahhh..." << endl;} }; #endif /* _ANIMAL_H */ Cow.h #ifndef _COW_H #define _COW_H #include "Animal.h" class Cow: public Animal { public: Cow() {} void scream() {cout << "MOOooooOOOOOOOO!!!" << endl;} }; #endif /* _COW_H */ Barn.h #ifndef _BARN_H #define _BARN_H #include "Animal.h" #include <vector> class Barn { std::vector<Animal> animals; public: Barn() {} void insertAnimal(Animal animal) {animals.push_back(animal);} void tortureAnimals() { for(int a = 0; a < animals.size(); a++) animals[a].scream(); } }; #endif /* _BARN_H */ and finally main.cpp #include <stdlib.h> #include "Barn.h" #include "Cow.h" #include "Chicken.h" /* * */ int main(int argc, char** argv) { Barn barn; barn.insertAnimal(Cow()); barn.tortureAnimals(); return (EXIT_SUCCESS); } I get this output: aaaAAAAAAAAAAGHHHHHHHHHH!!! ahhh... How should I code this to get MOOooooOOOOOOOO!!! (and whatever other classes inheriting Animal wants scream() to be) instead?

    Read the article

  • Do you know of a C dictionary that supports COW transactions?

    - by Tim Post
    I'm looking for a key - value dictionary library written in C that supports a theoretically unlimited number of cheap transactions. I'd like to have one dictionary in memory, with hundreds of threads starting transactions, possibly modifying the dictionary, ending (completing) the transaction or potentially aborting the transaction. Only 50% of the time will these threads actually modify the dictionary. Most dictionary transaction implementations that I've seen copy always, instead of copying on write, whenever a transaction is started. Given the expected size ( 1GB) of the dictionary, I'm hoping to find something that COWs only when something is actually changed during a transaction. I'm also hoping for something that is packaged by most major GNU/Linux distributions. Any suggestions or links are very much appreciated.

    Read the article

  • jquery animation callback - how to pass parameters to callback

    - by Hans
    I´m building a jquery animation from a multidimensional array, and in the callback of each iteration i would like to use an element of the array. However somehow I always end up with last element of the array instead of all different elements. html: <div id="square" style="background-color: #33ff33; width: 100px; height: 100px; position: absolute; left: 100px;"></div> javascript: $(document).ready(function () { // Array with Label, Left pixels and Animation Lenght (ms) LoopArr = new Array( new Array(['Dog', 50, 500]), new Array(['Cat', 150, 5000]), new Array(['Cow', 200, 1500]) ); $('#square').click(function() { for (x in LoopArr) { $("#square").animate({ left: LoopArr[x][0][1] }, LoopArr[x][0][2], function() { alert (LoopArr[x][0][0]); }); } }); }); ` Current result: Cow, Cow, Cow Desired result: Dog, Cat, Cow How can I make sure the relevant array element is returned in the callback?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >