Search Results

Search found 575 results on 23 pages for 'aaa'.

Page 11/23 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • iphone shake error

    - by aaa
    Right now I have this- [code] - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.type == UIEventSubtypeMotionShake) { int text = rand() % 12; switch (text) { case 0: textview.text = @"blah." ; break;[/code] For some reason, the text has to be selected for it to work. If you just shake it, nothing will happen.

    Read the article

  • Using methods on 2 input files - 2nd is printing multiple times - Java

    - by Aaa
    I have the following code to read in text, store in a hashmap as bigrams (with other methods to sort them by frequency and do v. v. basic additive smoothing. I had it working great for one language input file (english) and then I want to expand it for the second language input file (japanese - doens;t matter what it is I suppose) using the same methods but the Japanese bigram hashmap is printing out 3 times in a row with diff. values. I've tried using diff text in the input file, making sure there are no gaps in text etc. I've also put print statements at certain places in the Japanese part of the code to see if I can get any clues but all the print statements are printing each time so I can't work out if it is looping at a certain place. I have gone through it with a fine toothcomb but am obviously missing something and slowly going crazy here - any help would be appreciated. thanks in advance... package languagerecognition2; import java.lang.String; import java.io.InputStreamReader; import java.util.*; import java.util.Iterator; import java.util.List.*; import java.util.ArrayList; import java.util.AbstractMap.*; import java.lang.Object; import java.io.*; import java.util.Enumeration; import java.util.Arrays; import java.lang.Math; public class Main { /** public static void main(String[] args) { //training English ----------------------------------------------------------------- File file = new File("english1.txt"); StringBuffer contents = new StringBuffer(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String test = null; //test = reader.readLine(); // repeat until all lines are read while ((test = reader.readLine()) != null) { test = test.toLowerCase(); char[] charArrayEng = test.toCharArray(); HashMap<String, Integer> hashMapEng = new HashMap<String, Integer>(bigrams(charArrayEng)); LinkedHashMap<String, Integer> sortedListEng = new LinkedHashMap<String, Integer>(sort(hashMapEng)); int sizeEng=sortedListEng.size(); System.out.println("Total count of English bigrams is " + sizeEng); LinkedHashMap<String, Integer> smoothedListEng = new LinkedHashMap<String, Integer>(smooth(sortedListEng, sizeEng)); //print linkedHashMap to check values Set set= smoothedListEng.entrySet(); Iterator iter = set.iterator ( ) ; System.out.println("Beginning English"); while ( iter.hasNext()) { Map.Entry entry = ( Map.Entry ) iter.next ( ) ; Object key = entry.getKey ( ) ; Object value = entry.getValue ( ) ; System.out.println( key+" : " + value); } System.out.println("End English"); }//end while }//end try catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (reader != null) { reader.close(); } } catch (IOException e) { e.printStackTrace(); } } //End training English----------------------------------------------------------- //Training japanese-------------------------------------------------------------- File file2 = new File("japanese1.txt"); StringBuffer contents2 = new StringBuffer(); BufferedReader reader2 = null; try { reader2 = new BufferedReader(new FileReader(file2)); String test2 = null; //repeat until all lines are read while ((test2 = reader2.readLine()) != null) { test2 = test2.toLowerCase(); char[] charArrayJap = test2.toCharArray(); HashMap<String, Integer> hashMapJap = new HashMap<String, Integer>(bigrams(charArrayJap)); //System.out.println( "bigrams stage"); LinkedHashMap<String, Integer> sortedListJap = new LinkedHashMap<String, Integer>(sort(hashMapJap)); //System.out.println( "sort stage"); int sizeJap=sortedListJap.size(); //System.out.println("Total count of Japanese bigrams is " + sizeJap); LinkedHashMap<String, Integer> smoothedListJap = new LinkedHashMap<String, Integer>(smooth(sortedListJap, sizeJap)); System.out.println( "smooth stage"); //print linkedHashMap to check values Set set2= smoothedListJap.entrySet(); Iterator iter2 = set2.iterator(); System.out.println("Beginning Japanese"); while ( iter2.hasNext()) { Map.Entry entry2 = ( Map.Entry ) iter2.next ( ) ; Object key = entry2.getKey ( ) ; Object value = entry2.getValue ( ) ; System.out.println( key+" : " + value); }//end while System.out.println("End Japanese"); }//end while }//end try catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (reader2 != null) { reader2.close(); } } catch (IOException e) { e.printStackTrace(); } } //end training Japanese--------------------------------------------------------- } //end main (inner)

    Read the article

  • C/C++ efficient bit array

    - by aaa
    hi. Can you recommend efficient/clean way to manipulate arbitrary length bit array? right now I am using regular int/char bitmask, but those are not very clean when array length is greater than datatype length. std vector<bool> is not available for me. thanks

    Read the article

  • Random Alpha numeric generator

    - by AAA
    Hi, I want to give our users in the database a unique alpha-numeric id. I am using the code below, will this always generate a unique id? Below is the old and updated version of the code: New php: // Generate Guid function NewGuid() { $s = strtoupper(md5(uniqid("something",true))); $guidText = substr($s,0,8) . '-' . substr($s,8,4) . '-' . substr($s,12,4). '-' . substr($s,16,4). '-' . substr($s,20); return $guidText; } // End Generate Guid $Guid = NewGuid(); echo $Guid; echo "<br><br><br>"; Old PHP: // Generate Guid function NewGuid() { $s = strtoupper(md5(uniqid("something",true))); $guidText = substr($s,0,8) . '-' . substr($s,8,4) . '-' . substr($s,12,4). '-' . substr($s,16,4). '-' . substr($s,20); return $guidText; } // End Generate Guid $Guid = NewGuid(); echo $Guid; echo "<br><br><br>"; Will this first code guarantee uniqueness?

    Read the article

  • emacs local version control

    - by aaa
    hello. I am wondering if there is local version control/snapshots for emacs independent of VC? let me clarify: every time I save buffer, I would like to be able to keep track of changes of each save in session. I know I can do something similar with backup files, but they are not automated like VC and a somewhat cumbersome. I have searched Google, but did not find the solution. Perhaps my query string was not good. Thanks

    Read the article

  • C++ boost function overloaded template

    - by aaa
    I cannot figure out why this segment gives unresolved overloaded function error (gcc version 4.3.4 (Debian 4.3.4-6)): #include <algorithm> #include <boost/function.hpp> int main { typedef boost::function2<const int&, const int&, const int&> max; max m(static_cast<max>(&std::max<int>)); } can you help me, thanks

    Read the article

  • C++ Boost bind value type {solved}

    - by aaa
    hello. I look in documentation and source code but cannot figure out how to get return value type of boost bind functor. I am trying to accomplish following: 35 template<typename T,size_t N, class F> 36 boost::array<typename F::value_type, N> make_array(T (&input)[N], F unary) { 37 boost::array<typename F::value_type, N> array; 38 std::transform(input, input + N, array.begin(), unary); 39 return array; 40 } where F can be bind functor. the above does not work because functor does not have value_type. for that matter, is there standard interface for unary/binary functor as far as return value. solution: it should be result_type. also equivalent defined are argument_type and first/second_argument_type for binary functions Thanks

    Read the article

  • Is this the right way to set a cookie?

    - by AAA
    // if login is ok then we add a cookie $_POST['user_name'] = stripslashes($_POST['user_name']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['user_name'], $hour); setcookie(Key_my_site, $_POST['password'], $hour); Is this a right way to set cookies? Its been causing me serious redirect errors. See here: PHP Redirect problem with subdomain

    Read the article

  • C++, what does this syntax mean?

    - by aaa
    i found this in this file: http://www.boost.org/doc/libs/1_43_0/boost/spirit/home/phoenix/core/actor.hpp What does this syntax means? struct actor ... { ... template <typename T0, typename T1> typename result<actor(T0&,T1&)>::type // this line thank you

    Read the article

  • strategy to allocate/free lots of small objects

    - by aaa
    hello I am toying with certain caching algorithm, which is challenging somewhat. Basically, it needs to allocate lots of small objects (double arrays, < 256 elements), with objects accessible through mapped value, map[key] = array. time to initialized array may be quite large, generally more than 10 thousand cpu cycles. By lots I mean around gigabyte in total. objects may need to be popped/pushed as needed, generally in random places, one object at a time. lifetime of an object is generally long, minutes or more, however, object may be subject to allocation/deallocation several times during duration of program. What would be good strategy to avoid memory fragmentation, while still maintaining reasonable allocate deallocate speed? I am using C++, so I can use new and malloc. Thanks. I know there a similar questions on website, http://stackoverflow.com/questions/2156745/efficiently-allocating-many-short-lived-small-objects, are somewhat different, thread safety is not immediate issue for me.

    Read the article

  • C++ runtime, display exception message

    - by aaa
    hello. I am using gcc on linux to compile C++ code. There are some exceptions which should not be handled and should close program. However, I would like to be able to display exception string: For example: throw std::runtime_error(" message"); does not display message, only type of error. I would like to display messages as well. Is there way to do it? it is a library, I really do not want to put catch statements and let library user decide. However, right now library user is fortran, which does not allow to handle exceptions. in principle, I can put handlers in wrapper code, but rather not to if there is a way around Thanks

    Read the article

  • Problem carrying Session over to other pages

    - by AAA
    I am able to login a user, but while processing to the next page (memebers area) I can't display any user info let alone print the $_SESSION[email]. I am not sure what's up. Below is the login code and the testing members are page. Login page: session_start(); //also in a real app you would get the id dynamically $sql = "select `email`, `password` from `accounts` where `email` = '$_POST[email]'"; $query = mysql_query($sql) or die ("Error: ".mysql_error()); while ($row = mysql_fetch_array($query)){ $email = $row['email']; $secret = $row['password']; //we will echo these into the proper fields } mysql_free_result($query); // Process the POST variables $email = $_POST["email"]; //Variables $_SESSION["email"] = $_POST["email"]; $secret = $info['password']; //Checks if there is a login cookie if(isset($_COOKIE['ID_my_site'])) //if there is, it logs you in and directes you to the members page { $email = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT email, password FROM accounts WHERE email = '$email'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if (@ $info['password'] != $pass) { } else { header("Location: home.php"); } } } //if the login form is submitted if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['email'] | !$_POST['password']) { die('You did not fill in a required field.'); } // checks it against the database if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT email,password FROM accounts WHERE email = '".$_POST['email']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database. <a href=add.php>Click Here to Register</a>'); } while($info = mysql_fetch_array( $check )) //gives error if the password is wrong if (@ $_POST['password'] != $info['password']) { die('Incorrect password, please try again'); } else { // if login is ok then we add a cookie $_POST['email'] = stripslashes($_POST['email']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['email'], $hour); setcookie(Key_my_site, $_POST['password'], $hour); //then redirect them to the members area header("Location: home.php"); } } } else { // if they are not logged in ?> <?php } ?> home.php session_start(); if(!isset($_SESSION['email'])) { header('Location: login_test3.php'); die('<a href="login_test3.php">Login first!</a>'); } //Variables $_SESSION["email"] = $email; print $_SESSION['name']; UPDATE Just realized the existing code gets in to the home.php file but will not echo anything. But as soon as you hit refresh the session is gone.

    Read the article

  • C++ rvalue temporaries in template

    - by aaa
    hello. Can you please explain me the difference between mechanism of the following: int function(); template<class T> void function2(T&); void main() { function2(function()); // compiler error, instantiated as int & const int& v = function(); function2(v); // okay, instantiated as const int& } is my reasoning correct with respect to instantiation? why is not first instantiated as const T&? Thank you

    Read the article

  • C++, is it possible to obtain the dimension of an array?

    - by aaa
    hi. Suppose I have some pointer, which I want to reinterpret as static dimension array reference: double *p; double (&r)[4] = ?(p); // some construct? // clarify template< size_t N> void function(double (&a)[N]); ... double *p; function(p); // this will not work. // I would like to cast p as to make it appear as double[N] Is it possible to do so? how do I do it?

    Read the article

  • Subtle C++ mistake, can you spot it?

    - by aaa
    I ran into a subtle C++ gotcha, took me while to resolve it. Can you spot it? class synchronized_container { boost::mutex mutex_; std::vector <T> container_; void push_back(const T &value) { boost::scoped_lock(mutex_); // raii mutex lock container_.push_back(value); } ... }; scoped lock is a raii mutex lock, obtains lock on constructor, release lock in destructor. The program will work as expected in serial, but will may occasionally produce weird stuff with more than one thread.

    Read the article

  • Where namespace does operator<< (stream) go to?

    - by aaa
    If I have have some overloaded ostream operators, defined for library local objects, is its okay for them to go to std namespace? If I do not declare them in std namespace, then I must use using ns:: operator <<. As a possible follow-up question, are there any operators which should go to standard or global namespace?

    Read the article

  • How to control div on hover:?

    - by AAA
    I found a way to change the background color of a menu option upon hover. However, when you hover an option, it takes up some wide space that moves all the other options to the right, its sort of annoying, i want to maintain a consistent space, so if i hover, only the color should change, not the option moving to the right. Sort of the way facebook has its menu options. Below is the code: <div id="menu"> <a href="/hello" id="option">home</a> <a href="/hello" id="option">profile</a> <a href="/hello" id="option">account</a> <a href="/hello" id="option">settings</a> <a href="/hello" id="option">extra</a> <a href="/hello" id="option">logout</a> </div> CSS: div#menu { margin-left: 630px; margin-top:-20px; } option { margin-left: 20px; } #option:hover{ background: #3F2327; padding: 10px; }

    Read the article

  • C/C++ opaque pointer library

    - by aaa
    hello Is there library/header already written to manage C++ objects from C using opaque pointers/handles? I can write one myself, but I would rather use already made solution, especially if it has fortran bindings. Thanks

    Read the article

  • C++, strange behavior reusing variable name

    - by aaa
    hello. I have following snippet: { double scale = 3; // not used? { double scale = 4*scale; // what is RHS scale? for (...) { // scale is 0 here, using g++ } } } moreover, g++ reports first scale is not used. how is second scale initialize? What should be correct behavior? thanks

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >