Search Results

Search found 4650 results on 186 pages for 'perfect hash'.

Page 51/186 | < Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >

  • How can I create a custom cleanup mode for git?

    - by Danny
    Git's default cleanup of strip removes all lines starting with a # character. Unfortunately, the Trac engine's wiki formatter uses hashes in the beginning of a code block to denote the syntax type. Additionally any code added verbatim might include hashes as they are a common comment prefix; Perl comes to mind. In the following example the comments all get destroyed by git's cleanup mode. Example: {{{ #!/usr/bin/perl use strict; # say hi to the user. print "hello world\n"; }}} I'd like to use a custom filter that removes all lines beginning with a hash from the bottom of the file upwards. Leaving those lines that being with a hash that are embedded in the commit message I wrote alone. Where or how can I specify this in git? Note, creating a sed or perl script to perform the operation is not a problem, just knowing where to hook it into git is the question.

    Read the article

  • create a dataset by using modulo division method

    - by ayoom
    create a dataset with 101 integers. Use the modulo division method of hashing to store the random data values into hash tables with table sizes of 7, 51, and 151. Use the linear probing and quadratic method of collision resolution. Print out the tables after the data values have been stored. Search for 10 different values in each of the three hash tables, counting the number of comparisons necessary. Print out the number of comparisons necessary in each case, in tabular form.

    Read the article

  • Form action with #hashtag not working in internet explorer

    - by Stephane
    I am using jquery-ui tabs and I've set it up to select the correct tab depending on the #hash from the requested URL. I have a form which performs a search, and each tab present the result from different providers. so if the form is submitting to the action "/myAction#tab1", when the results load, the corresponding tab gets selected. This works perfectly in every browser except for IE. When my form is submitted, it loses somehow the #hash which describes which tab to select. Is that yet another a bug from IE, or am I doing something wrong? I could not find much information about this, but I can hardly believe that this is not a common problem.

    Read the article

  • Ruby on Rails: restrict file type with Paperclip using a flash uploader

    - by aperture
    I have a pretty basic Paperclip Upload model that is attached to a User model through has_many, and am using Uploadify to do the actual uploading. Flash sends all files with the content type of "application/octet-stream" so using validates_attachment_content_type rejects all files. In my create action, I am able to get the mime-type from the original file name, but only after it's been saved, with: def coerce(params) h = Hash.new h[:upload] = Hash.new h[:upload][:attachment].content_type = MIME::Types.type_for(h[:upload][:attachment].original_filename).to_s ... end and def create diff_params = coerce(params) @upload = Upload.new(diff_params[:upload]) ... end What would be the best way of white listing file types? I am thinking a before_validation method, but I'm not sure how that would work. Any ideas would be welcome.

    Read the article

  • Cache an FTP connection via session variables for use via AJAX?

    - by Chad Johnson
    I'm working on a Ruby web Application that uses the Net::FTP library. One part of it allows users to interact with an FTP site via AJAX. When the user does something, and AJAX call is made, and then Ruby reconnects to the FTP server, performs an action, and outputs information. Every time the AJAX call is made, Ruby has to reconnect to the FTP server, and that's slow. Is there a way I could cache this FTP connection? I've tried caching in the session hash, but "We're sorry, but something went wrong" is displayed, and a TCP dump is outputted in my logs whenever I attempt to store it in the session hash. I haven't tried memcache yet. Any suggestions?

    Read the article

  • jQuery Dynamic Page Loading wont work, not sure why any ideas?

    - by Luke
    Live demo here <- http://webcallonline.exoflux.co.uk/html/ $(function() { var url = $(this).attr("href"); $("nav").delegate("a", "click", function(event) { event.preventDefault(); window.location.hash = $(this).attr('href'); $("#main").slideUp('slow', function(){ $("#main").load(url + " #main", function() { $("#main").slideDown('slow'); }); }); }); $(window).bind('hashchange', function(){ newHash = window.location.hash.substring(1); }); $(window).trigger('hashchange'); }); Does anyone have any ideas?

    Read the article

  • Security when writing a PHP webservice?

    - by chustar
    I am writing a web service in PHP for the first time and had ran into some security problems. 1) I am planning to hash passwords using md5() before I write them to the database (or to authenticate the user) but I realize that to do that, I would have to transmit the password in plaintext to the server and hash it there. Because of this I thought of md5()ing it with javascript client side and then rehashing on the server but then if javascript is disabled, then the user can't login, right? 2) I have heard that anything that when the action is readonly, you should use GET but if it modifies the database, you should use POST. Isn't post just as transparent as GET, just not in the address bar?

    Read the article

  • help regarding PERL program

    - by riya
    Could someone write simple PERL programs for the following scenarios: 1) convert a list from {1,2,3,4,5,7,9,10,11,12,34} to {1-5,7,9-12,34} 2) to sort a list of negative numbers 3) to insert values to hash array 4) there is a file with content: C1 c2 c3 c4 r1 r2 r3 r4 put it into an hash array where keys = {c1,c2,c3,c4} and values = {r1,r2,r3,r4} 5) There are testcases running each testcase runs as a process and has a process ID. The logs are logged in a logfile process ID appended to each line. Prog to find out if the test case has passed or failed. The program shoud be running till the processes are running and display output.

    Read the article

  • Webservice for uploading data: security considerations

    - by Philip Daubmeier
    Hi everyone! Im not sure about what authentification method I should use for my webservice. I've searched on SO, and found nothing that helped me. Preliminary Im building an application that uploads data from a local database to a server (running my webservice), where all records are merged and stored in a central database. I am currently binary serializing a DataTable, that holds a small fragment of the local database, where all uninteresting stuff is already filtered out. The byte[] (serialized DataTable), together with the userid and a hash of the users password is then uploaded to the webservice via SOAP. The application together with the webservice already work exactly like intended. The Problem The issue I am thinking about is now: What is if someone just sniffs the network traffic, 'steals' the users id and password hash to send his own SOAP message with modified data that corrupts my database? Options The approaches to solving that problem, I already thought of, are: Using ssl + certificates for establishing the connection: I dont really want to use ssl, I would prefer a simpler solution. After all, every information that is transfered to the webservice can be seen on the website later on. What I want to say is: there is no secret/financial/business-critical information, that has to be hidden. I think ssl would be sort of an overkill for that task. Encrypting the byte[]: I think that would be a performance killer, considering that the goal of the excercise was simply to authenticate the user. Hashing the users password together with the data: I kind of like the idea: Creating a checksum from the data, concatenating that checksum with the password-hash and hashing this whole thing again. That would assure the data was sent from this specific user, and the data wasnt modified. The actual question So, what do you think is the best approach in terms of meeting the following requirements? Rather simple solution (As it doesnt have to be super secure; no secret/business-critical information transfered) Easily implementable retrospectively (Dont want to write it all again :) ) Doesnt impact to much on performance What do you think of my prefered solution, the last one in the list above? Is there any alternative solution I didnt mention, that would fit better? You dont have to answer every question in detail. Just push me in the right direction. I very much appreciate every well-grounded opinion. Thanks in advance!

    Read the article

  • Is there a class like a Dictionary without a Value template? Is HashSet<T> the correct answer?

    - by myotherme
    I have 3 tables: Foos, Bars and FooBarConfirmations I want to have a in-memory list of FooBarConfirmations by their hash: FooID BarID Hash 1 1 1_1 2 1 2_1 1 2 1_2 2 2 2_2 What would be the best Class to use to store this type of structure in-memory, so that I can quickly check to see if a combination exists like so: list.Contains("1_2"); I can do this with Dictionary<string,anything>, but it "feels" wrong. HashSet looks like the right tool for the job, but does it use some form of hashing algorithm in the background to do the lookups efficiently?

    Read the article

  • The C vs. C++ way

    - by amc
    Hi, So I have to write a program that will iterate through an image and record the pixel locations corresponding to each color pixel that appears in it. For example, given http://www.socuteurl.com/fishywishykissy I need to find the coordinates of all yellow, purple, dark pink, etc pixels. In C++ I would use a hash table to do this. I would iterate through the image, check each pixel's value, look up that value and either add to a vector of pixel coordinates if it were found or add a new entry to the table if the value were not already there. The problem is that I may need to write this program in pure C instead of C++. How would I go about doing this in C? I feel like implementing a hash table would be pretty obnoxious and error-prone: should I avoid doing that? I'm pretty inexperienced with C and have a fair amount of C++ experience, if that matters. Thanks.

    Read the article

  • .NET: efficient way to produce a string from a Dictionary<K,V> ?

    - by Cheeso
    Suppose I have a Dictionary<String,String>, and I want to produce a string representation of it. The "stone tools" way of doing it would be: private static string DictionaryToString(Dictionary<String,String> hash) { var list = new List<String> (); foreach (var kvp in hash) { list.Add(kvp.Key + ":" + kvp.Value); } var result = String.Join(", ", list.ToArray()); return result; } Is there an efficient way to do this in C# using existing extension methods? I know about the ConvertAll() and ForEach() methods on List, that can be used to eliminate foreach loops. Is there a similar method I can use on Dictionary to iterate through the items and accomplish what I want?

    Read the article

  • Prevent auto scrolling when clicking tab anchor

    - by JohnCrossy
    On my page I have some tabs that I've added some javascript so when they're clicked the page loads the tab's anchor URL instead of simply changing the view with AJAX, but I now want to stop the browser from auto scrolling to the anchor location. Having done some research, I'm pretty sure I just need to add a couple of lines so that when clicked it returns false or prevents default but, being a noob, I've no idea where to put them!?! I know it's cheeky, but if any answers could include the full script (ie. the below) with the solution, that way I'll understand better and hopefully learn some valuable lessons also :) Here's the code I'm using: jQuery( function() { jQuery('.ui-tabs').bind( 'tabsselect', function( e, ui ) { window.location.hash = ui.tab.hash }); });

    Read the article

  • Cache an FTP connection for use via AJAX?

    - by Chad Johnson
    I'm working on a Ruby web Application that uses the Net::FTP library. One part of it allows users to interact with an FTP site via AJAX. When the user does something, and AJAX call is made, and then Ruby reconnects to the FTP server, performs an action, and outputs information. Every time the AJAX call is made, Ruby has to reconnect to the FTP server, and that's slow. Is there a way I could cache this FTP connection? I've tried caching in the session hash, but "We're sorry, but something went wrong" is displayed, and a TCP dump is outputted in my logs whenever I attempt to store it in the session hash. I haven't tried memcache yet. Any suggestions?

    Read the article

  • Is SHA sufficient for checking file duplication? (sha1_file in PHP)

    - by wag2639
    Suppose you wanted to make a file hosting site for people to upload their files and send a link to their friends to retrieve it later and you want to insure files are duplicated where we store them, is PHP's sha1_file good enough for the task? Is there any reason to not use md5_file instead? For the frontend, it'll be obscured using the original file name store in a database but some additional concerns would be if this would reveal anything about the original poster. Does a file inherit any meta information with it like last modified or who posted it or is this stuff based in the file system? Also, is using a salt frivolous since security in regards of rainbow table attack mean nothing to this and the hash could later be used as a checksum? One last thing, scalability? initially, it's only going to be used for small files a couple of megs big but eventually... Edit 1: The point of the hash is primarily to avoid file duplication, not to create obscurity.

    Read the article

  • Searching and comparing ActiveRecord attributes to find largest value

    - by NS
    I have a model that would look something like: my_diet = Diet.new my_diet.food_type_1 = "beef" my_diet.food_type_1_percentage = 40 my_diet.food_type_2 = "carrots" my_diet.food_type_2_percentage = 50 my_diet.food_type_3 = "beans" my_diet.food_type_3_percentage = 5 my_diet.food_type_4 = "chicken" my_diet.food_type_4_percentage = 5 I need to find which food_type has the highest percentage. So far I've tried creating a hash out of the attibutes and percentages then sorting the hash (see below) but it feels like there must be a cleaner way to do it. food_type_percentages = { :food_type_1 => my_diet.foo_type_percentage_1_percentage.nil? ? 0 : my_dient.food_type_1_percentage, :food_type_2 => my_diet.foo_type_percentage_2_percentage.nil? ? 0 : my_dient.food_type_2_percentage, :food_type_3 => my_diet.foo_type_percentage_3_percentage.nil? ? 0 : my_dient.food_type_3_percentage, :food_type_4 => my_diet.foo_type_percentage_4_percentage.nil? ? 0 : my_dient.food_type_4_percentage } food_type_percentages.sort {|a,b| a[1]<=>b[1]}.last Any ideas? Thanks!

    Read the article

  • Would my situation be an appropriate place to use the ' /i ' REGEX attribute?

    - by Solignis
    I am making a large catalogue of all of the possible OS names that can be supported by my particular version of VMWare. Originally I was writing them all as they stood in the VMX files but then I found a website that had them all listed, the problem is they are not properly cased to provide a "perfect" match, would this be the perfect time to use the regex attribute for case insensitivity? Also as a side question, would it be possibly extract the list of OSs from the website?. They look to be in a HTML formated chart. It would save me a lot of time having to type them all out.

    Read the article

  • Perl/SQLite - How do I select / update a row with the prepare method?

    - by somebody
    I have the following code my $db = DBI->connect( "dbi:SQLite:data.db", "", "", { RaiseError => 1, AutoCommit => 1, PrintError => 0 } ); my $row = $db->selectall_arrayref( "SELECT * FROM something WHERE name=\'$hash->{name}\'"); print Dumper $row; How do I do the same with my $sql = $db->prepare("......"); $sql->execute($hash->{name}); so that it's escaped correctly and I have the selected data in $row?

    Read the article

  • Is it good practice to export variables in Perl?

    - by gvkv
    I'm finding it very convenient to pass configuration and other data that is read or calculated once but then used many times throughout a program by using Perl's use mechanism. I'm doing this by exporting a hash into the caller's namespace. For example: package Myconfiguration; my %config; sub import { my $callpkg = caller(0); my $expsym = $_[1]; configure() unless %config; *{"$callpkg\::$expsym"} = \%config; } and then in other modules: use MyConfiguration (loc_config_sym); if ( $loc_config_sym{paramater} ) { # ... do stuff ... } However, I'm not sure about this as a best practice. Is it better to add a method that returns a hash ref with the data? Something else?

    Read the article

  • .net equivalent for php preg_replace

    - by Hath
    What is the c#.net equivalent for php's preg_replace function? php code is like this: const ALLOW_VALUES = '[^a-z0-9àáâäèéêëìíîïòóôöùûwýÿyÁÂÄÈÉÊËÌÎÏÒÓÔÖÙÛÜWYÝ]'; public function streetTownHash($data, $hashCheck = false, $updateRecord = false) { foreach($data as $key=>$value){ try{ $value = mb_convert_case($value, MB_CASE_LOWER, "UTF-8"); } catch(Exception $e) { echo "Requires extension=php_mbstring.dll enabled ! - $e"; } $valueConcat .= preg_replace('/'.self::ALLOW_VALUES.'/','',$value); # Remove punctuation etc } $streetTownHash = sha1($valueConcat); .... this is as far as i've got but not sure about it.. private SHA1 hash = SHA1.Create(); private string hashAllowed = "[^a-z0-9àáâäèéêëìíîïòóôöùûwýÿyÁÂÄÈÉÊËÌÎÏÒÓÔÖÙÛÜWYÝ]"; public string HashString(string value) { value = // = regex not sure this part var bytes = ASCIIEncoding.UTF8.GetBytes(value); var hashed = hash.ComputeHash(bytes); return ASCIIEncoding.UTF8.GetString(hashed); }

    Read the article

  • What's wrong with this Perl 'grep' syntax?

    - by wes
    I've got a data structure that is a hash that contains an array of hashes. I'd like to reach in there and pull out the first hash that matches a value I'm looking for. I tried this: my $result = shift grep {$_->{name} eq 'foo'} @{$hash_ref->{list}}; But that gives me this error: Type of arg 1 to shift must be array (not grep iterator). I've re-read the perldoc for grep and I think what I'm doing makes sense. grep returns a list, right? Is it in the wrong context? I'll use a temporary variable for now, but I'd like to figure out why this doesn't work.

    Read the article

< Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >