Search Results

Search found 3484 results on 140 pages for 'chris dubois'.

Page 102/140 | < Previous Page | 98 99 100 101 102 103 104 105 106 107 108 109  | Next Page >

  • How to lowercase every element of a collection efficiently?

    - by Chris
    Whats the most efficient way to lower case every element of a list or set? My idea for a List: final List<String> strings = new ArrayList<String>(); strings.add("HELLO"); strings.add("WORLD"); for(int i=0,l=strings.size();i<l;++i) { strings.add(strings.remove(0).toLowerCase()); } is there a better, faster way? How would this exmaple look like for a set? As there is currently no method for applying an operation to each element of a set (or list) can it be done without creating an additional temporary set? Something like this would be nice: Set<String> strings = new HashSet<String>(); strings.apply( function (element) { this.replace(element, element.toLowerCase();) } ); Thanks,

    Read the article

  • JNI String Corruption

    - by Chris Dennett
    Hi everyone, I'm getting weird string corruption across JNI calls which is causing problems on the the Java side. Every so often, I'll get a corrupted string in the passed array, which sometimes has existing parts of the original non-corrupted string. The C++ code is supposed to set the first index of the array to the address, it's a nasty hack to get around method call limitations. Additionally, the application is multi-threaded. remoteaddress[0]: 10.1.1.2:49153 remoteaddress[0]: 10.1.4.2:49153 remoteaddress[0]: 10.1.6.2:49153 remoteaddress[0]: 10.1.2.2:49153 remoteaddress[0]: 10.1.9.2:49153 remoteaddress[0]: {garbage here} java.lang.NullPointerException at kokuks.KKSAddress.<init>(KKSAddress.java:139) at kokuks.KKSAddress.createAddress(KKSAddress.java:48) at kokuks.KKSSocket._recvFrom(KKSSocket.java:963) at kokuks.scheduler.RecvOperation$1.execute(RecvOperation.java:144) at kokuks.scheduler.RecvOperation$1.execute(RecvOperation.java:1) at kokuks.KKSEvent.run(KKSEvent.java:58) at kokuks.KokuKS.handleJNIEventExpiry(KokuKS.java:872) at kokuks.KokuKS.handleJNIEventExpiry_fjni(KokuKS.java:880) at kokuks.KokuKS.runSimulator_jni(Native Method) at kokuks.KokuKS$1.run(KokuKS.java:773) at java.lang.Thread.run(Thread.java:717) remoteaddress[0]: 10.1.7.2:49153 The null pointer exception comes from trying to use the corrupt string. In C++, the address prints to standard out normally, but doing this reduces the rate of errors, from what I can see. The C++ code (if it helps): /* * Class: kokuks_KKSSocket * Method: recvFrom_jni * Signature: (Ljava/lang/String;[Ljava/lang/String;Ljava/nio/ByteBuffer;IIJ)I */ JNIEXPORT jint JNICALL Java_kokuks_KKSSocket_recvFrom_1jni (JNIEnv *env, jobject obj, jstring sockpath, jobjectArray addrarr, jobject buf, jint position, jint limit, jlong flags) { if (addrarr && env->GetArrayLength(addrarr) > 0) { env->SetObjectArrayElement(addrarr, 0, NULL); } jboolean iscopy; const char* cstr = env->GetStringUTFChars(sockpath, &iscopy); std::string spath = std::string(cstr); env->ReleaseStringUTFChars(sockpath, cstr); // release me! if (KKS_DEBUG) { std::cout << "[kks-c~" << spath << "] " << __PRETTY_FUNCTION__ << std::endl; } ns3::Ptr<ns3::Socket> socket = ns3::Names::Find<ns3::Socket>(spath); if (!socket) { std::cout << "[kks-c~" << spath << "] " << __PRETTY_FUNCTION__ << " socket not found for path!!" << std::endl; return -1; // not found } if (!addrarr) { std::cout << "[kks-c~" << spath << "] " << __PRETTY_FUNCTION__ << " array to set sender is null" << std::endl; return -1; } jsize arrsize = env->GetArrayLength(addrarr); if (arrsize < 1) { std::cout << "[kks-c~" << spath << "] " << __PRETTY_FUNCTION__ << " array too small to set sender!" << std::endl; return -1; } uint8_t* bufaddr = (uint8_t*)env->GetDirectBufferAddress(buf); long bufcap = env->GetDirectBufferCapacity(buf); uint8_t* realbufaddr = bufaddr + position; uint32_t remaining = limit - position; if (KKS_DEBUG) { std::cout << "[kks-c~" << spath << "] " << __PRETTY_FUNCTION__ << " bufaddr: " << bufaddr << ", cap: " << bufcap << std::endl; } ns3::Address aaddr; uint32_t mflags = flags; int ret = socket->RecvFrom(realbufaddr, remaining, mflags, aaddr); if (ret > 0) { if (KKS_DEBUG) std::cout << "[kks-c~" << spath << "] " << __PRETTY_FUNCTION__ << " addr: " << aaddr << std::endl; ns3::InetSocketAddress insa = ns3::InetSocketAddress::ConvertFrom(aaddr); std::stringstream ss; insa.GetIpv4().Print(ss); ss << ":" << insa.GetPort() << std::ends; if (KKS_DEBUG) std::cout << "[kks-c~" << spath << "] " << __PRETTY_FUNCTION__ << " addr: " << ss.str() << std::endl; jsize index = 0; const char *cstr = ss.str().c_str(); jstring jaddr = env->NewStringUTF(cstr); if (jaddr == NULL) std::cout << "[kks-c~" << spath << "] " << __PRETTY_FUNCTION__ << " jaddr is null!!" << std::endl; //jaddr = (jstring)env->NewGlobalRef(jaddr); env->SetObjectArrayElement(addrarr, index, jaddr); //if (env->ExceptionOccurred()) { // env->ExceptionDescribe(); //} } jint jret = ret; return jret; } The Java code (if it helps): /** * Pass an array of size 1 into remote address, and this will be set with * the sender of the packet (hax). This emulates C++ references. * * @param remoteaddress * @param buf * @param flags * @return */ public int _recvFrom(final KKSAddress remoteaddress[], ByteBuffer buf, long flags) { if (!kks.isCurrentlyThreadSafe()) throw new RuntimeException( "Not currently thread safe for ns-3 functions!" ); //lock.lock(); try { if (!buf.isDirect()) return -6; // not direct!! final String[] remoteAddrStr = new String[1]; int ret = 0; ret = recvFrom_jni( path.toPortableString(), remoteAddrStr, buf, buf.position(), buf.limit(), flags ); if (ret > 0) { System.out.println("remoteaddress[0]: " + remoteAddrStr[0]); remoteaddress[0] = KKSAddress.createAddress(remoteAddrStr[0]); buf.position(buf.position() + ret); } return ret; } finally { errNo = _getErrNo(); //lock.unlock(); } } public int recvFrom(KKSAddress[] fromaddress, final ByteBuffer bytes, long flags, long timeoutMS) { if (KokuKS.DEBUG_MODE) printMessage("public synchronized int recvFrom(KKSAddress[] fromaddress, final ByteBuffer bytes, long flags, long timeoutMS)"); if (kks.isCurrentlyThreadSafe()) { return _recvFrom(fromaddress, bytes, flags); // avoid event } fromaddress[0] = null; RecvOperation ro = new RecvOperation( kks, this, flags, true, bytes, timeoutMS ); ro.start(); fromaddress[0] = ro.getFrom(); return ro.getRetCode(); }

    Read the article

  • Reusing a NSString variable - does it cause a memory leak?

    - by Chris S
    Coming from a .NET background I'm use to reusing string variables for storage, so is the code below likely to cause a memory leak? The code is targeting OS X on the iphone/itouch so no automatic GC. -(NSString*) stringExample { NSString *result = @"example"; result = [result stringByAppendingString:@" test"]; // where does "example" go? return result; } What confuses me is an NSStrings are immutable, but you can reuse an 'immutable' variable with no problem.

    Read the article

  • compare function for dates

    - by Chris
    I have struct as: struct stored { char *dates; // 12/May/2010, 10/Jun/2010 etc.. int ctr; }; // const struct stored structs[] = {{"12/May/2010", 1}, {"12/May/2011", 1}, {"21/May/2009", 4}, {"12/May/2011", 3}, {"10/May/2011", 8}, {"12/May/2011", 4 }}; What I want to do is to sort struct 'stored' by stored.dates. qsort(structs, 9, sizeof(struct stored*), sortdates); // sortdates function I'm not quite sure what would be a good way to sort those days? Compare them as c-strings?

    Read the article

  • After installing .net 3.5 SP1, get missing DLL error

    - by chris
    I just installed a number of updates to my machine, and am now encountering the following error when I run an asp.net MVC application on my local machine: Compiler Error Message: CS0006: Metadata file 'C:\WINNT\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll' could not be found I have removed the reference to this from the project (not really sure why it was there in the first place) but still get the error. Any idea on how to resolve this?

    Read the article

  • Enterprise integration of disparate systems

    - by Chris Latta
    We're about to embark on a fairly large integration effort to kill off a bunch of Access and Sql Server databases and get everything into one coherent enterprise system. There are also a number of other systems (accounting, CRM, payroll, MS Exchange) that hold critical data that we need to integrate (use for data validation in other systems), report on and otherwise expose. It is likely that some of these systems will change in the next few years, so we need to isolate our systems to be ready for change. Ideally we would be able to expose our forms in a consistent manner across as many of our our systems as possible without having to re-develop them for each system. We are currently targeting SharePoint (2007 and soon 2010), Office (2007 and soon 2010 - Word, Excel, PowerPoint and Outlook), Reporting Services, .Net console applications, .Net Windows applications, shell extensions, and with the possibility of exposing some functionality on mobile devices (BlackBerries currently, maybe iPhones later) and via our website. We're moving development to Visual Studio 2010 (from 2005) ahead of migrating to SharePoint 2010 and Office 2010. Given that most of our development is presently targeted to the .Net framework (mostly in C#) it seems logical to stick with this unless there is some compelling reason to switch frameworks/platform for some aspects. We're thinking of your standard Database-Data Integration layer-Business Objects Layer-Web Services (or REST) layer-Client Application plus doing our own client application with WPF (or something else?) forms that can also be exposed in the MS systems (SharePoint, Office, Windows). So, we don't want much, just everything :) Basically we need to isolate ourselves from database and systems changes, create an API that can be used throughout our systems and then make this functionality available in our client applications. I'm very keen to get pointers from anyone who has tips on how to pull this off. Should we look at the Enterprise Library as a place to start? Is REST with ASP.Net MVC2 a better solution than Web Services for a system like this? Will WPF deliver forms re-use or is there something better?

    Read the article

  • Disable buttons on post back using jquery in .net app

    - by Chris Lively
    I have a asp.net app that I want to disable the buttons as soon as they are clicked in order to prevent multiple submissions. I'd like to use jquery for this as the site already liberally uses it anyway. What I've tried is: $(document).ready(function () { $("#aspnetForm").submit(function () { $('input[type=submit]', $(this)).attr("disabled", "disabled"); }) }); The above will disable the button, and the page submits, but the asp.net button on click handler is never called. Simply removing the above and the buttons work as normal. Is there a better way?

    Read the article

  • Is C++ Unmanaged?

    - by Chris Becke
    Am I the only one bugged by the phrase "unmanaged c++"? I think the phrase is implicitly insulting, and is designed to be so. Stroustrup never wrote "The Design and Evolution of Unmanaged C++" and the not unmanaged C++ standards committee is not working on "UC++1x". Maybe I should disingeneously invent a suite of languages called "Faster" purely so I can refer to any language I want to implicitly denigrate with a "Slow" prefix. "Oh, youre using Slow CSharp? Shame!"

    Read the article

  • Why must I rewind IteratorIterator

    - by chris
    $arrayIter = new ArrayIterator( array(1, 2) ); $iterIter = new IteratorIterator($arrayIter); var_dump($iterIter->valid()); //false var_dump($arrayIter->valid()); //true If I first call $iterIter-rewind(), then $iterIter-valid() is true. I'm curious why it requires that rewind() be called. I imagine there's good reason for it, but I would have expected it to simply start iteration at whatever state it's inner iterator is in, and leave it as an option to rewind before beginning iteration. calling next() also seems to put it in a "valid" state(although it advances to the next position, suggesting it was previously at the first position). $arrayIter = new ArrayIterator(array(1,2)); $iterIter = new IteratorIterator($arrayIter); $iterIter->next(); var_dump($iterIter->valid()); Again, I'm curious why I need to call rewind(), despite the inner iterator being in a valid state.

    Read the article

  • LinkedList Wrong Display(string builder)

    - by Chris
    Hello, The following program is a basic linked list divided in 3 classes. In the tester class (main) i add several numbers to the list (sorted). But insteed of getting the numbers as a result i get the result: LinkedList.LinkedList Is something wrong with the stringbuilder (the program was first in java where a string buffer was used, but that should be the same i think?) LinkedListTester.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LinkedList { public class LinkedListTester { static void Main(string[] args) { LinkedList ll = new LinkedList(); ll.addDataSorted(5); ll.addDataSorted(7); ll.addDataSorted(13); ll.addDataSorted(1); ll.addDataSorted(17); ll.addDataSorted(8); Console.WriteLine(ll); } } }/LinkedList/ LinkedList.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LinkedList { public class LinkedList { //toestand private LinkedListNode first; private LinkedListNode last; //gedrag public LinkedList() { first = null; last = null; } public void addDataInFront(int data) { first = new LinkedListNode(data, first); if (last == null){ last = first; } }/*addDataInFront*/ public void addDataToBack(int data) { if (first == null) { addDataInFront(data); } else { last.setNext(new LinkedListNode(data, null)); last = last.getNext(); } }/*addDataToBack*/ public void addDataSorted(int data) { if (first == null || first.getData() > data) { addDataInFront(data); } else { LinkedListNode currentNode = first; while (currentNode.getNext() != null && currentNode.getNext().getData() < data) { currentNode = currentNode.getNext(); } currentNode.setNext(new LinkedListNode(data, currentNode.getNext())); currentNode = currentNode.getNext(); if (currentNode.getNext() == null) { last = currentNode; } } }/*addDataSorted*/ public String toString() { StringBuilder Buf = new StringBuilder(); LinkedListNode currentNode = first; while (currentNode != null) { Buf.Append(currentNode.getData()); Buf.Append(' '); currentNode = currentNode.getNext(); } return Buf.ToString(); }/*toString*/ }/*LinkedList*/ }/LinkedList/ LinkedListNode: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LinkedList { public class LinkedListNode { //toestand private int data; private LinkedListNode next; private LinkedListNode previous; //gedrag public LinkedListNode(int data, LinkedListNode next) { this.data = data; this.next = next; this.previous = null; } public LinkedListNode(int data, LinkedListNode next, LinkedListNode previous) { this.data = data; this.next = next; this.previous = previous; } public LinkedListNode getNext() { return next; } public LinkedListNode getPrevious() { return previous; } public void setNext(LinkedListNode next) { this.next = next; } public void setPrevious(LinkedListNode previous) { this.previous = previous; } public int getData() { return data; } }/*LinkedListNode*/ }/LinkedList/

    Read the article

  • Set Page Output Cache VaryByCustom value programmatically

    - by Chris Marisic
    I want to use an Enum value for the types of VaryByCustom parameters I will support, is it possible to do this? I tried setting it in the page itself <%@ OutputCache Duration="600" VaryByParam="none" VaryByCustom='<%=VaryByCustomType.IsAuthenticated.ToString(); %>' %> But this returned the entire literal string "<%=VaryByCustomType.IsAuthenticated.ToString(); %>" inside my global.asax is there any way to do this either on the page itself or from the codebehind? Or is this just something I have to accept is purely magic strings and nothing I can do to add type safety to it?

    Read the article

  • larger file upload problem with php

    - by chris
    I need to upload a csv file to a server. works fine for smaller files but when the file is 3-6 meg its not working. $allowedExtensions = array("csv"); foreach ($_FILES as $file) { if ($file['tmp_name'] > '') { if (!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions)) { die($file['name'].' is an invalid file type!<br/>'. '<a href="javascript:history.go(-1);">'. '&lt;&lt Go Back</a>'); } if (move_uploaded_file($file['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; } echo "File has been uploaded"; } //upload form <form name="upload" enctype="multipart/form-data" action="<? echo $_SERVER['php_self'];?>?action=upload_process" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="31457280" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form> I have also added this to htaccess php_value upload_max_filesize 20M php_value post_max_size 20M php_value max_execution_time 200 php_value max_input_time 200 Where am i going wrong?

    Read the article

  • App store for the PC?

    - by Chris
    So I've spent a lot of time making an iPhone game and have recently realized that I don't have to limit myself to just Apple - I know there are app stores for Palm and Android, but does anybody know of a good "app store" for the plain old PC? I would like to have one where individual developers can publish an app and not have to worry about all the billing and piracy issues!

    Read the article

  • Is there a limit to the number of DataContracts that can be used by a WCF Service?

    - by Chris
    Using WCF3.5SP1, VS2008. Building a WCF service that exposes about 10 service methods. We have defined about 40 [DataContract] types that are used by the service. We now experience that adding an additional [DataContract] type to the project (in the same namespace as the other existing types) does not get properly exposed. The new type is not in the XSD schemas generated with the WSDL. We have gone so far as to copy and rename an existing (and working) type, but it too is not present in the generated WSDL/XSD. We've tried this on two different developer machines, same problem. Is there a limit to the number of types that can exposed as [DataContract] for a Service? per Namespace?

    Read the article

  • jQuery - Multiple setInterval Conflict

    - by Chris Bowyer
    I am a jQuery novice and each of the following work fine on their own, but get out of time when working together. What am I doing wrong? Any improvement on the code would be appreciated too... It is to be used to rotate advertising. <!--- Header Rotator ---> <script type="text/javascript"> $(document).ready(function() { $("#header").load("header.cfm"); var refreshHeader = setInterval(function() { $("#header").load("header.cfm"); }, 10000); }); </script> <!--- Main Rotator ---> <script type="text/javascript"> $(document).ready(function() { $("#main").load("main.cfm"); var refreshMain = setInterval(function() { $("#main").load("main.cfm"); }, 5000); }); </script> <!--- Footer Rotator ---> <script type="text/javascript"> $(document).ready(function() { $("#footer").load("footer.cfm"); var refreshFooter = setInterval(function() { $("#footer").load("footer.cfm"); }, 2000); }); </script>

    Read the article

  • Microsoft Excel; Two conditions have to be true then be counted

    - by Chris Jones
    I'm working on a spreadsheet that two conditions have to true in order to be counted. If the month is January, and the number next to it is less than or equal to 30, then it's counted. Same rule applies for all the other months. Thus far, I have: =COUNTIFS(Sheet1!D2:D7,(SUMPRODUCT(--(MONTH(D2:D7)=1))),Sheet1!E2:E7,(COUNTIFS(E2:E7,"<=30"))) For example: Column D Jan 1, 2014 Feb 3, 2014 Feb 16, 2014 Mar 5, 2014 Mar 13, 2014 Mar 29, 2014 Column E 37 25 30 31 1 16 Outcome Jan 0 Feb 2 Mar 2

    Read the article

  • Executing an exe with arguments using Powershell

    - by Chris Charge
    This is what I want to execute: c:\Program Files (x86)\SEQUEL ViewPoint\viewpoint.exe /Setvar((POSTSTR $POSTSTR)(POSTEND $POSTEND)) /G:C:\viewpointfile.vpt /D:C:($BEGDATE to $TODDATE).xls This is what I have tried: $a = "/Setvar((POSTSTR $POSTSTR)(POSTEND $POSTEND))" $b = "/G:C:\viewpointfile.vpt" $c = "/D:C:($BEGDATE to $TODDATE).xls" $Viewpoint = "c:\Program Files (x86)\SEQUEL ViewPoint\viewpoint.exe" &$Viewpoint $a $b $c When I execute this I receive an error stating: File C:\viewpointfile.vpt "/D:C:($BEGDATE to $TODDATE).xls" not found! I'm not sure where it gets the extra quotes from. If I run the command with just $a and $b it runs fine. Any help would be greatly appreciated. Thanks! :) Update manojlds suggested echoargs so here it the output from it: &./echoargs.exe $viewpoint $a $b $c Arg 0 is C:\Program Files (x86)\SEQUEL ViewPoint\viewpoint.exe Arg 1 is /Setvar((POSTSTR 20101123)(POSTEND 20111123)) Arg 2 is /G:C:\viewpointfile.vpt Arg 3 is /D:C:(2010-11-23 to 2011-11-23 PM).xls It appears that all the arguments are being passed properly. When I run this as a command in cmd.exe it executes perfectly. So something on Powershells end must be messing up the output. Is there any other way to go about executing this command using Powershell?

    Read the article

  • Need help optimizing a NHibernate criteria query that uses Restrictions.In(..)

    - by Chris F
    I'm trying to figure out if there's a way I can do the following strictly using Criteria and DetachedCriteria via a subquery or some other way that is more optimal. NameGuidDto is nothing more than a lightweight object that has string and Guid properties. public IList<NameGuidDto> GetByManager(Employee manager) { // First, grab all of the Customers where the employee is a backup manager. // Access customers that are primarily managed via manager.ManagedCustomers. // I need this list to pass to Restrictions.In(..) below, but can I do it better? Guid[] customerIds = new Guid[manager.BackedCustomers.Count]; int count = 0; foreach (Customer customer in manager.BackedCustomers) { customerIds[count++] = customer.Id; } ICriteria criteria = Session.CreateCriteria(typeof(Customer)) .Add(Restrictions.Disjunction() .Add(Restrictions.Eq("Manager", manager)) .Add(Restrictions.In("Id", customerIds))) .SetProjection(Projections.ProjectionList() .Add(Projections.Property("Name"), "Name") .Add(Projections.Property("Id"), "Guid")) // Transform results to NameGuidDto criteria.SetResultTransformer(Transformers.AliasToBean(typeof(NameGuidDto))); return criteria.List<NameGuidDto>(); }

    Read the article

  • Javascript Alert Return value / Event

    - by Chris
    Hey, The question is pretty simple, but i'm not the big AJAX/JS coder, so I have no clue if it's possible. Is there any way that I can check whether or not an alert() was executed on a remote site? Like if I inputted an alert("Welcome to this site"); through a get variable, is there any way to check if it that alert() was actually executed in the browser? And not necessarily through AJAX/JS.

    Read the article

< Previous Page | 98 99 100 101 102 103 104 105 106 107 108 109  | Next Page >