Search Results

Search found 3659 results on 147 pages for 'sorted hash'.

Page 110/147 | < Previous Page | 106 107 108 109 110 111 112 113 114 115 116 117  | Next Page >

  • resizing arrays when close to memory capacity

    - by user548928
    So I am implementing my own hashtable in java, since the built in hashtable has ridiculous memory overhead per entry. I'm making an open-addressed table with a variant of quadratic hashing, which is backed internally by two arrays, one for keys and one for values. I don't have the ability to resize though. The obvious way to do it is to create larger arrays and then hash all of the (key, value) pairs into the new arrays from the old ones. This falls apart though when my old arrays take up over 50% of my current memory, since I can't fit both the old and new arrays in memory at the same time. Is there any way to resize my hashtable in this situation Edit: the info I got for current hashtable memory overheads is from here How much memory does a Hashtable use? Also, for my current application, my values are ints, so rather than store references to Integers, I have an array of ints as my values.

    Read the article

  • SHA-256 encryption wrong result in Android

    - by user642966
    I am trying to encrypt 12345 using 1111 as salt using SHA-256 encoding and the answer I get is: 010def5ed854d162aa19309479f3ca44dc7563232ff072d1c87bd85943d0e930 which is not same as the value returned by this site: http://hash.online-convert.com/sha256-generator Here's the code snippet: public String getHashValue(String entity, String salt){ byte[] hashValue = null; try { MessageDigest digest = MessageDigest.getInstance("SHA-256"); digest.update(entity.getBytes("UTF-8")); digest.update(salt.getBytes("UTF-8")); hashValue = digest.digest(); } catch (NoSuchAlgorithmException e) { Log.i(TAG, "Exception "+e.getMessage()); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return BasicUtil.byteArrayToHexString(hashValue); } I have verified my printing method with a sample from SO and result is fine. Can someone tell me what's wrong here? And just to clarify - when I encrypt same value & salt in iOS code, the returned value is same as the value given by the converting site.

    Read the article

  • How to make GhostScript PS2PDF stop subsetting fonts

    - by gavin-softyolk
    I am using the ps2pdf14 utility that ships with GhostScript, and I am having a problem with fonts. It does not seem to matter what instructions I pass to the command, it insists on subsetting any fonts it finds in the source document. e.g -dPDFSETTINGS#/prepress -dEmbedAllFonts#true -dSubsetFonts#false -dMaxSubsetPct#0 Note that the # is because the command is running on windows, it is the same as =. If anyone has any idea how to tell ps2pdf not to subset fonts, I would be very greatful. Thanks --------------------------Notes ------------------------------------------ The source file is a pdf containing embedded fonts, so it is the fonts already embedded in the source file, that I need to prevent being subset in the destination file. Currently all source file embedded fonts are subset, in some cases this is not apparent from the font name, i.e it contains no hash, and appears at first glance to be the full font, however the widths array has been subset in all cases.

    Read the article

  • Does to_json require parameters? what about within rails?

    - by Harry Wood
    Does to_json require parameters? what about within rails? I started getting the error "wrong number of arguments (0 for 1)" when doing myhash.to_json Unfortunately I'm not sure when this error started happening, but I guess it relates to some versions of either rails or the json gem. I suppose my code (in a rails controller) is using the ActiveSupport::JSON version of to_json, rather than the to_josn method supported by the json gem. ActiveSupport::JSON vs JSON In environment.rb I have RAILS_GEM_VERSION = '2.3.2' and also config.gem "json", :version=> '1.1.7' It's just a simple hash structure containing primitives which I want to convert in my controller, and it was working, but now I can't seem to run to_json without passing parameters.

    Read the article

  • Best solution for language documentation.

    - by Simone Margaritelli
    I'm developing a new object oriented scripting language and the project itself is quite ready for audience now, so i'm starting to think about a serious (not as "drafty" as it is right now) way of document its grammar, functions from standard library and standard library classes. I've looked a bit around and almost every language hash its own web application for the documentation, Python uses Sphinx for instance. Which is the best PHP (don't have the time/will to install mod_who_knows_what on my server) application to accomplish this? I've used mediawiki a bit but i found its tag system a little bit hard to use in this context. Thanks for your answers.

    Read the article

  • How does this Perl grep work to determine the union of several hashes?

    - by titaniumdecoy
    I don't understand the last line of this function from Programming Perl 3e. Here's how you might write a function that does a kind of set intersection by returning a list of keys occurring in all the hashes passed to it: @common = inter( \%foo, \%bar, \%joe ); sub inter { my %seen; for my $href (@_) { while (my $k = each %$href) { $seen{$k}++; } } return grep { $seen{$_} == @_ } keys %seen; } I understand that %seen is a hash which maps each key to the number of times it was encountered in any of the hashes provided to the function.

    Read the article

  • Accessing GMail "View as HTML" content programatically?

    - by Amethi
    I love the "View as HTML" option in GMail when viewing attachments. I would love to be able to use this feature programatically, i.e. check a GMail inbox, read emails, if there are attachments, get the html view and use that content. I'm looking to do this in C Sharp (on a Mac, can't find the hash symbol). Does anyone know if this is possible or if there's another solution to easily get content from a GMail account, regardless of what format it's in? I.E html, pdf, Word doc, etc. The GMail Inbox Feed api isn't good enough and before I start trying to build an IMAP solution that pulls in PDF/Word doc converters, I thought it'd be good to ask here.

    Read the article

  • which virtualization technology is right for me?

    - by Chris
    I need a little help with this getting this sorted out. I want to setup a linux virtual server that I can use to run both sever and desktop systems. I want a linux system that is minimalist in nature as all the main os will be doing is acting as a hypervisor. The system I'm trying to setup will be running a file server, windows 7, ubuntu 10.04, windows xp and a firewall/gateway security system. All the client OS'es accessing and storing files on the file server. Also all network traffic will be routed through the gateway guest os. The file sever will need direct disk access while the other guests can run one disk images. All of this will be running on the same computer so I wont be romoting in to access the guests OS'es. Also if possible I would like to be able to use my triple head setup in the guest OS'es. I've looked at Xen, kvm and virtualbox but I don't know which is the best for me. I'm really debating between kvm and virtual box as kvm seem to support direct hardware access.

    Read the article

  • Migrate Maildir between courier and dovecot servers

    - by DeaconDesperado
    I have several tarballs that make up all the previous emails for two or three accounts on a mail server. This machine we be shut down within a few weeks and so I need to migrate all the previously subscribed IMAP folders to the new server. The old machine ran Dovecot with exim and delivered all mail to a virtual user folder on the server in maildir format. The new machine uses courier and postfix, also configured to deliver through maildir. The new server is already setup and all clients are successfully logging in, the problem is migrating their old conversations. I've tried moving the old message files directly and deleting the imap db that records which messages have already been fetched, but nothing has been successful. The outlook clients present an error for every message saying that the "message can no longer be located on the server." Keeping the files chronologically sorted is not an object, I just need to migrate the old conversations over. Is there a way to do this in a batch operation that will allow the clients to login to the new server and treat these old messages as though they were new? What is the protocol for this kind of migration?

    Read the article

  • How does Hibernate detect dirty state of an entity object?

    - by ???'Lenik
    Is it using some kind of byte codes modification to the original classes? Or, maybe Hibernate get the dirty state by compare the given object with previously persisted version? I'm having a problem with hashCode() and equals() methods for complicated objects. I feel it would be very slow to compute hash code if the object has collection members, and cyclic references are also a problem. If Hibernate won't use hashCode()/equals() to check the dirty state, I guess I should not use equals()/hashCode() for the entity object (not value object), but I'm also afraid if the same operator (==) is not enough. So, the questions are: How does Hibernate know if a property of an object is changed? Do you suggest to override the hashCode()/equals() methods for complicated objects? What if they contains cyclic references? And, also, Would hashCode()/equals() with only the id field be enough?

    Read the article

  • What's the best way to match a query to a set of keywords?

    - by Ryan Detzel
    Pretty much what you would assume Google does. Advertisers come in and big on keywords, lets say "ipod", "ipod nano", "ipod 60GB", "used ipod", etc. Then we have a query, "I want to buy an ipod nano" or "best place to buy used ipods" what kind of algorithms and systems are used to match those queries to the keyword set. I would imagine that some of those keyword sets are huge, 100k keywords made up of one or more actual words. on top of that queries can be 1-n words as well. Any thoughts, links to wikipedia I can start reading? From what I know already I would use some stemmed hash in disk(CDB?) and a bloom filter to check to see if I should even go to disk.

    Read the article

  • does a switch idiom make sense in this case?

    - by the ungoverned
    I'm writing a parser/handler for a network protocol; the protocol is predefined and I am writing an adapter, in python. In the process of decoding the incoming messages, I've been considering using the idiom I've seen suggested elsewhere for "switch" in python: use a hash table whose keys are the field you want to match on (a string in this case) and whose values are callable expressions: self.switchTab = { 'N': self.handleN, 'M': self.handleM, ... } Where self.handleN, etc., are methods on the current class. The actual switch looks like this: self.switchTab[selector]() According to some profiling I've done with cProfile (and Python 2.5.2) this is actually a little bit faster than a chain of if..elif... statements. My question is, do folks think this is a reasonable choice? I can't imagine that re-framing this in terms of objects and polymorphism would be as fast, and I think the code looks reasonably clear to a reader.

    Read the article

  • Killing the mysqld process

    - by Josh K
    I have a table with ~800k rows. I ran an update users set hash = SHA1(CONCAT({about eight fields})) where 1; Now I have a hung Sequel Pro process and I'm not sure about the mysqld process. This is two questions: What harm can possibly come from killing these programs? I'm working on a separate database, so no damage should come to other databases on the system, right? Assume you had to update a table like this. What would be a quicker / more reliable method of updating without writing a separate script. I just checked with phpMyAdmin and it appears as though the query is complete. I still have Sequel Pro using 100% of both my cores though...

    Read the article

  • Whats the best data-structure for storing 2-tuple (a, b) which support adding, deleting tuples and c

    - by bhups
    Hi So here is my problem. I want to store 2-tuple (key, val) and want to perform following operations: - keys are strings and values are Integers - multiple keys can have same value - adding new tuples - updating any key with new value (any new value or updated value is greater than the previous one, like timestamps) - fetching all the keys with values less than or greater than given value - deleting tuples. Hash seems to be the obvious choice for updating the key's value but then lookups via values will be going to take longer (O(n)). The other option is balanced binary search tree with key and value switched. So now lookups via values will be fast (O(lg(n))) but updating a key will take (O(n)). So is there any data-structure which can be used to address these issues? Thanks.

    Read the article

  • How can i pass Twig sub parameter?

    - by aliocee
    hi, Help i cant pass my hash key to twig subroutine. here: foreach my $word (sort { $keywords{$a} <=> $keywords{$b} } keys (%keywords)) { my $t = XML::Twig->new( twig_roots => { 'Id' => \&insert($keywords{$word}) } ); $t->parse($docsums); sub insert { my($t, $id, $k)= @_; my $p = $id->text; my $query = "insert into pres (id, wid, p) values(DEFAULT, '$k', '$p')"; my $sql = $connect->prepare($query); $sql->execute( ); } } Thanks.

    Read the article

  • PHP code cannot see query string param on return in Facebook oAuth flow

    - by TMC
    I am doing some integration with Facebook Open Graph using their oAuth flow and having issues with parsing query string parameters they return. On my callback URL, they pass back an "access_token" parameter with a hash (#). so the callback would be: http://mydomain.com/callback.php#access_token=foobar123 where foobar123 is my access token I'm trying to parse out. However, no matter what I do, my PHP code cannot see if and I've done every debug trick I know (even using phpinfo() to go through everything). The URL is stated only as http://mydomain.com/callback.php. It's as if the rest of the URL isn't really there! This code returns nothing: $token = $_REQUEST['access_token']; Any help would be greatly appreciated... I'm obviously missing something simple.

    Read the article

  • Confusing Perl code

    - by titaniumdecoy
    I don't understand the last line of this function from Programming Perl 3e. Here's how you might write a function that does a kind of set intersection by returning a list of keys occurring in all the hashes passed to it: @common = inter( \%foo, \%bar, \%joe ); sub inter { my %seen; for my $href (@_) { while (my $k = each %$href) { $seen{$k}++; } } return grep { $seen{$_} == @_ } keys %seen; } I understand that %seen is a hash which maps each key to the number of times it was encountered in any of the hashes provided to the function.

    Read the article

  • What's the best way of using a pair (triple, etc) of values as one value in C#?

    - by Yacoder
    That is, I'd like to have a tuple of values. The use case on my mind: Dictionary<Pair<string, int>, object> or Dictionary<Triple<string, int, int>, object> Are there built-in types like Pair or Triple? Or what's the best way of implementing it? Update There are some general-purpose tuples implementations described in the answers, but for tuples used as keys in dictionaries you should additionaly verify correct calculation of the hash code. Some more info on that in another question. Update 2 I guess it is also worth reminding, that when you use some value as a key in dictionary, it should be immutable.

    Read the article

  • call value inside a JS variable as a JS function name

    - by user1640668
    Hello I have a function to perform actions but name of the function is inside a variable... below code will get the URL's hashed part example: #JHON and remove # and store it inside URLHASH variable..example: JHON var urlhash = document.location.hash; urlhash = urlhash.replace(/^.*#/, ''); always there is a function name from that value inside variable and i want to call value inside that variable as a function name window.onload=function() { Value inside URLHASH variable should run as a name of a variable. example: jhon(); }; Is it possible ? I tried some codes but it calls variable name as a function not value inside the variable..help me..

    Read the article

  • Rails application and multilingual content, Model dilemma

    - by dakull
    I'm writing in Rails a website that will be multilingual, for the application translation part i will use the simple I18n gem, for messages and everything related. Yet, all the content must be translated, and we're talking about lots of pages, that will be stored into the database ( like articles, news, etc. ) For now, I'm thinking of two approaches: Lets say i have a Pages table, the content in diff. languages, i will be storing it in a different table called PagesContent that will belong_to Pages and also to a Languages table. The problem here, is that I'll essentially duplicate the no. of tables needed. Pros: flexibility, in the box validation To skip that duplication i can serialize a hash into the content column of Pages, containing the translation. The problem here, is validation, arguably more code to write, and less flexibility when adding a new language. Pros: Less tables. Any other idea ?

    Read the article

  • What is the best way to implement this composite GetHashCode()

    - by Frank Krueger
    I have a simple class: public class TileName { int Zoom, X, Y; public override bool Equals (object obj) { var o = obj as TileName; return (o != null) && (o.Zoom == Zoom) && (o.X == X) && (o.Y == Y); } public override int GetHashCode () { return (Zoom + X + Y).GetHashCode(); } } I was curious if I would get a better distribution of hash codes if I instead did something like: public override int GetHashCode () { return Zoom.GetHashCode() + X.GetHashCode() + Y.GetHashCode(); } This class is going to be used as a Dictionary key, so I do want to make sure there is a decent distribution.

    Read the article

  • how to store passwords in database?

    - by rgksugan
    I use jsp and servlets in my web application. i need to store passwords in the database. I found that hashing will be the best way to do that. I used this code to do it. java.security.MessageDigest d = null; d = java.security.MessageDigest.getInstance("SHA-1"); d.reset(); d.update(pass.getBytes("UTF-8")); byte b[] = d.digest(); String tmp = (new BASE64Encoder()).encode(b); When i tried to print the value of tmp, i get some other value.i guess its the hash value of the password. But when i persist this data to the database the original password gets saved there other than the value in tmp.. What is the problem???

    Read the article

  • Pushing Windows Store apps silently

    - by seagull
    As part of a requirement I have been issued, I seek the ability to push apps from the Windows Store (.appx) to remote users. The framework surrounding the data transmission is sorted; What I need to know is if there is a script that can be sent out along with a URI or the package proper to facilitate installation on the user-side of the Windows Store app. I am well aware that numerous guides exist from Microsoft on pushing out Line-of-Business (LOB) (AKA Enterprise) applications -- that is, apps that have been developed in-house and are not for the consumption of the Windows store. This is inappropriate for my requirement, however; the customer wants their clients to receive apps that appear currently on the Windows Store, and for them to be installed in a silent manner. I've seen this guide; http://blogs.technet.com/b/keithmayer/archive/2013/02/25/step-by-step-deploying-windows-8-apps-with-system-center-2012-service-pack-1.aspx, which details doing exactly this, but it is only applicable to machines that are administered by a system running Windows Server 2012 R2 with the 'System Center 2012' bundle installed. The systems I target are considerably more decentralised than this, making this guide inappropriate. I have a hunch that Microsoft have deliberately designed the Windows Store to be this way, but I figured I ought to ask around before I resign myself to the requirement. Much obliged

    Read the article

  • ActiveRecord Create (not !) Throwing Exception on Validation

    - by myferalprofessor
    So I'm using ActiveRecord model validations to validate a form in a RESTful application. I have a create action that does: @association = Association.new and the receiving end of the form creates a data hash of attributes from the form parameters to save to the database using: @association = user.associations.create(data) I want to simply render the create action if validation fails. The problem is that the .create (not !) method is throwing an exception in cases where the model validation fails. Example: validates_format_of :url, :with => /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix, :message => "Your url doesn't seem valid." in the model produces: ActiveRecord::RecordInvalid Exception: Validation failed: Url Your url doesn't seem valid. I thought .create! is supposed throw an exception whereas .create is not. Am I missing something here? Ruby 1.8.7 patchlevel 173 & rails 2.3.3

    Read the article

  • Separating an Array into a comma seperated string with quotes

    - by user548744
    I'm manually building an SQL query where I'm using an Array in the params hash for an SQL IN statement, like: ("WHERE my_field IN('blue','green','red')"). So I need to take the contents of the array and output them into a string where each element is single quoted and comma seperated (and with no ending comma). So if the array was: my_array = ['blue','green','red'] I'd need a string that looked like: "'blue','green','red'" I'm pretty new to Ruby/Rails but came up with something that worked: if !params[:colors].nil? @categories_array = params[:colors][:categories] @categories_string ="" for x in @categories_array @categories_string += "'" + x + "'," end @categories_string.chop! #remove the last comma end So, I'm good but curious as to what a proper and more consise way of doing this would look like? Thanks

    Read the article

< Previous Page | 106 107 108 109 110 111 112 113 114 115 116 117  | Next Page >