Search Results

Search found 670 results on 27 pages for 'brain teaser'.

Page 19/27 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • Code required to use foreach on my own custom appSettings

    - by jamauss
    I've searched the site and haven't found exactly what I'm looking for. Close, but no cigar. Basically I want to have a config section like this: <configSections> <section name="PhoneNotificationsSection" type="Alerts.PhoneAlertConfigSection,Alerts,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"/> </configSections> <PhoneNotificationsSection> <phones> <add phone="MyMobile" value="[email protected]" /> <add phone="OtherMobile" value="[email protected]" /> </phones> </PhoneNotificationsSection> Then I'd like to, in my appSettings consuming code, be able to write something like this (pseudo code): foreach (phone p in phones) { //'phone' attribute is just helpful/descriptive DoSomething(p.value); } I've done enough research to know I probably need a few of my own classes that implement and/or inherit from certain Configuration classes to make the above code possible. I just haven't found anything that clearly demonstrates this scenario and how to code for it - and when I try to learn the whole .NET configuration world my brain starts to hurt. Anyone have some code like what I'm looking for that they can share?

    Read the article

  • What's the strangest corner case you've seen in C# or .NET?

    - by Jon Skeet
    I collect a few corner cases and brain teasers and would always like to hear more. The page only really covers C# language bits and bobs, but I also find core .NET things interesting too. For example, here's one which isn't on the page, but which I find incredible: string x = new string(new char[0]); string y = new string(new char[0]); Console.WriteLine(object.ReferenceEquals(x, y)); I'd expect that to print False - after all, "new" (with a reference type) always creates a new object, doesn't it? The specs for both C# and the CLI indicate that it should. Well, not in this particular case. It prints True, and has done on every version of the framework I've tested it with. (I haven't tried it on Mono, admittedly...) Just to be clear, this is only an example of the kind of thing I'm looking for - I wasn't particularly looking for discussion/explanation of this oddity. (It's not the same as normal string interning; in particular, string interning doesn't normally happen when a constructor is called.) I was really asking for similar odd behaviour. Any other gems lurking out there?

    Read the article

  • Always can't separate these guys: ascending and descending! Are there good examples?

    - by mystify
    As a non-english dude, I have trouble differentiating this. When I try to translate this into my language, I get something weird like "go up" for ascending. So lets say I want to sort the names of all my pets alphabetically. I want that A comes first, then B, then C... and so on. So since the alphabet is not a number for me, my brain refuses to grok what's "going up". A = 0? B = 1? C = 2? If yes, then ascending would be what I'm most of the time looking for. Table would start showing A, then B, then C... Or is that the other way around? Must I look from the bottom of the table, up? And with numbers: If it's an ascending order, the smallest comes first? (would seem logical...) Can someone post a short but good example for what is an ascending sort order, and what is an descending sort order? And does that apply to whatever platform, programming language, API, etc.?

    Read the article

  • Intercepting method with Spring AOP using only annotations

    - by fish
    In my Spring context file I have something like this: <bean id="userCheck" class="a.b.c.UserExistsCheck"/> <aop:config> <aop:aspect ref="userCheck"> <aop:pointcut id="checkUser" expression="execution(* a.b.c.d.*.*(..)) &amp;&amp; args(a.b.c.d.RequestObject)"/> <aop:around pointcut-ref="checkUser" method="checkUser"/> </aop:aspect> </aop:config> a.b.c.UserExistsCheck looks like this: @Aspect public class UserExistsCheck { @Autowired private UserInformation userInformation; public Object checkUser(ProceedingJoinPoint pjp) throws Throwable { int userId = ... //get it from the RequestObject passed as a parameter if (userExists(userId)) { return pjp.proceed(); } else { return new ResponseObject("Invalid user); } } And the class that is being intercepted with this stuff looks like this: public class Klazz { public ResponseObject doSomething(RequestObject request) {...} } This works. UserExistCheck is executed as desired before the call is passed to Klazz. The problem is that this is the only way I got it working. To get this working by using annotations instead of the context file seems to be just too much for my small brain. So... how exactly should I annotate the methods in UserExistsCheck and Klazz? And do I still need something else too? Another class? Still something in the context file?

    Read the article

  • C# - update variable based upon results from backgroundworker

    - by Bruce
    I've got a C# program that talks to an instrument (spectrum analyzer) over a network. I need to be able to change a large number of parameters in the instrument and read them back into my program. I want to use backgroundworker to do the actual talking to the instrument so that UI performance doesn't suffer. The way this works is - 1) send command to the instrument with new parameter value, 2) read parameter back from the instrument so I can see what actually happened (for example, I try to set the center frequency above the max that the instrument will handle and it tells me what it will actually handle), and 3) update a program variable with the actual value received from the instrument. Because there are quite a few parameters to be updated I'd like to use a generic routine. The part I can't seem to get my brain around is updating the variable in my code with what comes back from the instrument via backgroundworker. If I used a separate RunWorkerCompleted event for each parameter I could hardwire the update directly to the variable. I'd like to come up with a way of using a single routine that's capable of updating any of the variables. All I can come up with is passing a reference number (different for each parameter) and using a switch statement in the RunWorkerCompleted handler to direct the result. There has to be a better way. Thanks for your help.

    Read the article

  • ASP.NET MVC - Entending the Authorize Attribute

    - by Mad Halfling
    Hi folks, currently I use [Authorize(Roles = ".....")] to secure my controller actions on my ASP.NET MVC 1 app, and this works fine. However, certain search views need to have buttons that route to these actions that need to be enabled/disabled based on the record selected on the search list, and also the security privs of the user logged in. Therefore I think I need to have a class accessing a DB table which cross-references these target controller/actions with application roles to determine the state of these buttons. This will, obviously, make things messy as privs will need to be maintained in 2 places - in that class/DB table and also on the controller actions (plus, if I want to change the access to the action I will have to change the code and compile rather than just change a DB table entry). Ideally I would like to extend the [Authorize] functionality so that instead of having to specify the roles in the [Authorize] code, it will query the security class based on the user, controller and action and that will then return a boolean allowing or denying access. Are there any good articles on this - I can't imagine it's an unusual thing to want to do, but I seem to be struggling to find anything on how to do it (could be Monday-morning brain). I've started some code doing this, looking at article http://schotime.net/blog/index.php/2009/02/17/custom-authorization-with-aspnet-mvc/ , and it seems to be starting off ok but I can't find the "correct" way to get the calling controller and action values from the httpContext - I could possibly fudge a bit of code to extract them from the request url, but that doesn't seem right to me and I'd rather do it properly. Cheers MH

    Read the article

  • Rails RJS template displays code instead of the html page

    - by Anand
    After having Googled and hurting my brain for hours on this, I finally decided to post this question. Here's the code... view1.html.erb -------------- <%=link_to_remote_redbox "Link", :url => {:action => :action1, :id => @some.id} some_controller.rb ------------------ def action1 render :layout => false end def action2 do some processing end action1.html.erb -------------------- <form onsubmit="new Ajax.Request('/some_controller/action2', {asynchronous:true, evalScripts:true, onComplete:function(request){RedBox.close(); return false;}, parameters:Form.serialize(this)}); return false;}" method="post" action="/some_controller/action2"> <input type=text name='username'> <input type='submit' value='submit'> </form> action2.rjs ----------- page.replace_html("some_div", (render(:partial => "some_partial"))) with that code in place when action2.rjs kicks in it should display the html page instead I am getting this Element.update("some_div", "<style type=\"text/css\">\n\n.............. As suggested on other posts I read, they say its caused because of the ":update = some_div" in the link_to_remote_redbox function but clearly my code doesn't have that. Help is always appreciated. Many Thanks

    Read the article

  • Numpy: Sorting a multidimensional array by a multidimensional array

    - by JD Long
    Forgive me if this is redundant or super basic. I'm coming to Python/Numpy from R and having a hard time flipping things around in my head. I have a n dimensional array which I want to sort using another n dimensional array of index values. I know I could wrap this in a loop but it seems like there should be a really concise Numpyonic way of beating this into submission. Here's my example code to set up the problem where n=2: a1 = random.standard_normal(size=[2,5]) index = array([[0,1,2,4,3] , [0,1,2,3,4] ]) so now I have a 2 x 5 array of random numbers and a 2 x 5 index. I've read the help for take() about 10 times now but my brain is not groking it, obviously. I thought this might get me there: take(a1, index) array([[ 0.29589188, -0.71279375, -0.18154864, -1.12184984, 0.25698875], [ 0.29589188, -0.71279375, -0.18154864, 0.25698875, -1.12184984]]) but that's clearly reordering only the first element (I presume because of flattening). Any tips on how I get from where I am to a solution that sorts element 0 of a1 by element 0 of the index ... element n?

    Read the article

  • F# Class with Generics : 'constructor deprecated' error

    - by akaphenom
    I am trying to create a a class that will store a time series of data - organized by groups, but I had some compile errors so I stripped down to the basics (just a simple instantiation) and still can't overcome the compile error. I was hoping some one may have seen this issue before. Clas is defined as: type TimeSeriesQueue<'V, 'K when 'K: comparison> = class val private m_daysInCache: int val private m_cache: Map<'K, 'V list ref > ref; val private m_getKey: ('V -> 'K) ; private new(getKey) = { m_cache = ref Map.empty m_daysInCache = 7 ; m_getKey = getKey ; } end So that looks OK to me (it may not be, but doesnt have any errors or warnings) - the instantiation gets the error: type tempRec = { someKey: string ; someVal1: int ; someVal2: int ; } let keyFunc r:tempRec = r.someKey // error occurs on the following line let q = new TimeSeriesQueue<tempRec, string> keyFunc This construct is deprecated: The use of the type syntax 'int C' and 'C ' is not permitted here. Consider adjusting this type to be written in the form 'C' NOTE This may be simple stupidity - I am just getting back from holiday and my brain is still on time zone lag...

    Read the article

  • update variable based upon results from .NET backgroundworker

    - by Bruce
    I've got a C# program that talks to an instrument (spectrum analyzer) over a network. I need to be able to change a large number of parameters in the instrument and read them back into my program. I want to use backgroundworker to do the actual talking to the instrument so that UI performance doesn't suffer. The way this works is - 1) send command to the instrument with new parameter value, 2) read parameter back from the instrument so I can see what actually happened (for example, I try to set the center frequency above the max that the instrument will handle and it tells me what it will actually handle), and 3) update a program variable with the actual value received from the instrument. Because there are quite a few parameters to be updated I'd like to use a generic routine. The part I can't seem to get my brain around is updating the variable in my code with what comes back from the instrument via backgroundworker. If I used a separate RunWorkerCompleted event for each parameter I could hardwire the update directly to the variable. I'd like to come up with a way of using a single routine that's capable of updating any of the variables. All I can come up with is passing a reference number (different for each parameter) and using a switch statement in the RunWorkerCompleted handler to direct the result. There has to be a better way.

    Read the article

  • Single value data to multiple values of data in database relation

    - by Sofiane Merah
    I have such a hard time picturing this. I just don't have the brain to do it. I have a table called reports. --------------------------------------------- | report_id | set_of_bads | field1 | field2 | --------------------------------------------- | 123 | set1 | qwe | qwe | --------------------------------------------- | 321 | 123112 | ewq | ewq | --------------------------------------------- I have another table called bads. This table contains a list of bad data. ------------------------------------- | bad_id | set_it_belongs_to | field2 | field3 | ------------------------------------- | 1 | set1 | qwe | qwe | ------------------------------------- | 2 | set1 | qee | tte | ------------------------------------- | 3 | set1 | q44w | 3qwe | ------------------------------------- | 4 | 234 | qoow | 3qwe | ------------------------------------- Now I have set the first field of every table as the primary key. My question is, how do I connect the field set_of_bads to set_it_belongs_to in the bads table. This way if I want to get the entire set of data that is set1 by calling on the reports table I can do it. Example: hey reports table.. bring up the row that has the report_id 123. Okay thank you.. Now get all the rows from bads that has the set_of_bads value from the row with the report_id 123. Thanks.

    Read the article

  • Exam Questions that use .Demand or .LinkDemand COULD NOT BE ANY MORE CONFUSING OR AMBIGIOUS ????

    - by IbrarMumtaz
    I am 110% sure this is WRONG !!!! Q.12) You develop a library, and want to ensure that the functions in the library cannot be either directly or indirectly invoked by applications that are not running on the local intranet. What attribute would you add to each method? A. [UrlIdentityPermission(SecurityAction.RequestRefuse, Url="http://myintranet")] B. [UrlIdentityPermission(SecurityAction.LinkDemand, Url="http://myintranet")] (correct answer) C. [UrlIdentityPermission(SecurityAction.Demand, Url="http://myintranet")] D. [UrlIdentityPermission(SecurityAction.Assert, Url="http://myintranet")] Explanation Link-Demand should be used as it ensures that all callers in the call stack have the necessary permission. In this case it ensures that all callers in the call stack are on the local intranet. There is an indentical question on Transencer so I already had a clue what was goin but Transcender was much more informative that this drivel as it mentioned class level and not assembly level. It also mentioned that some callers maybe coming externally from the company intranet via authroised and authenticated credentials. With information is easy to see why .Demand on would be wong option to go for? So Transcender was right .... so I thgt fine, that makes sense. With think information still fresh in my brain I had a good idea was was going on in the question. To my surprise .Demand was wrong agin !!!! WHAT? I am really starting to hate this setting now? I cannot be any more p*ssed right now!!! :@ Thanks For Reading, Ibrar

    Read the article

  • Fastest Method to Learn Web Design for a Developer

    - by hekevintran
    I am a Web developer and in my projects I have noticed that my weakest point is not being good at the front-end design. Relying on other designers can be annoying if they are not able to produce as quickly as I want. My perspective on HTML/CSS is that it is basically a big hack that amazingly works. There are too many CSS and browser specific bugs/quirks to learn and remember them all without spending extreme amounts of time trying to untangle everything. Is there a fast track route to getting CSS into my brain? I have looked at some CSS books, but to me they really read as long lists of how to render things correctly in IE6 and how to make corners rounded. (Seriously why does it require so many tricks to make a sharp corner round? On any platform but the Web this would be called a major oversight.) Does there exist something that does the analogous to CSS that jQuery does for JavaScript? Using jQuery you don't need to know JavaScript well to make things that work. I am not interested in learning why IE6 does things in weird ways because I don't care about supporting it at all. I am more interested in a method of learning how to use CSS to do what I want without spending hours and hours reading obscure blogs.

    Read the article

  • Is there a better way to refresh WebView?

    - by cdg
    Hi all. Ok. I have looked EVERYWHERE and my little brain just can't understand a better way to refresh an activity. Any suggestions that I can understand would be great. :) Here is the java code: package com.dge.dges; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.webkit.WebView; import android.widget.Button; public class dgeActivity extends Activity { WebView mWebView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mWebView = (WebView) findViewById(R.id.webview); mWebView.getSettings(); mWebView.loadUrl("http://www.websitehere.php"); Button newButton = (Button)findViewById(R.id.new_button); newButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(dgeActivity.this, dgeActivity.class); startActivity(intent); } }); } } And here is the main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000" > <WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbars="none" /> <Button android:id="@+id/new_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:text="Refresh" /> </RelativeLayout> I don't like the idea of just re-stacking activity after activity. There has to be an easier way to refresh the webview. Please help. :)

    Read the article

  • Gravatar XML-RPC request problem in Objective-C

    - by Erik
    Hi all, I'm trying to incorporate some Gravatar functionality using its XML-RPC API in an iPhone app I'm writing. I grabbed the Cocoa XML-RPC Framework by Eric Czarny (http://github.com/eczarny/xmlrpc) and it works well when I tested it with some of the Wordpress methods. However, when I try to use the Gravatar API, I always receive a response of "Error code: -9 Authentication error". I think I'm constructing the request correctly, but I've been wracking my brain and can't seem to figure it out. Maybe someone has some experience with this API or can see what I'm doing wrong. Here's the call: <?xml version="1.0"> <methodCall> <methodName>grav.addresses</methodName> <params> <param><value><string>PASSWORD_HERE</string></value></param> </params> </methodCall> Again, the Cocoa XML-RPC Framework worked like a dream with Wordpress, but it's choking on the Gravatar API for some reason. Thanks for your help.

    Read the article

  • Sorting by dates (including nil) with NSFetchedResultsController

    - by glorifiedHacker
    In my NSFetchedResultsController, I set a sortDescriptor that sorts based on the date property of my managed objects. The problem that I have encountered (along with several others according to Google) is that nil values are sorted at the earliest end rather than the latest end of the date spectrum. I want my list to be sorted earliest, earlier, now, later, latest, nil. As I understand it, this sorting is done at the database level in SQLite and so I cannot construct my own compare: method to provide the sorting I want. I don't want to manually sort in memory, because I would have to give up all of the benefits of NSFetchedResultsController. I can't do compound sorting because the sectionNameKeyPaths are tightly coupled to the date ranges. I could write a routine that redirects indexPath requests so that section 0 in the results controller gets mapped to the last section of the tableView, but I fear that would add a lot of overhead, severely increase the complexity of my code, and be very, very error-prone. The latest idea that I am considering is to map all nil dates to the furthest future date that NSDate supports. My left brain hates this idea, as it feels more like a hack. It will also take a bit of work to implement, since checking for nil factors heavily into how I process dates in my app. I don't want to go this route without first checking for better options. Can anyone think of a better way to get around this problem?

    Read the article

  • how to match var/id to class

    - by circey
    Hi. I'm new to jquery and, in addition, I think I'm having a brain freeze. I have a number of links with different ids. I want to match the clicked link with a div with the corresponding class so the div will show/hide/toggle as appropriate. I have: <script type="text/javascript"> $(document).ready(function() { $('.folioBox').hide(); $('a.interface').click(function(){ var currentId = $(this).attr('id'); var currentBox = $('.folioBox .' + currentId); $(currentBox).toggle(400); }); }); </script> <a class="interface" id="apple">Apple flavor</a> <a class="interface" id="banana">Banana flavor</a> <a class="interface" id="cherry">Cherry flavor</a> <div class="folioBox apple">content</div> <div class="folioBox banana">content</div> <div class="folioBox cherry">content</div> I just can't get it to work and I can't figure out whether I would be best using match or find or filter. Some assistance would be much appreciated!

    Read the article

  • Trouble Shoot JavaScript Function in IE

    - by CreativeNotice
    So this function works fine in geko and webkit browsers, but not IE7. I've busted my brain trying to spot the issue. Anything stick out for you? Basic premise is you pass in a data object (in this case a response from jQuery's $.getJSON) we check for a response code, set the notification's class, append a layer and show it to the user. Then reverse the process after a time limit. function userNotice(data){ // change class based on error code returned var myClass = ''; if(data.code == 200){ myClass='success'; } else if(data.code == 400){ myClass='error'; } else{ myClass='notice'; } // create message html, add to DOM, FadeIn var myNotice = '<div id="notice" class="ajaxMsg '+myClass+'">'+data.msg+'</div>'; $("body").append(myNotice); $("#notice").fadeIn('fast'); // fadeout and remove from DOM after delay var t = setTimeout(function(){ $("#notice").fadeOut('slow',function(){ $(this).remove(); }); },5000); }

    Read the article

  • Javascript/PHP and timezones

    - by James
    Hi, I'd like to be able to guess the user's timezone offset and whether or not daylight savings is being applied. Currently, the most definitive code that I've found for this is here: http://www.michaelapproved.com/articles/daylight-saving-time-dst-detect/ So this gives me the offset along with the DST indicator. Now, I want to use these in my PHP scripts in order to ouput the local date/time for the user....but what's best for this? I figure I have 2 options: a) Pick a random timezone which has the same offset and DST setting from the output of timezone_abbreviations_list(). Then call date_timezone_set() with this in order to apply the correct treatment to the time. b) Continue treating the date as UTC but just do some timestamp addition to add the appropriate number of hours on. My feeling is that option B is the best way. The reason for this is that with A, I could be using a timezone which although correct in terms of offset/dst, may have some obscur rules in place behind the scene that could give surprising results (I don't know of any but nonetheless I don't think I can rule it out). I'd then re-check the timezone using Javascript at the start of each session in order to capture when either the user's timezone changes (very unlikely) or they pass in to the DST period. Sorry for the brain dump - I'm really just after some sort of reassurance that the approaches above are valid. Thanks, James.

    Read the article

  • Liferay hook: filter url giving filterstart error and current url generates exception null

    - by jack
    I'm trying to make an autologinfilter in Eclipse using a liferay hook. Now I've added the: <filter> <filter-name>myautologinfilter</filter-name> <filter-class>bla.bla.xyz</filter-class> </filter> <filter-mapping> <filter-name>myautologinfilter</filter-name> <url-pattern>/c/login/myurl</url-pattern> </filter-mapping> To the liferay hook's web.xml. In the liferay-hook.xml I added: portal.properties And in that hook.xml I added: auto.login.hooks=bla.bla.xyz bla.bla.xyz implements AutoLogin, but for now it's pretty gutted: @Override public String[] login(HttpServletRequest request, HttpServletResponse response) throws AutoLoginException { Object parameters = request.getAttribute("javax.servlet.forward.query_string"); Map<String, String> x = parserClass.parsing(parameters.toString()); System.out.println("voornaam: " + geparsdeParameters.get("tokenvalue1")); try { return null; } catch (Exception e) { throw new AutoLoginException(e); } } Since the hook doesn't start when I add the filtering I removed it and just tried: http://localhost:8080/c/portal/login?tokenvalue1=55 but when I check my tomcat I see: Error XYZ Url: url myUsedUrl exception null Also I tried adding some util classes but I got: classnotfoundexceptions. Is there anything specific I have to do when I add extra classes in a hook? Any advice/input would be appreciated. Or someone's ear I could lend so I could mail them a little bit so I could pick their brain a bit would be really appreciated since I don't know anyone who programs for liferay.

    Read the article

  • Filling SWT table object using a separated thread class ...

    - by erlord
    Hi all I've got a code snippet by the swt team that does exactly what I need. However, there is a part I want to separate into another class, in particular, the whole inline stuff. In response to my former question, it has been suggested that Callable should be used in order to implement threaded objects. It is suggested to make use of an implementation of runnable or better callable, since I do need some kind of return. However, I don't get it. My problems are: In the original code, within the inline implementation of the method run, some of the parents objects are called. How would I do this when the thread is separated? Pass the object via the C'tor's parameter? In the original code, another runnable object is nested within the runnable implementation. What is it good for? How to implement this when having separated the code? Furthermore, this nested runnable again calls objects created by the main method. Please, have mercy with me, but I am still quite a beginner and my brain is near collapsing :-( All I want is to separate all the threaded stuff into another class and make the program do just the same thing as it already does. Help please! Again thank you very much in advance for any useful suggestions, hints, examples etc... Regs Me

    Read the article

  • Subsonic in a VS2008 Add-In woes

    - by Michael Smit
    Hi, I am writing a VS2008 add-in that connects to a remote database blah blah. I am having a problem with the app.config in this project. When I use SubSonic in my code, it moans that is cannot find the SubSonicServer section. This is because the .config file cannot be found. This appears to a problem with paths as the add-in is a DLL running in the context of VS2008 and the working directory is C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE. Is there a way to get the app.config to deploy properly with the application so my add-in (and SubSonic) can find what it needs in the .config file, or is there a way to get SubSonic to work without the need for the .config? I am very experienced in SubSonic projects now, but only winforms, web, web service, and WPF applications. This is the first time I have tried to use SubSonic in a VS2008 Add-In project. I also have AppSettings in the config file which the ConfigurationManager cannot read because it cannot see the .config file. 2AM now and brain is tired of trying to figure this one out. Hopefully there is an answer when I wake up :) TIA

    Read the article

  • Refresh a Div that has a Google ad inside it

    - by Abs
    Hello all, I have a div that holds a google ad. My website is mostly AJAX and there is no need for a browser refresh. That means my ads will not refresh either, which isnt ideal, a user staring at one ad all day. So I wanted a way to refresh a particular div on a page. I found many solutions but they didnt work. For example, using JQuery's html function: $("#ads").html("google ad script here"); This managed to refresh the whole page no idea how. I can also make an AJAX request to a HTML page that contains the google ad but I am guessing it will have the same effect as the above attempt. I do not want to use iFrames. Is there any other option open to me? My pea brain can not think of anymore. :) Thanks you for any help. EDIT: It is allowed since I will be initiating the refresh only when a user clicks a link. A prime example is Yahoo Mail - their new AJAX mailbox uses this same method, when a user clicks a link then a new ad is shown.

    Read the article

  • How to restrain one's self from the overwhelming urge to rewrite everything?

    - by Scott Saad
    Setup Have you ever had the experience of going into a piece of code to make a seemingly simple change and then realizing that you've just stepped into a wasteland that deserves some serious attention? This usually gets followed up with an official FREAK OUT moment, where the overwhelming feeling of rewriting everything in sight starts to creep up. It's important to note that this bad code does not necessarily come from others as it may indeed be something we've written or contributed to in the past. Problem It's obvious that there is some serious code rot, horrible architecture, etc. that needs to be dealt with. The real problem, as it relates to this question, is that it's not the right time to rewrite the code. There could be many reasons for this: Currently in the middle of a release cycle, therefore any changes should be minimal. It's 2:00 AM in the morning, and the brain is starting to shut down. It could have seemingly adverse affects on the schedule. The rabbit hole could go much deeper than our eyes are able to see at this time. etc... Question So how should we balance the duty of continuously improving the code, while also being a responsible developer? How do we refrain from contributing to the broken window theory, while also being aware of actions and the potential recklessness they may cause? Update Great answers! For the most part, there seems to be two schools of thought: Don't resist the urge as it's a good one to have. Don't give in to the temptation as it will burn you to the ground. It would be interesting to know if more people feel any balance exists.

    Read the article

  • MySQL Query That Can Pull the Data I am Seeking?

    - by Amy
    On the project I am working on, I am stuck with the table structure from Hades. Two things to keep in mind: I can't change the table structure right now. I'm stuck with it for the time being. The queries are dynamically generated and not hard coded. So, while I am asking for a query that can pull this data, what I am really working toward is an algorithm that will generate the query I need. Hopefully, I can explain the problem without making your eyes glaze over and your brain implode. We have an instance table that looks (simplified) along these lines: Instances InstanceID active 1 Y 2 Y 3 Y 4 N 5 Y 6 Y Then, there are multiple data tables along these lines: Table1 InstanceID field1 reference_field2 1 John 5 2 Sally NULL 3 Fred 6 4 Joe NULL Table2 InstanceID field3 5 1 6 1 Table3 InstanceID fieldID field4 5 1 Howard 5 2 James 6 2 Betty Please note that reference_field2 in Table1 contains a reference to another instance. Field3 in Table2 is a bit more complicated. It contains a fieldID for Table 3. What I need is a query that will get me a list as follows: InstanceID field1 field4 1 John Howard 2 Sally 3 Fred The problem is, in the query I currently have, I do not get Fred because there is no entry in Table3 for fieldID 1 and InstanceID 6. So, the very best list I have been able to get thus far is InstanceID field1 field4 1 John Howard 2 Sally In essence, if there is an entry in Table1 for Field 2, and there is not an entry in Table 3 that has the instanceID contained in field2 and the field ID contained in field3, I don't get the data from field1. I have looked at joins till I'm blue in the face, and I can't see a way to handle the case when table3 has no entry.

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >