Search Results

Search found 4955 results on 199 pages for 'range'.

Page 128/199 | < Previous Page | 124 125 126 127 128 129 130 131 132 133 134 135  | Next Page >

  • Caesar Cipher in Java (Spanish Characters)

    - by Rodolfo
    I've reading this question, and I was wondering if Is there any way to consider the whole range of characters? For example, "á", "é", "ö", "ñ", and not consider " " (the [Space])? (For example, my String is "Hello World", and the standard result is "Khoor#Zruog"; I want to erase that "#", so the result would be "KhoorZruog") I'm sure my answer is in this piece of code: if (c >= 32 && c <= 127) { // Change base to make life easier, and use an // int explicitly to avoid worrying... cast later int x = c - 32; x = (x + shift) % 96; chars[i] = (char) (x + 32); } But I've tried some things, and it didn't work.

    Read the article

  • Best method to compress JSON string in term of performance and compress radio

    - by Eric Yin
    For a JSON string, contains all kinds of settings, numbers, string etc. Total JSON string fairly fall into 10k~50K range. I want to compress it before save to database. So I wonder which compress method should I choose, I am using c# 4, I know I can choose gzip and deflate but the compression radio is not good (although speed is good). More specific, compress can be a little slow (since only once) but should be small. Decompress should be lighting fast since decompress happens lots. Please give some advice.

    Read the article

  • How to evaluate a custom math expression in Python

    - by taynaron
    I'm writing a custom dice rolling parser (snicker if you must) in python. Basically, I want to use standard math evaluation but add the 'd' operator: #xdy sum = 0 for each in range(x): sum += randInt(1, y) return sum So that, for example, 1d6+2d6+2d6-72+4d100 = (5)+(1+1)+(6+2)-72+(5+39+38+59) = 84 I was using regex to replace all 'd's with the sum and then using eval, but my regex fell apart when dealing with parentheses on either side. Is there a faster way to go about this than implementing my own recursive parsing? Perhaps adding an operator to eval?

    Read the article

  • Artificial Intelligence in online game using Google App Engine

    - by Hortinstein
    I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI. I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another server I am stuck on how to do it. I have looked at the Task Queue feature, but due to long running processes not being an option on the App engine, I am a little stuck. I intend to run multiple server instances with 200+ persistant NPC entities that I will need to update. Most action is slowly roaming around based on player movements/concentrations, and attacking close range players...(you can probably guess the type of game im developing)

    Read the article

  • Increasing speed of webservice - howto

    - by Koran
    Hi, Our client-server product has the protocol between them as XML over HTTP. Here, the client asks a GET/POST query to the web server and the server responds with XML. The server is written using django. The server has to be on the web because there are many clients across the world using this. The server code uses extensive memoization and also there is very less db queries - most queries dont have any db queries, some of them has max 1. The biggest problem is the speed. Every query takes close to 5 seconds for the reply. The data replied is also very less - in the range of 4-6 Kb. What are the mechanisms to improve speed of the web service? Is this the usual way of writing a client-server? Are there other technologies and are we missing out on it? Thank you K

    Read the article

  • Version control for Adobe Flash projects

    - by Guss
    I'm working with a very complex Flash project which is part of a full range of services that we deploy for the use of our clients. For most of our software sources (Java, PHP, Javascript, HTML and a some supporting scripts in other languages) we use subversion for version control and management, so we do the same for our Flash projects, even though we gain little benefits from version controlling that (except being able revert to previous versions) as FLA files are stored as just binaries which we cannot get meaningful diffs from. We're putting as much code as we can into AS files which we can properly manage using subversion, but due to the requirements of our architecture and our deployment strategy (both we cannot change because of our clients needs), we still maintain a large collection of FLA files that we need to manage. I've looked at Adobe Version Cue and while I do not really understand what it does in terms of version control, will moving our Flash projects to hosting on Version Cue will give me better control then I currently get from Subversion? Also - if people can share their experience and suggestions regarding version control of Flash projects, it will be very helpful.

    Read the article

  • Does DataType DataAnnotation Check the Expression?

    - by Jason
    I am currently using DataAnnotations within my ASP.NET MVC website to ensure data is properly validated. One question I wanted to verify (I think I know the answer, but I can't find verification online) - does the DataType DataAnnotation perform regular expression checks to ensure that you have received a valid e-mail/phone/currency/etc? [Required(ErrorMessage = "Price required")] [DataType(DataType.Currency, ErrorMessage = "Not a valid price")] [Range(0, double.MaxValue, ErrorMessage = "Price must be greater than 0.")] public decimal Price { get; set; } I believe the answer is no (meaning I have to provide my own, custom, RegularExpressionAttribute), but I wanted to double check before I do that for various field types.

    Read the article

  • Bind any version of MySql.Data using the app.config

    - by Martin Kirsche
    How do I bind any version or a range of versions of an assembly by using the app.config? I'm currently binding the MySql.Data assembly like this: <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" applies-to="v2.0.50727"> <qualifyAssembly partialName="MySql.Data" fullName="MySql.Data, Version=6.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL"/> </assemblyBinding> </runtime> Any version of MySql.Data other than 6.2.2.0 is not working this way. The versions of this assembly are changing fast so I either want to bind any or all versions beginning with 6.2 to my application without changing the app.config each time.

    Read the article

  • PHP: Filling in the 'gaps' in an array

    - by aboved
    Hey gurus, I've got a php array (obtained through checkbox values in a form - as you know checkboxes only show up in the _POST variable when they are not set). Array ( [2] => 0,2 [3] => 0,3 ) I need a way to 'fill in' the gaps between the range 0-5. So above would look like (filling the empty spaces with '-1'. I tried array_merge() with an array filled with '-1' but that didn't work. Array ( [0] => -1 [2] => 0,2 [3] => 0,3 [4] => -1 [5] => -1 ) I think I may have gone down the wrong road with the problem I am trying to solve, but I have put too much time into this solution to back out - a feeling I am sure most of you are familiar with(!) Cheers!

    Read the article

  • Create a color generator in matplotlib

    - by Brendan
    I have a series of lines that each need to be plotted with a separate colour. Each line is actually made up of several data sets (positive, negative regions etc.) and so I'd like to be able to create a generator that will feed one colour at a time across a spectrum, for example the gist_rainbow map shown here. I have found the following works but it seems very complicated and more importantly difficult to remember, from pylab import * NUM_COLORS = 22 mp = cm.datad['gist_rainbow'] get_color = matplotlib.colors.LinearSegmentedColormap.from_list(mp, colors=['r', 'b'], N=NUM_COLORS) ... # Then in a for loop this_color = get_color(float(i)/NUM_COLORS) Moreover, it does not cover the range of colours in the gist_rainbow map, I have to redefine a map. Maybe a generator is not the best way to do this, if so what is the accepted way?

    Read the article

  • Ontology - Conflict of same individuals property and datatype property

    - by blueomega
    I am having a problem with "same individuals property" in protege, when i run a reasoner (pellet 1.5 or fact++) Lets take ontology example thing has class sons A and B, A has sons C and D. B, C and D have individuals of the same class. Cant i say a individual C is "same individual" as individual B, and then add also individual D is "same individual" as individual B. Wich is true, they have diferent names, but they are same individual.. Why does it only work when i set individual B has "same individual" of type C or D? The protege error is "InconsistentOntologyException:Fact++.Kernel: inconsistent Ontology" and pellet says ontology is inconsistent. EDIT: Seems its a more deep rooted problem, this example works :(, gonna keep checking. EDIT2: After some more experimenting, seems its a conflict with DataType properties. They all share a DataType properties with same name. In the example domain of property would be A and range string. Any idea how to solve?

    Read the article

  • How can I make Excel's MIN function ignore zeroes in a set?

    - by mfg
    In Excel, I have the following formula =(MIN(H69,H52,H35,H18)*(1/H18))*10 that is supposed to return the MIN of a range, and divide it by the current cell (*(1/H18) ), then multiply by 10. I am having difficulty with adding a type of NULLIF statement. I want to be able to have (the possibility for) blank rows, and have the MIN function ignore zero/blank fields while selecting the next lowest value (all are between 1.0-0.1). Is there a modifier i can apply to the MIN function to make it not compare zeroes in the MIN set? Is there a better funtion than MIN to use? This is to prevent the following situation: users will need to eliminate fields that are zeros from the form, theres 2 formula edits per entry, averaging 4 entries per use, so 8 possible errors per form use...

    Read the article

  • Why doesn't negative values for the second index in a jagged array work in Python?

    - by univerio
    For example, if I have the following (data from Project Euler): s = [[75], [95, 64], [17, 47, 82], [18, 35, 87, 10], [20, 4, 82, 47, 65], [19, 1, 23, 75, 3, 34], [88, 2, 77, 73, 7, 63, 67], [99, 65, 4, 28, 6, 16, 70, 92], [41, 41, 26, 56, 83, 40, 80, 70, 33], [41, 48, 72, 33, 47, 32, 37, 16, 94, 29], [53, 71, 44, 65, 25, 43, 91, 52, 97, 51, 14], [70, 11, 33, 28, 77, 73, 17, 78, 39, 68, 17, 57], [91, 71, 52, 38, 17, 14, 91, 43, 58, 50, 27, 29, 48], [63, 66, 4, 68,89, 53, 67, 30, 73, 16, 69, 87, 40, 31], [4, 62, 98, 27, 23, 9, 70, 98, 73, 93, 38, 53, 60, 4, 23]] Why does s[1:][:-1] give me the same thing as s[1:] instead of (what I want) [s[i][:-1] for i in range(1,len(s))]. In other words, why does Python ignore my second index?

    Read the article

  • When should I use static methods in a class and what are the benefits?

    - by NAVEED
    I have concept of static variables but what are the benefits of static methods in a class. I have worked on some projects but I did not make a method static. Whenever I need to call a method of a class, I create an object of that class and call the desired method. Static variable in a method holds it's value even when method is executed but accessible only in its containing method but what is the best definition of static method? Is calling the static method without creating object of that class is the only benefit of static method? What is the accessible range for static method? What is the syntax to create and calling static method in php? Thanks

    Read the article

  • Are there cross-platform tools to write XSS attacks directly to the database?

    - by Joachim Sauer
    I've recently found this blog entry on a tool that writes XSS attacks directly to the database. It looks like a terribly good way to scan an application for weaknesses in my applications. I've tried to run it on Mono, since my development platform is Linux. Unfortunately it crashes with a System.ArgumentNullException deep inside Microsoft.Practices.EnterpriseLibrary and I seem to be unable to find sufficient information about the software (it seems to be a single-shot project, with no homepage and no further development). Is anyone aware of a similar tool? Preferably it should be: cross-platform (Java, Python, .NET/Mono, even cross-platform C is ok) open source (I really like being able to audit my security tools) able to talk to a wide range of DB products (the big ones are most important: MySQL, Oracle, SQL Server, ...)

    Read the article

  • Efficient data structure for fast random access, search, insertion and deletion

    - by Leonel
    I'm looking for a data structure (or structures) that would allow me keep me an ordered list of integers, no duplicates, with indexes and values in the same range. I need four main operations to be efficient, in rough order of importance: taking the value from a given index finding the index of a given value inserting a value at a given index deleting a value at a given index Using an array I have 1 at O(1), but 2 is O(N) and insertion and deletions are expensive (O(N) as well, I believe). A Linked List has O(1) insertion and deletion (once you have the node), but 1 and 2 are O(N) thus negating the gains. I tried keeping two arrays a[index]=value and b[value]=index, which turn 1 and 2 into O(1) but turn 3 and 4 into even more costly operations. Is there a data structure better suited for this?

    Read the article

  • Getting error on inserting tuple values in postgreSQL table using python

    - by rahman.bd
    Hello, I want to keep last.fm's user recent music tracks list to postgresql database table using pylast interface.But when I tried to insert values to the table it shows errors.Code example: for i, artist in enumerate(recent_tracks): for key in sorted(artist): cur.execute(""" INSERT INTO u_recent_track(Playback_date,Time_stamp,Track) VALUES (%s,%s)""", (key, artist[key])) conn.commit() cur.execute("SELECT * FROM u_recent_track;") cur.fetchone() for row in cur: print ' '.join(row[1:]) cur.close() conn.close() Here "recent_tracks" tuple have the values for example: artist 0 - playback_date : 5 May 2010, 11:14 - timestamp : 1273058099 - track : Brian Eno - Web I want to store these value under u_recent_track(Tid,Playback_date,Time_stamp,Track).Can anybody have idea how to sort out this problem? when I tried to run, it shows error: Traceback (most recent call last): File "F:\JavaWorkspace\Test\src\recent_track_database.py", line 50, in <module> VALUES (%s,%s,%s)""", (key, artist[key])) IndexError: tuple index out of range Thanks in advanced!

    Read the article

  • MPI4Py Scatter sendbuf Argument Type?

    - by Noel
    I'm having trouble with the Scatter function in the MPI4Py Python module. My assumption is that I should be able to pass it a single list for the sendbuffer. However, I'm getting a consistent error message when I do that, or indeed add the other two arguments, recvbuf and root: File "code/step3.py", line 682, in subbox_grid i = mpi_communicator.Scatter(station_range, station_data) File "Comm.pyx", line 427, in mpi4py.MPI.Comm.Scatter (src/ mpi4py_MPI.c:44993) File "message.pxi", line 321, in mpi4py.MPI._p_msg_cco.for_scatter (src/mpi4py_MPI.c:14497) File "message.pxi", line 232, in mpi4py.MPI._p_msg_cco.for_cco_send (src/mpi4py_MPI.c:13630) File "message.pxi", line 36, in mpi4py.MPI.message_simple (src/ mpi4py_MPI.c:11904) ValueError: message: expecting 2 or 3 items Here is the relevant code snipped, starting a few lines above 682 mentioned above. for station in stations #snip--do some stuff with station station_data = [] station_range = range(1,len(station)) mpi_communicator = MPI.COMM_WORLD i = mpi_communicator.Scatter(station_range, nsm) #snip--do some stuff with station[i] nsm = combine(avg, wt, dnew, nf1, nl1, wti[i], wtm, station[i].id) station_data = mpi_communicator.Gather(station_range, nsm) I've tried a number of combinations initializing station_range, but I must not be understanding the Scatter argument types properly. Does a Python/MPI guru have a clarification this?

    Read the article

  • How can I perform a web query in C# similar to the Data > Import External Data > New Web Query in Mi

    - by TNT
    I need to pull data from a table on a website. I can easily do this in VBA using the Web Query, but I need to do this in C#. I'm just having some trouble figuring out how to properly convert the code. I got something close, but it's returning HTML with the data. I just want the data. Any help would be great. The block of code giving me issues is below: Private Function GetData(ByVal theURL As String, ByVal theRow As Integer, ByVal thePosition As Integer, ByVal theColumn As String, ByVal theTable As Integer) With ActiveSheet.QueryTables.Add(Connection:="URL;" + theURL, Destination:=Sheet2.Range(theColumn & theRow + 1)) .Name = "op?s=" + Mid(theURL, thePosition + 1) + "_1" .PreserveFormatting = True .AdjustColumnWidth = True .WebTables = theTable .Refresh BackgroundQuery:=False End With End Function

    Read the article

  • Classic ASP Site Throwing Date Conversion Error After Moving Servers?

    - by leen3o
    I am moving an old store from a Win2003 IIS6 server to a Win2008 IIS7 server, moved everything across including database. The front end seems to work just fine, but when I login it has to do pull in data based on date ranges and now from no where I am getting this error? The conversion of a varchar data type to a datetime data type resulted in an out-of-range value Any ideas why this would do this on the new server and NOT on the old one? No code has changed and the DB is a backup of the one from the old server??

    Read the article

  • Python Beginner: Selective Printing in loops

    - by Jonathan Straus
    Hi there. I'm a very new python user (had only a little prior experience with html/javascript as far as programming goes), and was trying to find some ways to output only intermittent numbers in my loop for a basic bicycle racing simulation (10,000 lines of biker positions would be pretty excessive :P). I tried in this loop several 'reasonable' ways to communicate a condition where a floating point number equals its integer floor (int, floor division) to print out every 100 iterations or so: for i in range (0,10000): i = i + 1 t = t + t_step #t is initialized at 0 while t_step is set at .01 acceleration_rider1 = (power_rider1 / (70 * velocity_rider1)) - (force_drag1 / 70) velocity_rider1 = velocity_rider1 + (acceleration_rider1 * t_step) position_rider1 = position_rider1 + (velocity_rider1 * t_step) force_drag1 = area_rider1 * (velocity_rider1 ** 2) acceleration_rider2 = (power_rider2 / (70 * velocity_rider1)) - (force_drag2 / 70) velocity_rider2 = velocity_rider2 + (acceleration_rider2 * t_step) position_rider2 = position_rider2 + (velocity_rider2 * t_step) force_drag2 = area_rider1 * (velocity_rider2 ** 2) if t == int(t): #TRIED t == t // 1 AND OTHER VARIANTS THAT DON'T WORK HERE:( print t, "biker 1", position_rider1, "m", "\t", "biker 2", position_rider2, "m"

    Read the article

  • Update specific rows in LINQ to SQL result set.

    - by davemackey
    I have a page with a form on it and needs a range of dates. Thus I've placed a number of textboxes on the page into which users can type dates. When the user clicks the save button I want to trigger a LINQ update to the SQL Server...all the rows already exist, so I'm just updating existing data. How can I do this? For example, lets say my table looks like this: Column Names: Description dateValue Column Values: Birthdate 1/1/1990 Anniversary 1/10/1992 Death 1/1/1993 I want to do something like this: hupdate.Description("Birthdate").dateValue = TextBox1.Text hupdate.Description("Anniversary").dateValue = TextBox2.Text hupdate.Description("Death").dateValue = TextBox3.Text hconfig.SubmitChanges() Is there a way to do this with LINQ?

    Read the article

  • Masking to Transparent returns empty image

    - by Tibi
    Hi there, I'm trying to put white color in my images to transparent with the following code. Problem is that "CGImageRef maskedTransparent" is blank. I don't understand because the code I'm using is nearly a copy paste from the doc ... Any idea ? (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage { CGImageRef maskRef = maskImage.CGImage; CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef), CGImageGetHeight(maskRef), CGImageGetBitsPerComponent(maskRef), CGImageGetBitsPerPixel(maskRef), CGImageGetBytesPerRow(maskRef), CGImageGetDataProvider(maskRef), NULL, false); CGImageRef masked = CGImageCreateWithMask([image CGImage], mask); //Array defining min & max RGB values to be transformed to transparent colors. float maskingMinMax[6] = {255, 255, 255, 255, 255, 255}; //masking image to remove range in maskinLinMax CGImageRef maskedTransparent = CGImageCreateWithMaskingColors(masked, maskingMinMax); return [UIImage imageWithCGImage:maskedTransparent]; }

    Read the article

  • Windows API calls from assembly while minimizing program size

    - by takteek
    I'm trying to write a program in assembly and make the resulting executable as small as possible. Some of what I'm doing requires windows API calls to functions such as WriteProcessMemory. I've had some success with calling these functions, but after compiling and linking, my program comes out in the range of 14-15 KB. (From a source of less than 1 KB) I was hoping for much, much less than that. I'm very new to doing low level things like this so I don't really know what would need to be done to make the program smaller. I understand that the exe format itself takes up quite a bit of space. Can anything be done to minimize that? I should mention that I'm using NASM and GCC but I can easily change if that would help.

    Read the article

  • Macro VBA to get selected text in Outlook 2003

    - by balalakshmi
    I am trying to use this code snippet to get the selected text in outlook 2003 Sub SelectedTextDispaly() On Error Resume Next Err.Clear Dim oText As TextRange ''# Get an object reference to the selected text range. Set oText = ActiveWindow.Selection.TextRange ''# Check to see whether error occurred when getting text object ''# reference. If Err.Number <> 0 Then MsgBox "Invalid Selection. Please highlight some text " _ & "or select a text frame and run the macro again.", _ vbExclamation End End If ''# Display the selected text in a message box. If oText.Text = "" Then MsgBox "No Text Selected.", vbInformation Else MsgBox oText.Text, vbInformation End If End Sub When running this macro I get the error --------------------------- Microsoft Visual Basic --------------------------- Compile error: User-defined type not defined Do I need to add any references to fix this up?

    Read the article

< Previous Page | 124 125 126 127 128 129 130 131 132 133 134 135  | Next Page >