Search Results

Search found 2343 results on 94 pages for 'masterchris 99'.

Page 70/94 | < Previous Page | 66 67 68 69 70 71 72 73 74 75 76 77  | Next Page >

  • Adding items to a generic list (novice)

    - by Crash893
    I'm some what embarrassed to even ask this but I know there is a better way to do this I just don't know how List<int> numbers = new List<int>(22); numbers.Add(3); numbers.Add(4); numbers.Add(9); numbers.Add(14); numbers.Add(15); numbers.Add(19); numbers.Add(28); numbers.Add(37); numbers.Add(47); numbers.Add(50); numbers.Add(54); numbers.Add(56); numbers.Add(59); numbers.Add(61); numbers.Add(70); numbers.Add(73); numbers.Add(78); numbers.Add(81); numbers.Add(92); numbers.Add(95); numbers.Add(97); numbers.Add(99);

    Read the article

  • How can I overlay a watermark on an already resampled image in PHP (using GD) ?

    - by Rick
    Here's my current code: define('IMG_WIDTH', (isset ($_GET['width'])) ? (int) $_GET['width'] : 99); define('IMG_HEIGHT', (isset ($_GET['height'])) ? (int) $_GET['height'] : 75); $image = imagecreatefromjpeg($_GET['image']); $origWidth = imagesx($image); $origHeight = imagesy($image); $croppedThumb = imagecreatetruecolor(IMG_WIDTH, IMG_HEIGHT); if ($origWidth > $origHeight) { $leftOffset = ($origWidth - $origHeight) / 2; imagecopyresampled($croppedThumb, $image, 0, 0, $leftOffset, 0, IMG_WIDTH, IMG_HEIGHT, $origHeight, $origHeight); } else { $topOffset = ($origHeight - $origWidth) / 2; imagecopyresampled($croppedThumb, $image, 0, 0, 0, $topOffset, IMG_WIDTH, IMG_HEIGHT, $origWidth, $origWidth); } It basically takes an image and re-sizes it to create a thumbnail. It works quite nicely. What I would like to do now is add a watermark to the bottom right corner. I've seen the imagecopymerge function used for this... However, that doesn't seem to allow me to supply a resampled image as the source. How can I take my already modified image and add a watermark? :/ I've thought of saving the image to /tmp and then unlink()'ing it once I've added the watermark but that seems like a bit of a mess...

    Read the article

  • Security of Flex for payment website

    - by Mario
    So, it's been about 3 years since I wrote and went live with my company's main internet facing website. Originally written in php, I've since just been making minor changes here and there to progress the site as we've needed to. I've wanted to rewrite it from the ground up in the last year or so and now, we want to add some major features so this is a perfect time. The website in question is as close to a banking website as you'd get (without being a bank; sorry for the obscurity, but the less info I can give out, the better). For the rewrite, I want to separate the presentation layer from the processing layer as much as I can. I want the end user to be stuck in a box and not be able to get out so to speak (this is all because of PCI complacency, being PEN tested every 3 months, etc...) So, being probed every 3 months has increasingly made me nervous. We haven't failed yet and there hasen't been a breach yet, but I want to make sure I continue to pass (as much as I can anyways) So, I'm considering rewriting the presentation layer in Adobe Flex and do all the processing in PHP (effectively IMO, separating presentation from processing) - I would do all my normal form validation in flex (as opposed to javascript or php) and do my reads and writes to the db via php. My questions are: I know Flash has something like 99% market penetration - do people find this to be true? Has anyone seen on their own sites being in flash that someone couldn't access it? Flash in general has come under alot of attacks about security and the like - i know this. I would use a swf encryptor - disable debugging (which i got snagged on once on a different application), continue to use https and any other means i can think of. At the end of the day, everyone knows if someone wants in to the data bad enough, their going to find a ways in; i just wanna make it as difficult for them as i can. Any thoughts are appreciated. -Mario

    Read the article

  • Determining where in the code an error came from - iPhone

    - by Robert Eisinger
    I'm used to Java programming where an error is thrown and it tells you at what line the error was thrown from which file. But with Objective-C in XCode, I can't ever tell where the error comes from. How can I figure out where the error came from? Here is an example of a crash error: 2011-01-04 10:36:31.645 TestGA[69958:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array' *** Call stack at first throw: ( 0 CoreFoundation 0x01121be9 __exceptionPreprocess + 185 1 libobjc.A.dylib 0x012765c2 objc_exception_throw + 47 2 CoreFoundation 0x011176e5 -[__NSArrayM objectAtIndex:] + 261 3 TestGA 0x000548d8 -[S7GraphView drawRect:] + 5763 4 UIKit 0x003e16eb -[UIView(CALayerDelegate) drawLayer:inContext:] + 426 5 QuartzCore 0x00ec89e9 -[CALayer drawInContext:] + 143 6 QuartzCore 0x00ec85ef _ZL16backing_callbackP9CGContextPv + 85 7 QuartzCore 0x00ec7dea CABackingStoreUpdate + 2246 8 QuartzCore 0x00ec7134 -[CALayer _display] + 1085 9 QuartzCore 0x00ec6be4 CALayerDisplayIfNeeded + 231 10 QuartzCore 0x00eb938b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 325 11 QuartzCore 0x00eb90d0 _ZN2CA11Transaction6commitEv + 292 12 QuartzCore 0x00ee97d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99 13 CoreFoundation 0x01102fbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27 14 CoreFoundation 0x010980e7 __CFRunLoopDoObservers + 295 15 CoreFoundation 0x01060bd7 __CFRunLoopRun + 1575 16 CoreFoundation 0x01060240 CFRunLoopRunSpecific + 208 17 CoreFoundation 0x01060161 CFRunLoopRunInMode + 97 18 GraphicsServices 0x01932268 GSEventRunModal + 217 19 GraphicsServices 0x0193232d GSEventRun + 115 20 UIKit 0x003b842e UIApplicationMain + 1160 21 TestGA 0x00001cd8 main + 102 22 TestGA 0x00001c69 start + 53 23 ??? 0x00000001 0x0 + 1 So from looking at this, where is the error coming from and from which class is it coming from?

    Read the article

  • Problem with width in percentage in mozilla

    - by lam3r4370
    I have problem with width in percentage in mozilla. Firefox:http://img155.imageshack.us/i/prolemwidthper.png/ Opera:http://img209.imageshack.us/i/logowpopera.png/ Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta name="author" content="adminite"> <title>Untitled 2</title> <style> #cont { width:99.8%; height:125px; border:1px solid red; background-color:#1ea1de; margin: 0px 0px 0px 0px; }</style> </head> <body> <div id="cont"> </div> </body> </html>

    Read the article

  • "Function object is unsubscriptable" in basic integer to string mapping function

    - by IanWhalen
    I'm trying to write a function to return the word string of any number less than 1000. Everytime I run my code at the interactive prompt it appears to work without issue but when I try to import wordify and run it with a test number higher than 20 it fails as "TypeError: 'function' object is unsubscriptable". Based on the error message, it seems the issue is when it tries to index numString (for example trying to extract the number 4 out of the test case of n = 24) and the compiler thinks numString is a function instead of a string. since the first line of the function is me defining numString as a string of the variable n, I'm not really sure why that is. Any help in getting around this error, or even just help in explaining why I'm seeing it, would be awesome. def wordify(n): # Convert n to a string to parse out ones, tens and hundreds later. numString = str(n) # N less than 20 is hard-coded. if n < 21: return numToWordMap(n) # N between 21 and 99 parses ones and tens then concatenates. elif n < 100: onesNum = numString[-1] ones = numToWordMap(int(onesNum)) tensNum = numString[-2] tens = numToWordMap(int(tensNum)*10) return tens+ones else: # TODO pass def numToWordMap(num): mapping = { 0:"", 1:"one", 2:"two", 3:"three", 4:"four", 5:"five", 6:"six", 7:"seven", 8:"eight", 9:"nine", 10:"ten", 11:"eleven", 12:"twelve", 13:"thirteen", 14:"fourteen", 15:"fifteen", 16:"sixteen", 17:"seventeen", 18:"eighteen", 19:"nineteen", 20:"twenty", 30:"thirty", 40:"fourty", 50:"fifty", 60:"sixty", 70:"seventy", 80:"eighty", 90:"ninety", 100:"onehundred", 200:"twohundred", 300:"threehundred", 400:"fourhundred", 500:"fivehundred", 600:"sixhundred", 700:"sevenhundred", 800:"eighthundred", 900:"ninehundred", } return mapping[num] if __name__ == '__main__': pass

    Read the article

  • MySQL running on an EC2 m1.small instance has high load but low memory usage, possible resolutions?

    - by Tosh
    I have a MySQL server 5.0.75 Ubuntu, on an m1.small instance running on Amazon's EC2 as part of an application. During peak usage the server load will rise very high, while the memory usage stays low and the application server is no longer responsive since it's waiting for query results. The application server has only 5-8 apache processes running (mod_perl processes). The data directory uses only 140MB of data so the MyIsam tables aren't very big. The queries are pretty complicated with some big joins being performed, and the application makes a lot of queries. mysqltuner reports everything OK except "Maximum possible memory usage: 1.7G (99% of installed RAM)" but I'm nowhere close to using that. My question is, where should I be looking to fix this? Is this something that can be tuned away, or do I just need a larger instance/server? Googling indicates either or also upgrading MySQL server. Any pointers in the right direction would be greatly appreciated, thanks! EDIT: I just discovered this in my slow queries log: # Time: 101116 11:17:00 # User@Host: user[pass] @ [host] # Query_time: 4063 Lock_time: 1035 Rows_sent: 0 Rows_examined: 19960174 SELECT * FROM contacts WHERE contacts.contact_id IN (SELECT external_id FROM contact_relations WHERE external_table = 'contacts' AND contact_id IN (SELECT contact_id FROM contacts WHERE (company_name like '%%butan%%%' OR country like '%%butan%%%' OR city like '%%butan%%%' OR email1 like '%%butan%%%') AND (company_name is not null and company_name != ''))); Which actually brings up a different but related question: If I have a contact table containing: John Smith,The Fun Factory,555-1212,[email protected] What's the best way to search for that record using "factory" as a search key? Fulltext rarely seems to find items in the middle of a word, for example "actor" should bring up "Factory"

    Read the article

  • CodeModel help needed for right-hand singleton.getinstance() assignment.

    - by antarti
    I've been able to generate 99% of what I need with the CodeModel API, but I am stumped here... Using the various "directXX" methods does not add import statements to the generated code, and I can work without the "directXXX" type of methods except for one place in a generated class. Suppose I desire a generated method like: /** * Copies data from this Value-Obj instance, to the returned PERSON instance. * * @return PERSON * */ public PERSON mapVOToPERSON() throws MappingException { Mapper mapper = (com.blah.util.MapperSingleton.getMapperInstance()); return mapper.map(this, PERSON.class); } You can see the right hand of the Mapper assignment in parens. Emitting the entire package+class was the only way I could find to just declare "SomeSingleton.someMethod()" on the right hand side and have the generated code compile. Without the MapperSingleton being added to the object model, there is no import generated... Questions: 1) Is there a way to force an import to be generated? 2) How to declare an expression that gives me the right side of the Mapper assignment within the object model (so that an import of MapperSingleton gets generated. Any help appreciated...

    Read the article

  • How to debug JBoss out of memory problem?

    - by user561733
    Hello, I am trying to debug a JBoss out of memory problem. When JBoss starts up and runs for a while, it seems to use memory as intended by the startup configuration. However, it seems that when some unknown user action is taken (or the log file grows to a certain size) using the sole web application JBoss is serving up, memory increases dramatically and JBoss freezes. When JBoss freezes, it is difficult to kill the process or do anything because of low memory. When the process is finally killed via a -9 argument and the server is restarted, the log file is very small and only contains outputs from the startup of the newly started process and not any information on why the memory increased so much. This is why it is so hard to debug: server.log does not have information from the killed process. The log is set to grow to 2 GB and the log file for the new process is only about 300 Kb though it grows properly during normal memory circumstances. This is information on the JBoss configuration: JBoss (MX MicroKernel) 4.0.3 JDK 1.6.0 update 22 PermSize=512m MaxPermSize=512m Xms=1024m Xmx=6144m This is basic info on the system: Operating system: CentOS Linux 5.5 Kernel and CPU: Linux 2.6.18-194.26.1.el5 on x86_64 Processor information: Intel(R) Xeon(R) CPU E5420 @ 2.50GHz, 8 cores This is good example information on the system during normal pre-freeze conditions a few minutes after the jboss service startup: Running processes: 183 CPU load averages: 0.16 (1 min) 0.06 (5 mins) 0.09 (15 mins) CPU usage: 0% user, 0% kernel, 1% IO, 99% idle Real memory: 17.38 GB total, 2.46 GB used Virtual memory: 19.59 GB total, 0 bytes used Local disk space: 113.37 GB total, 11.89 GB used When JBoss freezes, system information looks like this: Running processes: 225 CPU load averages: 4.66 (1 min) 1.84 (5 mins) 0.93 (15 mins) CPU usage: 0% user, 12% kernel, 73% IO, 15% idle Real memory: 17.38 GB total, 17.18 GB used Virtual memory: 19.59 GB total, 706.29 MB used Local disk space: 113.37 GB total, 11.89 GB used

    Read the article

  • CSS/JQUERY make div scrollable without showing scrollbar

    - by Ispuk
    is there any way to make a div scrollable with overflow-y:hidden; and overflow-x:hidden? i'm trying without success, maybe i need some js or jquery script? i mean, i would like to make div scroll on y axes without showing scrollbar on right side( as it is now). itryed: .get-list{ position:absolute; z-index:444; text-align: center; display: none; bottom:0; clear:both !important; left:0; right:0; top:11%; margin:0 auto; background:#fff; max-height:800px; overflow-y:no-display; overflow-x:hidden; display: block; } thanks EDIT log-widget-list{ position:absolute; z-index:444; text-align: center; display: none; width:99%; margin:0 auto; background:#fff; height:800px; overflow: hidden; } .log-widget-list .scroller{ overflow: scroll; height:800px; width:100%; } it shows right scrollbar anyway

    Read the article

  • Datastructure choices for highspeed and memory efficient detection of duplicate of strings

    - by Jonathan Holland
    I have a interesting problem that could be solved in a number of ways: I have a function that takes in a string. If this function has never seen this string before, it needs to perform some processing. If the function has seen the string before, it needs to skip processing. After a specified amount of time, the function should accept duplicate strings. This function may be called thousands of time per second, and the string data may be very large. This is a highly abstracted explanation of the real application, just trying to get down to the core concept for the purpose of the question. The function will need to store state in order to detect duplicates. It also will need to store an associated timestamp in order to expire duplicates. It does NOT need to store the strings, a unique hash of the string would be fine, providing there is no false positives due to collisions (Use a perfect hash?), and the hash function was performant enough. The naive implementation would be simply (in C#): Dictionary<String,DateTime> though in the interest of lowering memory footprint and potentially increasing performance I'm evaluating a custom data structures to handle this instead of a basic hashtable. So, given these constraints, what would you use? EDIT, some additional information that might change proposed implementations: 99% of the strings will not be duplicates. Almost all of the duplicates will arrive back to back, or nearly sequentially. In the real world, the function will be called from multiple worker threads, so state management will need to be synchronized.

    Read the article

  • What's a good way to write batch scripts in C#?

    - by Scott Bilas
    I would like to write simple scripts in C#. Stuff I would normally use .bat or 4NT .btm files for. Copying files, parsing text, asking user input, and so on. Fairly simple but doing this stuff right in a batch file is really hard (no exceptions for example). I'm familiar with command line "scripting" wrappers like AxScript so that gets me part of the way there. What I'm missing is the easy file-manipulation framework. I want to be able to do cd(".."), copy(srcFile, destFile) type functionality. Tools I have tried: NANT, which we use in our build process. Not a good scripting tool. Insanely verbose XML syntax and to add a simple function you must write an extension assembly. Can't do it inline. PowerShell. Looks great, but I just haven't been able to switch over to this as my primary shell. Too many differences from 4NT. Whatever I do needs to run from an ordinary command prompt and not require a special shell to run it through. Can PowerShell be used as a script executor? Perl/Python/Ruby. Really hate learning an entirely new language and framework just to do batch file operations. Haven't been able to dedicate the time I need to do this. Plus, we're a 99% .NET shop for our toolchain and I really want to leverage our existing experience and codebase. Are there frameworks out there that are trying to solve this problem of "make a batch file in C#" that you have used? I want the power of C#/.NET with the immediate-mode type functionality of a typical cmd.exe shell language. Am I alone in wanting something like this?

    Read the article

  • Custom progress bar label text via binding

    - by Alexander K
    I was playing with progress bar customization in Silverlight application. What I want to reach is to have progress bar label to show current its state in the following format: "Value / Maximum". So, user will see what is the current value, and what is the maximum possible value. Here is a style for progress bar I use: <Style x:Key="ProgressBarStyle" TargetType="ProgressBar"> <Setter Property="Width" Value="97.21" /> <Setter Property="Height" Value="19" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ProgressBar"> <Canvas x:Name="LevelField" Width="99" Height="21"> ... <TextBlock ... DataContext="{TemplateBinding Value}" Text="{Binding Converter={StaticResource DecNumberToStringConverter}}"/> </Canvas> </ControlTemplate> </Setter.Value> </Setter> </Style> The way I want to implement this, is to have a value converter, that will convert current value and maximum possible into the proper string. It does work properly, if it is written like above. However, I also need to provide ConverterParameter for Convertor, but not sure how to make it. When I write like this: , ConvertParameter={Binding Maximum}, it shows error on start, that Text attribute is not found in TextBlock. I was also trying to set DataContext as {RelativeSource Self}, but then it didn't displays error that DataContext attribute is not found. How to make the described progress bar label properly?

    Read the article

  • Better way to compare neighboring cells in matrix

    - by HyperCube
    Suppose I have a matrix of size 100x100 and I would like to compare each pixel to its direct neighbor (left, upper, right, lower) and then do some operations on the current matrix or a new one of the same size. A sample code in Python/Numpy could look like the following: (the comparison 0.5 has no meaning, I just want to give a working example for some operation while comparing the neighbors) import numpy as np my_matrix = np.random.rand(100,100) new_matrix = np.array((100,100)) my_range = np.arange(1,99) for i in my_range: for j in my_range: if my_matrix[i,j+1] > 0.5: new_matrix[i,j+1] = 1 if my_matrix[i,j-1] > 0.5: new_matrix[i,j-1] = 1 if my_matrix[i+1,j] > 0.5: new_matrix[i+1,j] = 1 if my_matrix[i-1,j] > 0.5: new_matrix[i-1,j] = 1 if my_matrix[i+1,j+1] > 0.5: new_matrix[i+1,j+1] = 1 if my_matrix[i+1,j-1] > 0.5: new_matrix[i+1,j-1] = 1 if my_matrix[i-1,j+1] > 0.5: new_matrix[i-1,j+1] = 1 This can get really nasty if I want to step into one neighboring cell and start from it to do a similar task... Do you have some suggestions how this can be done in a more efficient manner? Is this even possible?

    Read the article

  • Convert SVG image with filters to PNG /PDF

    - by user1599669
    I have the following svg image to the png image & pdf image with 300 DPI. <svg width="640" height="480" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <!-- Created with SVG-edit - http://svg-edit.googlecode.com/ --> <defs> <filter height="200%" width="200%" y="-50%" x="-50%" id="svg_1_blur"> <feGaussianBlur stdDeviation="10" in="SourceGraphic"/> </filter> </defs> <g> <title>Layer 1</title> <image filter="url(#svg_1_blur)" xlink:href="images/logo.png" id="svg_1" height="162.999996" width="223.999992" y="99" x="185"/> <text xml:space="preserve" text-anchor="middle" font-family="serif" font-size="24" id="svg_2" y="210" x="289" stroke-width="0" stroke="#000000" fill="#000000">sdfdsdsfsdf</text> </g> </svg> I want to do this using PHP and I have applied filters to the blur filter to the image and I want to retain that. Also I have problem in viewing this image in the IE, because it doesn't show the blur effect on IE9. Any suggestions?

    Read the article

  • Using jQuery with form to eliminate spam

    - by Thierry-Dimitri Roy
    I have put a form on a web page where the user can send us data. Unfortunately, the webmaster does get a lot of spam through this form and the valid submissions gets buried. I have used captcha to bypass this problem. But I think that everyone would agree that captcha is a big annoyance to users. I switched to another solution: now the URL of the submit form points to null: <form id="sendDataForm" action="/null" method="post"> ... </form> And I bypass the form submission using jQuery excellent form plugin: $('#sendDataForm').ajaxForm({ url: '/ajax-data/' }); Since then, no spam has reached the webmaster, and valid comments gets through. The only drawbacks is that users without javascript cannot send us the form. But since this is on top of a javascript web application, we can safely assume that these are not valid users. My question is: in a world where 99% of users has javascript enabled (and a mechanism for those user could be build that uses captcha), why is this solution not more used? What drawback am I not seeing?

    Read the article

  • Basic C# problem

    - by Juan
    Determine if all the digits of the sum of n -numbers and swapped n are odd. For example: 36 + 63 = 99, y 409 + 904 = 1313. Visual Studio builds my code, there is still something wrong with it ( it doesnt return an answer) can you please help me here? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { long num = Convert.ToInt64(Console.Read()); long vol = voltea(num); long sum = num + vol; bool simp = simpares(sum); if (simp == true) Console.Write("Si"); else Console.Write("No"); } static private bool simpares(long x) { bool s = false; long [] arreglo = new long [1000]; while ( x > 0) { arreglo [x % 10] ++; x /=10; } for (long i=0 ; i <= arreglo.Length ; i++) { if (arreglo [i]%2 != 0) s = true; } return s; } static private long voltea(long x) { long v = 0; while (v > 0) { v = 10 * v + x % 10; x /= 10; } return v; } } }

    Read the article

  • How do I force MyEclipse to hot-deploy a JavaScript file to my JBoss instance?

    - by Mike Cialowicz
    I'm having trouble with MyEclipse 7.1.1 hot-deployment of files to my JBoss 4 server. The problem is this: while my server is running, I can make changes to various JAVA and HTML files, which are then hot-deployed immediately (I can see the changes reflected in my browser when I refresh the page). However, while working on a particular JavaScript file, my changes are not being hot-deployed. This makes it very difficult to work on and debug this file, since I have to stop my server, redeploy, and start it again each time I make changes. This is a new problem - it didn't used to happen with this file, so I think something got screwed up in my MyEclipse configuration. I've verified that my projects (JBoss 4 instances) are all set up in "Exploded" mode for hot-deployment. I'm also 99% sure that this isn't an issue with my browser, since I always refresh with CTRL+F5, and I've tried a number of things like clearing my browser cache to get the currently deployed version of the file. I've also tried doing a "clean" on the project while the server is running, and that didn't force a deployment either. Any sort of solution would be helpful. I'd love for MyEclipse to deploy the file automatically, but I'm also open to manually forcing hot-deployment of this particular file while I work on it. Thank you.

    Read the article

  • Project management software, available options

    - by canni
    Hey, sorry for posting this here, I know that this question better suites into SuperUser, but I would like to know answers from developers point of view. I have been using Indefero for project management etc. for some time, but I found that Indefero limitations are too big for my team. I'm searching project-management software that best suites this needs: Open-Source, but I can consider commercial apps GIT integration is mandatory, best if it can support multiple repos per project Time-tracking, good if it can have Gannt chart connected with issues etc. Issue, milestone, task tracking Good if it can be integrated with Gitosis, or have similar repository access control It must have an option, to setup on our own server Markdown syntax support is mandatory (or easy way to install plugin for this etc.) Issue tagging will be and advantage It will be used by developers team by 99% of time, but it has to have some simple interface, that clients can fill up bug reports etc. per project. It does not have to fill all this needs, but good if it can :) What options do You know, and can recommend?

    Read the article

  • Why is my rspec test failing?

    - by Justin Meltzer
    Here's the test: describe "admin attribute" do before(:each) do @user = User.create!(@attr) end it "should respond to admin" do @user.should respond_to(:admin) end it "should not be an admin by default" do @user.should_not be_admin end it "should be convertible to an admin" do @user.toggle!(:admin) @user.should be_admin end end Here's the error: 1) User password encryption admin attribute should respond to admin Failure/Error: @user = User.create!(@attr) ActiveRecord::RecordInvalid: Validation failed: Email has already been taken # ./spec/models/user_spec.rb:128 I'm thinking the error might be somewhere in my data populator code: require 'faker' namespace :db do desc "Fill database with sample data" task :populate => :environment do Rake::Task['db:reset'].invoke admin = User.create!(:name => "Example User", :email => "[email protected]", :password => "foobar", :password_confirmation => "foobar") admin.toggle!(:admin) 99.times do |n| name = Faker::Name.name email = "example-#{n+1}@railstutorial.org" password = "password" User.create!(:name => name, :email => email, :password => password, :password_confirmation => password) end end end Please let me know if I should reproduce any more of my code. UPDATE: Here's where @attr is defined, at the top of the user_spec.rb file: require 'spec_helper' describe User do before(:each) do @attr = { :name => "Example User", :email => "[email protected]", :password => "foobar", :password_confirmation => "foobar" } end

    Read the article

  • Cannot bulk load. The file "c:\data.txt" does not exist.

    - by Daniel Brink
    Hi, I'm having a problem reading data from a text file into ms sql. I created a text file in my c:\ called data.txt, but for some reason ms sql server cannot find the file. I get the error "Cannot bulk load. The file "c:\data.txt" does not exist." Any ideas? The data file (yes I know the data looks crappy, but in the real world thats how it comes from clients): 01-04 10.338,18 0,00 597.877,06- 5 0,7500 62,278- 06-04 91.773,00 9.949,83 679.700,23- 1 0,7500 14,160- 07-04 60.648,40 149.239,36 591.109,27- 1 0,7500 12,314- 08-04 220.173,70 213.804,37 597.478,60- 1 0,7500 12,447- 09-04 986.071,39 0,00 1.583.549,99- 3 0,7500 98,971- 12-04 836.049,00 1.325.234,79 1.094.364,20- 1 0,7500 22,799- 13-04 38.000,00 503.010,49 629.353,71- 1 0,7500 13,111- 14-04 286.400,00 840.126,50 75.627,21- 1 0,7500 1,575- The Sql: CREATE TABLE #temp ( vchCol1 VARCHAR (50), vchCol2 VARCHAR (50), vchCol3 VARCHAR (50), vchCol4 VARCHAR (50), vchCol5 VARCHAR (50), vchCol6 VARCHAR (50), vchCol7 VARCHAR (50) ) BULK insert #temp FROM 'c:\data.txt' WITH ( FIELDTERMINATOR = ' ', ROWTERMINATOR = '\n' ) select * from #temp drop table #temp

    Read the article

  • bidirectional buble sort

    - by davit-datuashvili
    Here is the code I'm using for shacker sort (or bidirectional buble sort). Something is wrong; the error is java.lang.ArrayIndexOutOfBoundsException. Can anybody help me? public class bidirectional{ public static void main(String[]args){ int x[]=new int[]{12,9,4,99,120,1,3,10}; int j; int n=x.length; int st=-1; while (st<n){ st++; n--; for (j=st;j<n;j++) { if (x[j]>x[j+1]) { int t=x[j]; x[j]=x[j+1]; x[j+1]=t; } } for (j=n;--j>=st;) { if (x[j]>x[j+1]) { int t=x[j]; x[j]=x[j+1]; x[j+1]=t; } } } for (int k=0;k<x.length;k++) { System.out.println(x[k]); } } }

    Read the article

  • extra storage merge sort

    - by davit-datuashvili
    I need make a merge sort using an additional array. Here is my code: public class extra_storage{ public static void main(String[]args) { int x[]=new int[]{12,9,4,99,120,1,3,10}; int a[]=new int[x.length]; mergesort(x,0,x.length-1,a); for (int i=0;i<x.length;i++){ System.out.println(x[i]); } } public static void mergesort(int x[],int low,int high, int a[]){ if (low>=high) { return; } int middle=(low+high)/2; mergesort(x,low,middle,a); mergesort(x,middle+1,high,a); int k; int lo=low; int h=high; for (k=low;k<high;k++) if ((lo<=middle ) && ((h>high)||(x[lo]<x[h]))){ a[k]=x[lo++]; } else { a[k]=x[h++]; } for (k=low;k<=high;k++){ x[k]=a[k]; } } } But something is wrong. When I run it the output is this: 1 0 3 0 4 0 9 0 What is the problem?

    Read the article

  • Interpretation of range(n) and boolean list, one-to-one map, simpler?

    - by HH
    #!/usr/bin/python # # Description: bitwise factorization and then trying to find # an elegant way to print numbers # Source: http://forums.xkcd.com/viewtopic.php?f=11&t=61300#p2195422 # bug with large numbers such as 99, but main point in simplifying it # def primes(n): # all even numbers greater than 2 are not prime. s = [False]*2 + [True]*2 + [False,True]*((n-4)//2) + [False]*(n%2) i = 3; while i*i < n: # get rid of ** and skip even numbers. s[i*i : n : i*2] = [False]*(1+(n-i*i)//(i*2)) i += 2 # skip non-primes while not s[i]: i += 2 return s # TRIAL: can you find a simpler way to print them? # feeling the overuse of assignments but cannot see a way to get it simpler # p = 49 boolPrimes = primes(p) numbs = range(len(boolPrimes)) mydict = dict(zip(numbs, boolPrimes)) print([numb for numb in numbs if mydict[numb]]) Something I am looking for, can you get TRIAL to be of the extreme simplicity below? Any such method? a=[True, False, True] b=[1,2,3] b_a # any such simple way to get it evaluated to [1,3] # above a crude way to do it in TRIAL

    Read the article

  • How to correctly pass a float from C# to C++ (dll)

    - by RavelT
    I'm getting huge differences when I pass a float from C# to C++. I'm passing a dynamic float wich changes over time. With a debuger I get this: c++ lonVel -0.036019072 float c# lonVel -0.029392920 float I did set my MSVC++2010 floating point model to /fp:fast wich should be the standard in .NET if I'm not mistaken, but this didnt help. Now I cant give out the code but I can show a fraction of it. From C# side it looks like this: namespace Example { public class Wheel { public bool loging = true; #region Members public IntPtr nativeWheelObject; #endregion Members public Wheel() { this.nativeWheelObject = Sim.Dll_Wheel_Add(); return; } #region Wrapper methods public void SetVelocity(float lonRoadVelocity,float latRoadVelocity){Sim.Dll_Wheel_SetVelocity(this.nativeWheelObject,lonRoadVelocity,latRoadVelocity);} #endregion Wrapper methods } internal class Sim { #region PInvokes [DllImport(pluginName, CallingConvention=CallingConvention.Cdecl)] public static extern void Dll_Wheel_SetVelocity(IntPtr wheel,float lonRoadVelocity,float latRoadVelocity); #endregion PInvokes } } And in C++ side @ exportFunctions.cpp: EXPORT_API void Dll_Wheel_SetVelocity(CarWheel* wheel,float lonRoadVelocity,float latRoadVelocity){ wheel->SetVelocity(lonRoadVelocity,latRoadVelocity);} So any sugestions on what I should do in order to get 1:1 results or atleast 99% correct results.

    Read the article

< Previous Page | 66 67 68 69 70 71 72 73 74 75 76 77  | Next Page >