Search Results

Search found 264 results on 11 pages for 'trevor adams'.

Page 7/11 | < Previous Page | 3 4 5 6 7 8 9 10 11  | Next Page >

  • Chart for deciphering terms in different programming languages

    - by Nathan Adams
    This has been bugging me every since I started to use Python - in PHP you have this ability to use a string as a key in an array. PHP calls these associative arrays. Python calls these dictionaries. Does anyone know of a premade chart that will let me see what the different terminology is in different languages. For example: PHP             | Python Assosicative array | Dictionary

    Read the article

  • PHP upload with progress bar

    - by Mitchan Adams
    Hi all I want to create an upload form to upload large files. Thats pretty much easy, however, the upload process itself taks long and basically looks like nothing is happening for a few minutes. So now I'd like to insert a progress bar to show the user that something is happening and they should just sit tight. I've read of numerous methods like APC and certian flash plugins, but my site is hosted on a shared server and I cant install any new applications on it. I'm thinking, maybe if it is possible to read the size of the temp file it creates via an ajax page. By polling the size every few seconds I should be able to get the progress of the upload. Now the question I pose is...where is the temp file situated?

    Read the article

  • Haskell: variant of `show` that doesn't wrap String and Char in quotes

    - by Joey Adams
    I'd like a variant of show (let's call it label) that acts just like show, except that it doesn't wrap Strings in " " or Chars in ' '. Examples: > label 5 "5" > label "hello" "hello" > label 'c' "c" I tried implementing this manually, but I ran into some walls. Here is what I tried: {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} module Label where class (Show a) => Label a where label :: a -> String instance Label [Char] where label str = str instance Label Char where label c = [c] -- Default case instance Show a => Label a where label x = show x However, because the default case's class overlaps instance Label [Char] and instance Label Char, those types don't work with the label function. Is there a library function that provides this functionality? If not, is there a workaround to get the above code to work?

    Read the article

  • Greasemonkey is getting an empty document.body on select Google pages.

    - by Brock Adams
    Hi, I have a Greasemonkey script that processes Google search results. But it's failing in a few instances, when xpath searches (and document body) appear to be empty. Running the code in Firebug's console works every time. It only fails in a Greasemonkey script. Greasemonkey sees an empty document.body. I've boiled the problem down to a test, greasemonkey script, below. I'm using Firefox 3.5.9 and Greasemonkey 0.8.20100408.6 (but earlier versions had the same problem). Problem: Greasemonkey sees an empty document.body. Recipe to Duplicate: Install the Greasemonkey script. Open a new tab or window. Navigate to Google.com (http://www.google.com/). Search on a simple term like "cats". Check Firefox's Error console (Ctrl-shift-J) or Firebug's console. The script will report that document body is empty. Hit refresh. The script will show a good result (document body found). Note that the failure only reliably appears on Google results obtained this way, and on a new tab/window. Turn javascript off globally (javascript.enabled set to false in about:config). Repeat steps 2 thru 5. Only now the Greasemonkey script will work. It seems that Google javascript is killing the DOM tree for greasemonkey, somehow. I've tried a time-delayed retest and even a programmatic refresh; the script still fails to see the document body. Test Script: // // ==UserScript== // @name TROUBLESHOOTING 2 snippets // @namespace http://www.google.com/ // @description For code that has funky misfires and defies standard debugging. // @include http://*/* // ==/UserScript== // function LocalMain (sTitle) { var sUserMessage = ''; //var sRawHtml = unsafeWindow.document.body.innerHTML; //-- unsafeWindow makes no difference. var sRawHtml = document.body.innerHTML; if (sRawHtml) { sRawHtml = sRawHtml.replace (/^\s\s*/, ''). substr (0, 60); sUserMessage = sTitle + ', Doc body = ' + sRawHtml + ' ...'; } else { sUserMessage = sTitle + ', Document body seems empty!'; } if (typeof (console) != "undefined") { console.log (sUserMessage); } else { if (typeof (GM_log) != "undefined") GM_log (sUserMessage); else if (!sRawHtml) alert (sUserMessage); } } LocalMain ('Preload'); window.addEventListener ("load", function() {LocalMain ('After load');}, false);

    Read the article

  • How do I generate a connection reset programatically?

    - by Brock Adams
    Hi, I'm sure you've seen the "the connection was reset" message displayed when trying to browse web pages. (The text is from Firefox, other browsers differ.) I need to generate that message/error/condition on demand, to test workarounds. So, how do I generate that condition programmatically? (How to generate a TCP RST from PHP -- or one of the other web-app languages?) Caveats and Conditions: It cannot be a general IP block. The test client must still be able to see the test server when not triggering the condition. Ideally, it would be done at the web-application level (Python, PHP, Coldfusion, Javascript, etc.). Access to routers is problematic. Access to Apache config is a pain. Ideally, it would be triggered by fetching a specific web-page. Bonus if it works on a standard, commercial web host. Update: Sending RST is not enough to cause this condition. See my partial answer, below. I've a solution that works on a local machine, Now need to get it working on a remote host.

    Read the article

  • XNA Track rotated pixel positions

    - by jonny adams
    Hi, Im making a game in xna where a tank has to move over a landscape. I need to be able find the bottom of the tank when it is rotated so I can make it move up and down as the player goes over the landscape. for example if i have a sprite at with its top left corner at 400,300 and i rotate it around its center by 45 degrees around its center, how do i find the new locations of the bottom track. Thanks

    Read the article

  • Downloading HTTP URLs asynchronously in C++

    - by Joey Adams
    What's a good way to download HTTP URLs (e.g. such as http://0.0.0.0/foo.htm ) in C++ on Linux ? I strongly prefer something asynchronous. My program will have an event loop that repeatedly initiates multiple (very small) downloads and acts on them when they finish (either by polling or being notified somehow). I would rather not have to spawn multiple threads/processes to accomplish this. That shouldn't be necessary. Should I look into libraries like libcurl? I suppose I could implement it manually with non-blocking TCP sockets and select() calls, but that would likely be less convenient.

    Read the article

  • Precise explanation of JavaScript <-> DOM circular reference issue

    - by Joey Adams
    One of the touted advantages of jQuery.data versus raw expando properties (arbitrary attributes you can assign to DOM nodes) is that jQuery.data is "safe from circular references and therefore free from memory leaks". An article from Google titled "Optimizing JavaScript code" goes into more detail: The most common memory leaks for web applications involve circular references between the JavaScript script engine and the browsers' C++ objects' implementing the DOM (e.g. between the JavaScript script engine and Internet Explorer's COM infrastructure, or between the JavaScript engine and Firefox XPCOM infrastructure). It lists two examples of circular reference patterns: DOM element → event handler → closure scope → DOM DOM element → via expando → intermediary object → DOM element However, if a reference cycle between a DOM node and a JavaScript object produces a memory leak, doesn't this mean that any non-trivial event handler (e.g. onclick) will produce such a leak? I don't see how it's even possible for an event handler to avoid a reference cycle, because the way I see it: The DOM element references the event handler. The event handler references the DOM (either directly or indirectly). In any case, it's almost impossible to avoid referencing window in any interesting event handler, short of writing a setInterval loop that reads actions from a global queue. Can someone provide a precise explanation of the JavaScript ↔ DOM circular reference problem? Things I'd like clarified: What browsers are effected? A comment in the jQuery source specifically mentions IE6-7, but the Google article suggests Firefox is also affected. Are expando properties and event handlers somehow different concerning memory leaks? Or are both of these code snippets susceptible to the same kind of memory leak? // Create an expando that references to its own element. var elem = document.getElementById('foo'); elem.myself = elem; // Create an event handler that references its own element. var elem = document.getElementById('foo'); elem.onclick = function() { elem.style.display = 'none'; }; If a page leaks memory due to a circular reference, does the leak persist until the entire browser application is closed, or is the memory freed when the window/tab is closed?

    Read the article

  • How do you tell that your unit tests are correct?

    - by Jacob Adams
    I've only done minor unit testing at various points in my career. Whenever I start diving into it again, it always troubles me how to prove that my tests are correct. How can I tell that there isn't a bug in my unit test? Usually I end up running the app, proving it works, then using the unit test as a sort of regression test. What is the recommended approach and/or what is the approach you take to this problem? Edit: I also realize that you could write small, granular unit tests that would be easy to understand. However, if you assume that small, granular code is flawless and bulletproof, you could just write small, granular programs and not need unit testing. Edit2: For the arguments "unit testing is for making sure your changes don't break anything" and "this will only happen if the test has the exact same flaw as the code", what if the test overfits? It's possible to pass both good and bad code with a bad test. My main question is what good is unit testing since if your tests can be flawed you can't really improve your confidence in your code, can't really prove your refactoring worked, and can't really prove that you met the specification?

    Read the article

  • Ajax div can't access address bar variable

    - by Elaine Adams
    Can someone please advise me on how my Ajax div can get an address bar variable. The usual way just doesn't work. My address bar currently looks like this: http://localhost/social3/browse/?locationName=Cambridge Usually, I would use a little php and do this: $searchResult = $_POST['locationName']; echo $searchResult; But because I'm in an Ajax div, I can't seem to get to the variable. Do I need to add some JavaScript wizardry to my Ajax coding? (I have little knowledge of this) My Ajax: <script> window.onload = function () { var everyone = document.getElementById('everyone'), searching = document.getElementById('searching'), searchingSubmit = document.getElementById('searchingSubmit'); everyone.onclick = function() { loadXMLDoc('indexEveryone'); everyone.className = 'filterOptionActive'; searching.className = 'filterOption'; } searching.onclick = function() { loadXMLDoc('indexSearching'); searching.className = 'filterOptionActive'; everyone.className = 'filterOption'; } searchingSubmit.onclick = function() { loadXMLDoc('indexSearchingSubmit'); } function loadXMLDoc(pageName) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("leftCont").innerHTML=xmlhttp.responseText; } } function get_query(){ var url = location.href; var qs = url.substring(url.indexOf('?') + 1).split('&'); for(var i = 0, result = {}; i < qs.length; i++){ qs[i] = qs[i].split('='); result[qs[i][0]] = decodeURIComponent(qs[i][1]); } return result; } xmlhttp.open("GET","../browse/" + pageName + ".php?user=" + get_query()['user'],true); xmlhttp.send(); } } </script> <!-- ends ajax script -->

    Read the article

  • Get the window height

    - by Mitchan Adams
    This is frustrating me. It should be something really simple but I can't get it to work IE. I want to get the height of the current window. Not the scroll height, not the document height, the actual window height. I've tried window.innerHeight which returns undefined and document.documentElement.clientHeight which gives the scroll height.

    Read the article

  • One-to-one Mapping issue with NHibernate/Fluent: Foreign Key not updateing

    - by Trevor
    Summary: Parent and Child class. One to one relationship between the Parent and Child. Parent has a FK property which references the primary key of the Child. Code as follows: public class NHTestParent { public virtual Guid NHTestParentId { get; set; } public virtual Guid ChildId { get { return ChildRef.NHTestChildId; } set { } } public virtual string ParentName { get; set; } protected NHTestChild _childRef; public virtual NHTestChild ChildRef { get { if (_childRef == null) _childRef = new NHTestChild(); return _childRef; } set { _childRef = value; } } } public class NHTestChild { public virtual Guid NHTestChildId { get; set; } public virtual string ChildName { get; set; } } With the following Fluent mappings: Parent Mapping Id(x => x.NHTestParentId); Map(x => x.ParentName); Map(x => x.ChildId); References(x => x.ChildRef, "ChildId").Cascade.All(); Child Mapping: Id(x => x.NHTestChildId); Map(x => x.ChildName); If I do something like (pseudo code) ... HTestParent parent = new NHTestParent(); parent.ParentName = "Parent 1"; parent.ChildRef.ChildName = "Child 1"; nhibernateSession.SaveOrUpdate(aParent); Commit; ... I get an error: "Invalid index 3 for this SqlParameterCollection with Count=3" If I change the parent 'References' line as follows (i.e. provide the name of the child property I'm pointing at): References(x => x.ChildRef, "ChildId").PropertyRef("NHTestChildId").Cascade.All(); I get the error: "Unable to resolve property: NHTestChildId" So, I tried the 'HasOne()' reference setting, as follows: HasOne<NHTestChild>(x => x.ChildRef).ForeignKey("ChildId").Cascade.All().Fetch.Join(); This results in the save working, but the load fails to find the child. If I inspect the SQL Nhibernate produces I can see that NHibernate is assuming the Primary key of the parent is the link to the child (i.e. load join condition is "parent.NHTestParentId = child.NHTestChildId). The 'ForeignKey' specified appears to be ignored. I can set any value and no error occurs - the join just always fails and no child is returned. I've tried a number of slight variations on the above. It seems like it should be a simple thing to achieve. Any ideas?

    Read the article

  • In NHibernate, how do I combine two DetachedCriteria instances

    - by Trevor
    My scenario is this: I have a base NHibernate query to run of the form (I've coded it using DetachedCriteria , but describe it here using SQL syntax): SELECT * FROM Items I INNER JOIN SubItems S on S.FK = I.Key The user interface to show the results of this join allows the user to specify additional criteria: Say: I.SomeField = 'UserValue'. Now, I need the final load command to be: SELECT * FROM Items I INNER JOIN SubItems S on S.FK = I.Key WHERE I.SomeField = 'UserValue' My problem is: I've created a DetachedCriteria with the 'static' aspect of the query (the top join) and the UI creates a DetachedCriteria with the 'dynamic' component of the query. I need to combine the two into a final query that I can execute on the NHibernate session. DefaultCriteria.Add() takes an ICriterion (which are created using the Expression class, and maybe other classes I don't know of which could be the solution to my problem). Does anyone know how I might do what I want?

    Read the article

  • jquery Ajax sortable list stops being sortable when Ajax call updates the list html

    - by Trevor
    Hi, I am using jquery 1.4.2 and trying to achieve the following: 1 - function call that sends a value to a php page to add/remove an item 2 - returns html list of the items 3 - list should still be sortable 4 - save (serialise list) onclick My full WIP is located here [http://www.chittak.co.uk/test4/index_nw3.php][1] I tried to delegate from the level above the UL but I could get this to work $("#construnctionstage").delegate('ul li', 'click', function(){ The initial list is sortable, when you click add/remove the ajax function returns a new list with the a number of items, BUT I am doing something wrong as the alert message continues to work while the list is no longer sortable. $(document).ready(function(){ $('ul').delegate('li', 'click', function(){ alert('You clicked on an li element!'); /*$("#test-list").sortable({ handle : '.handle', update : function () { var order = $('#test-list').sortable('serialize'); $("#info").load("process-sortable.php?"+order); } });*/ }).sortable({ handle : '.handle', update : function () { var order = $('#test-list').sortable('serialize'); $("#info").load("process-sortable.php?"+order); } }); }); <div id="construnctionstage"> <ul id="test-list"> <li id="listItem_1">

    Read the article

  • Assigning console.log to another object (Webkit issue)

    - by Trevor Burnham
    I wanted to keep my logging statements as short as possible while preventing console from being accessed when it doesn't exist; I came up with the following solution: var _ = {}; if (console) { _.log = console.debug; } else { _.log = function() { } } To me, this seems quite elegant, and it works great in Firefox 3.6 (including preserving the line numbers that make console.debug more useful than console.log). But it doesn't work in Safari 4. [Update: Or in Chrome. So the issue seems to be a difference between Firebug and the Webkit console.] If I follow the above with console.debug('A') _.log('B'); the first statement works fine in both browsers, but the second generates a "TypeError: Type Error" in Safari. Is this just a difference between how Firebug and the Safari Web Developer Tools implement console? If so, it is VERY annoying on Apple's Webkit's part. Binding the console function to a prototype and then instantiating, rather than binding it directly to the object, doesn't help. I could, of course, just call console.debug from an anonymous function assigned to _.log, but then I'd lose my line numbers. Any other ideas?

    Read the article

  • Python sudoku programming

    - by trevor
    I need your help on this. I have this program and I must finish it. It's missing 3 parts. Here is the program I'm working with: import copy def display(A): if A: for i in range(9): for j in range(9): if type(A[i][j]) == type([]): print A[i][j][0], else: print A[i][j], print print else: print A def has_conflict(A): for i in range(9): for j in range(9): for (x,y) in get_neighbors(i,j): if len(A[i][j])==1 and A[i][j]==A[x][y]: return True return False # HERE ARE THE PARTS THAT REQUIRE HELP!!!! def get_neighbors(x,y): return [] def update(A, i, j, value): return [] def solve(A): return [] # ENDS PARTS THAT REQUIRE HELP!!!! A = [] infile = open('puzzle1.txt', 'r') for i in range(9): A += [[]] for j in range(9): num = int(infile.read(2)) if num: A[i] += [[num]] else: A[i] += [[1,2,3,4,5,6,7,8,9]] for i in range(9): for j in range(9): if len(A[i][j])==1: A = update(A, i,j, A[i][j][0]) if A==[]: break if A==[]: break if A<>[]: A = solve(A) display(A) I need to solve the stuff formerly in bold letters, now explicitly marked in the code, specifically - get_neighbors(): - update(): - solve(): Thank you for your time and help.

    Read the article

  • Implementing EAV pattern with Hibernate for User -> Settings relationship

    - by Trevor
    I'm trying to setup a simple EAV pattern in my web app using Java/Spring MVC and Hibernate. I can't seem to figure out the magic behind the hibernate XML setup for this scenario. My database table "SETUP" has three columns: user_id (FK) setup_item setup_value The database composite key is made up of user_id | setup_item Here's the Setup.java class: public class Setup implements CommonFormElements, Serializable { private Map data = new HashMap(); private String saveAction; private Integer speciesNamingList; private User user; Logger log = LoggerFactory.getLogger(Setup.class); public String getSaveAction() { return saveAction; } public void setSaveAction(String action) { this.saveAction = action; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } public Integer getSpeciesNamingList() { return speciesNamingList; } public void setSpeciesNamingList(Integer speciesNamingList) { this.speciesNamingList = speciesNamingList; } public Map getData() { return data; } public void setData(Map data) { this.data = data; } } My problem with the Hibernate setup, is that I can't seem to figure out how to map out the fact that a foreign key and the key of a map will construct the composite key of the table... this is due to a lack of experience using Hibernate. Here's my initial attempt at getting this to work: <composite-id> <key-many-to-one foreign-key="id" name="user" column="user_id" class="Business.User"> <meta attribute="use-in-equals">true</meta> </key-many-to-one> </composite-id> <map lazy="false" name="data" table="setup"> <key column="user_id" property-ref="user"/> <composite-map-key class="Command.Setup"> <key-property name="data" column="setup_item" type="string"/> </composite-map-key> <element column="setup_value" not-null="true" type="string"/> </map> Any insight into how to properly map this common scenario would be most appreciated!

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11  | Next Page >