Search Results

Search found 6094 results on 244 pages for 'double gras'.

Page 41/244 | < Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >

  • how do I insert an hidden token in my form to prevent double posts? (PHP)

    - by jpjp
    I want to prevent users from accidentally posting a comment twice. I use the PRG (post redirect get) method, so that I insert the data on another page then redirect the user back to the page which shows the comment. This allows users to refresh as many times as they want. However this doesn't work when the user goes back and clicks submit again or when they click submit 100 times really fast. I don't want 100 of the same comments. I looked at related questions on SO and found that a token is best. But I am having trouble using it. //makerandomtoken(20) returns a random 20 length char. <form method="post" ... > <input type="text" id="comments" name="comments" class="commentbox" /><br/> <input type="hidden" name="_token" value="<?php echo $token=makerandomtoken(20); ?>" /> <input type="submit" value="submit" name="submit" /> </form> if (isset($_POST['submit']) && !empty($comments)) { $comments= mysqli_real_escape_string($dbc,trim($_POST['comments'])); //how do I make the if-statment to check if the token has been already set once? if ( ____________){ //don't insert comment because already clicked submit } else{ //insert the comment into the database } } So I have the token as a hidden value, but how do I use that to prevent multiple clicking of submit.

    Read the article

  • modify the way files get opened from finder by shift-clicking (etc) as in windows

    - by stib
    In the windows shell it is possible to modify the default action for opening any document type when holding down a modifier key such as shift or option when double clicking. So for example I can open a jpeg in irfanview if I just double click it, in firefox if I shift-double click it or in potatoshop if I option-double click it. However on a mac I have to right click, and choose "open with..", which can be annoying when there are a lot of possible candidates (such as with jpegs) or if I want to open the file with somehting like an applescript, which won't show up on the list and will have to be found in the file system and specified manually, every.. single.. time. Is there a way of making the mac open files differently by holding down modifier keys when double clicking?

    Read the article

  • How can I prevent a double submit with jQuery or Javascript?

    - by kielie
    Hi guys, I keep getting duplicate entries in my database because of impatient users clicking the submit button multiple times. I googled and googled and found a few scripts, but none of them seem to be sufficient. How can I prevent these duplicate entries from occurring using javascript or preferably jQuery? Thanx in advance!

    Read the article

  • How many copies are needed to enlarge an array?

    - by user10326
    I am reading an analysis on dynamic arrays (from the Skiena's algorithm manual). I.e. when we have an array structure and each time we are out of space we allocate a new array of double the size of the original. It describes the waste that occurs when the array has to be resized. It says that (n/2)+1 through n will be moved at most once or not at all. This is clear. Then by describing that half the elements move once, a quarter of the elements twice, and so on, the total number of movements M is given by: This seems to me that it adds more copies than actually happen. E.g. if we have the following: array of 1 element +--+ |a | +--+ double the array (2 elements) +--++--+ |a ||b | +--++--+ double the array (4 elements) +--++--++--++--+ |a ||b ||c ||c | +--++--++--++--+ double the array (8 elements) +--++--++--++--++--++--++--++--+ |a ||b ||c ||c ||x ||x ||x ||x | +--++--++--++--++--++--++--++--+ double the array (16 elements) +--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--+ |a ||b ||c ||c ||x ||x ||x ||x || || || || || || || || | +--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--+ We have the x element copied 4 times, c element copied 4 times, b element copied 4 times and a element copied 5 times so total is 4+4+4+5 = 17 copies/movements. But according to formula we should have 1*(16/2)+2*(16/4)+3*(16/8)+4*(16/16)= 8+8+6+4=26 copies of elements for the enlargement of the array to 16 elements. Is this some mistake or the aim of the formula is to provide a rough upper limit approximation? Or am I missunderstanding something here?

    Read the article

  • How can I improve the performance of this double-for print?

    - by Florenc
    I have the following static method that prints the data imported from a 40.000 lines .xls spreadsheet. Now, it takes about 27 seconds to print the data in the console and the memory consumption is huge. import org.apache.poi.hssf.usermodel.*; import org.apache.poi.ss.usermodel.*; public static void printSheetData(List<List<HSSFCell>> sheetData) { for (int i = 0; i < sheetData.size(); i++) { List<HSSFCell> list = (List<HSSFCell>) sheetData.get(i); for (int j = 0; j < list.size(); j++) { HSSFCell cell = (HSSFCell) list.get(j); System.out.print(cell.toString()); if (j < list.size() - 1) { System.out.print(", "); } } System.out.println(""); } } Disclaimer: I know, I know large data belong to a database, don't print output in the console, premature optimization is the root of all evils...

    Read the article

  • LoginControl not working correctly with Firefox, requires double login attempt.

    - by CmdrTallen
    Any idea why LoginControl requires users authenticate twice with FireFox but works correctly (once) with IE? I am using a custom MembershipProvider and RoleProvider, if that matters. Authentication portion of my web.config; <authentication mode="Forms"> <forms timeout="50000000" protection="All" requireSSL="false" slidingExpiration="true" cookieless="AutoDetect" domain="" enableCrossAppRedirects="true"> <credentials passwordFormat="SHA1" /> </forms> </authentication> Membership section; <membership defaultProvider="CustomMembershipProvider"> <providers> <add name="CustomMembershipProvider" type="CustomCrateMembershipProvider" connectionString="" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/> </providers> </membership> <roleManager defaultProvider="CustomRoleProvider" enabled="true"> <providers> <add name="CustomRoleProvider" type="CustomRoleProvider"/> </providers> </roleManager> Only code behind related to login; protected void OnLoggedIn(object sender, EventArgs e) { } protected void OnLoggingOut(object sender, EventArgs e) { }

    Read the article

  • Simple rendering produces minor stutter

    - by Ben
    For some reason, this game loop renders the movement of a simple rectangle with no stuttering. double currTime; double prevTime = System.nanoTime() / NANO_TO_SEC; double FPSTIMER = System.nanoTime(); double maxTimeDiff = 100.0 / 1000.0; double delta = 1.0 / 60.0; int processes = 0, frames = 0; while(true){ currTime = System.nanoTime() / NANO_TO_SEC; if(currTime - prevTime > maxTimeDiff) prevTime = currTime; if(currTime >= prevTime){ process(); processes++; prevTime += delta; if(currTime < prevTime){ render(); frames++; } } else{ try{ Thread.sleep((long) (1000 * (prevTime - currTime))); } catch(Exception e){} } if(System.nanoTime() - FPSTIMER > 1000000000.0){ System.out.println("Process: " + (1000 / processes) + "ms FPS: " + (1000 / frames) + "ms"); processes = frames = 0; FPSTIMER += 1000000000.0; } } But for this game loop, I get really minor stuttering where the movement does not look smooth. long prevTime = System.currentTimeMillis(); long prevRenderTime = 0; long currRenderTime = 0; long delta = 0; long msPerTick = 1000 / 60; int frames = 0; int ticks = 0; double FPSTIMER = System.currentTimeMillis(); while (true){ long currTime = System.currentTimeMillis(); delta += (currTime - prevTime) / msPerTick; prevTime = currTime; while (delta >= 1){ ticks++; process(); delta -= 1; } prevRenderTime = System.currentTimeMillis(); render(); frames++; currRenderTime = System.currentTimeMillis(); try{ Thread.sleep((long) ((1000 / FPS) - (currRenderTime - prevRenderTime))); } catch(Exception e){} if(System.currentTimeMillis() - FPSTIMER > 1000.0){ System.out.println("Process: " + (1000.0 / ticks) + "ms FPS: " + (1000.0 / frames) + "ms"); ticks = frames = 0; FPSTIMER += 1000.0; } Is there any critical difference that I'm missing here? The one thing I noticed is that if I uncap the fps for the second game loop, the stuttering goes away. It doesn't make sense to me. Also, the second game loop came from Notch's Minicraft code with just my thread sleeping code added in.

    Read the article

  • What are some methods to prevent double posting in a form? (PHP)

    - by jpjp
    I want to prevent users from accidentally posting a comment twice. I use the PRG (post redirect get) method, so that I insert the data on another page then redirect the user back to the page which shows the comment. This allows users to refresh as many times as they want. However this doesn't work when the user goes back and clicks submit again or when they click submit 100 times really fast. I don't want 100 of the same comments. I looked at related questions on SO and found that a token is best. But I am having trouble using it. //makerandomtoken(20) returns a random 20 length char. <form method="post" ... > <input type="text" id="comments" name="comments" class="commentbox" /><br/> <input type="hidden" name="_token" value="<?php echo $token=makerandomtoken(20); ?>" /> <input type="submit" value="submit" name="submit" /> </form> if (isset($_POST['submit']) && !empty($comments)) { $comments= mysqli_real_escape_string($dbc,trim($_POST['comments'])); //how do I make the if-statment to check if the token has been already set once? if ( ____________){ //don't insert comment because already clicked submit } else{ //insert the comment into the database } } So I have the token as a hidden value, but how do I use that to prevent multiple clicking of submit. METHODS: someone suggested using sessions. I would set the random token to $_SESSION['_token'] and check if that session token is equal to the $_POST['_token'], but how do I do that? When I tried, it still doesn't check

    Read the article

  • get user selection and convert it to a String [Android]

    - by Kira
    Hello, I just got a Droid, and after having used it for a while, I felt like I wanted to make a program for it. The program that I am trying to make calculates the actual storage capacity of secondary storage mediums. The user select from a list of units that ranges from KB to YB and the size the entered gets put into a formula depending on the chosen unit. However, there is a bit of a problem with the program. From my testing, I have narrowed it down to the fact that the user's selection is not really being obtained from the spinner. Everything I look up seems to point me to a method quite similar to how it works in J2SE, but it does nothing. How am I actually supposed to get that data? Here is the Java source code for the app: package com.Actual.android; import android.app.Activity; import android.os.Bundle; import android.widget.*; import android.view.*; public class ActualStorageActivity extends Activity { Spinner selection; /* declare variable, in order to control spinner (ComboBox) */ ArrayAdapter adapter; /* declare an array adapter object, in order for spinner to work */ EditText size; /* declare variable to control textfield */ EditText result; /* declare variable to control textfield */ Button calculate; /* declare variable to control button */ Storage capacity = new Storage(); /* import custom class for formulas */ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // load content from XML selection = (Spinner)findViewById(R.id.spinner); adapter = ArrayAdapter.createFromResource(this, R.array.choices_array, android.R.layout.simple_spinner_dropdown_item); size = (EditText)findViewById(R.id.size); result = (EditText)findViewById(R.id.result); calculate = (Button)findViewById(R.id.submit); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); /* set resource for dropdown */ selection.setAdapter(adapter); // attach adapter to spinner result.setEnabled(false); // make read-only result.setText("usable storage"); } public void calcAction(View view) { String initial = size.getText().toString(); String unit = selection.getSelectedItem().toString(); String end = "Nothing"; double convert = Double.parseDouble(initial); capacity.setStorage(convert); if (unit == "KB") { end = Double.toString(capacity.getKB()); } else if (unit == "MB") { end = Double.toString(capacity.getMB()); } else if (unit == "GB") { end = Double.toString(capacity.getGB()); } else if (unit == "TB") { end = Double.toString(capacity.getTB()); } else if (unit == "PB") { end = Double.toString(capacity.getPB()); } else if (unit == "EB") { end = Double.toString(capacity.getEB()); } else if (unit == "ZB") { end = Double.toString(capacity.getZB()); } else if (unit == "YB") { end = Double.toString(capacity.getYB()); } else; result.setText(end); } }

    Read the article

  • Why does dynamic array always double by a factor of 2?

    - by Phoenix
    I was wondering how does one decide the resizing factor by which dynamic array resizes ? On wikipedia and else where I have always seen the number of elements being increased by a factor of 2? Why 2? Why not 3? how does one decide this factor ? IF it is language dependent I would like to know this for Java.

    Read the article

  • Generic that takes only numeric types (int double etc)?

    - by brandon
    In a program I'm working on, I need to write a function to take any numeric type (int, short, long etc) and shove it in to a byte array at a specific offset. There exists a Bitconverter.GetBytes() method that takes the numeric type and returns it as a byte array, and this method only takes numeric types. So far I have: private void AddToByteArray<T>(byte[] destination, int offset, T toAdd) where T : struct { Buffer.BlockCopy(BitConverter.GetBytes(toAdd), 0, destination, offset, sizeof(toAdd)); } So basically my goal is that, for example, a call to AddToByteArray(array, 3, (short)10) would take 10 and store it in the 4th slot of array. The explicit cast exists because I know exactly how many bytes I want it to take up. There are cases where I would want a number that is small enough to be a short to really take up 4 bytes. On the flip side, there are times when I want an int to be crunched down to just a single byte. I'm doing this to create a custom network packet, if that makes any ideas pop in to your heads. If the where clause of a generic supported something like "where T : int || long || etc" I would be ok. (And no need to explain why they don't support that, the reason is fairly obvious) Any help would be greatly appreciated! Edit: I realize that I could just do a bunch of overloads, one for each type I want to support... but I'm asking this question because I want to avoid precisely that :)

    Read the article

  • Looking for feedback on design pattern for simple 2D environment

    - by Le Mot Juiced
    I'm working in iOS. I am trying to make a very simple 2D environment where there are some basic shapes you can drag around with your finger. These shapes should interact in various ways when dropped on each other, or when single-tapped versus double-tapped, etc. I don't know the name for the design pattern I'm thinking of. Basically, you have a bunch of arrays named after attributes, such as "double-tappable" or "draggable" or "stackable". You assign these attributes to the shapes by putting the shapes in the arrays. So, if there's a double-tap event, the code gets the location of it, then iterates through the "double-tappable" array to see if any of its members are in that location. And so on: every interactive event causes a scan through the appropriate array or arrays. It seems like that should work, but I'm wondering if there's a better pattern for the purpose.

    Read the article

  • Why does casting to double using "String * 1" fail? Will CDbl(String) work on all systems?

    - by Jamie Bull
    I have an application which contains the line below to assign a parsed XML value to a variant array. V(2) = latNode.Text * 1 This works fine on my system (Windows 7, Excel 2010) but doesn't work on some other system or systems - and I've not been able to get a response from the user who reported the problem. I've switched out the offending line for: V(2) = CDbl(latNode.Text) This still works on my system, but then I had no problem in the first place. The question is on what systems does the first approach fail and why, and will the second method always work? I'm sure I've used the "Stying * 1" trick elsewhere before and would like to know how concerned I should be about tracking down other occurrences. Thanks.

    Read the article

  • PHP Curl Not formatting quotes properly; producing weird character set for single/double quotes

    - by user595052
    I wrote a html scraper to scrape my various social identites, so I can make a real time 'biography' website. However after using php curl_exec, I find that texts that I have quoted, end up being formatted in a weird character set. ex: "I love dogs" gets formatted to ’I love dogs ’ "I hate cheese" gets formatted to “I hate cheese� How do I either scrub these characters, or set curl not to format quotes like this. Also, I have turned off magic_quotes.

    Read the article

  • Interesting fact #123423

    - by Tim Dexter
    Question from a customer on an internal mailing list this, succintly answered by RTF Template God, Hok-Min Q: Whats the upper limit for a sum calculation in terms of the largest number BIP can handle? A: Internally, XSL-T processor uses double precession.  Therefore the upper limit and precision will be same as double (IEEE 754 double-precision binary floating-point format, binary64). Approximately 16 significant decimal digits, max is 1.7976931348623157 x 10308 . So, now you know :)

    Read the article

  • Do double forward slashes direct IE to use specific css?

    - by kjh
    I have just found something very weird while developing a website. While trying to get a div element to display across the top of the screen, I noticed that I wasn't achieving a desired result in any browser except for old versions of IE. In order to test some different code, instead of deleting the faulty line, I used '//' to comment it out (I'm not really even sure if that works in css) but what happened was, the compatible browsers used the uncommented code, while IE used the code marked by '//'. here is the code: #ban-menu-div{ position:fixed;top:0; //position:relative; //<-- IE keeps the banner with rel pos while the other display:block; // browsers used fixed margin:auto; padding:0px; width:100%; text-align:center; background:black; } so basically, it seems as though // can be used to instruct newer browsers to ignore specific lines of code, and instruct older versions of IE to use it? If this is common practice someone please let me know. it sure makes developing for older browsers a hell of a lot easier

    Read the article

  • How to avoid double construction of proxy with DynamicProxy::CreateClassProxyWithTarget?

    - by Belvasis
    I am decorating an existing object using the CreateClassProxyWithTarget method. However, the constructor and therefore, initialization code, is being called twice. I already have a "constructed" instance (the target). I understand why this happens, but is there a way to avoid it, other than using an empty constructor? Edit: Here is some code: First the proxy creation: public static T Create<T>(T i_pEntity) where T : class { object pResult = m_pGenerator.CreateClassProxyWithTarget(typeof(T), new[] { typeof(IEditableObject), typeof(INotifyPropertyChanged) , typeof(IMarkerInterface), typeof(IDataErrorInfo) }, i_pEntity, ProxyGenerationOptions.Default, new BindingEntityInterceptor<T>(i_pEntity)); return (T)pResult; } I use this for example with an object of the following class: public class KatalogBase : AuditableBaseEntity { public KatalogBase() { Values = new HashedSet<Values>(); Attributes = new HashedSet<Attributes>(); } ... } If i now call BindingFactory.Create(someKatalogBaseObject); the Values and Attributes properties are beeing initialized again.

    Read the article

  • How can I double-enhance a class with cglib?

    - by artemb
    Hi there! Here's the code: Patient patient = factory.createPatient(); Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(patient.getClass()); enhancer.setCallback(new DefaultMethodInterceptor(patient)); patient = (Patient) enhancer.create(); assertThat(patient.getFirstName()).isNotNull(); Enhancer enhancer2 = new Enhancer(); enhancer2.setSuperclass(patient.getClass()); enhancer2.setCallback(new DefaultMethodInterceptor(patient)); patient = (Patient) enhancer2.create(); assertThat(patient.getFirstName()).isNotNull(); It fails on the last assert with net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null ... Caused by: java.lang.reflect.InvocationTargetException ... Caused by: java.lang.ClassFormatError: Duplicate method name&signature in class file my/package/entity/Patient$$EnhancerByCGLIB$$ca1e6685$$EnhancerByCGLIB$$f52743be I ask this because I want to enhance Hibernate's entities, but sometimes it returns already enhanced ones by itself and my second enhancement fails. How can I avoid this?

    Read the article

  • How to use GPS data like the double value returned by getLatitude()?

    - by Dan
    I have been searching quite a bit for an answer, but maybe I'm just not using the correct terminology. I am creating an app that will access a database to return a list of other users that are within a certain distance of the users location. I've never worked with this type of data, and I don't really know what the values mean. I'd like to do all the calculations on the backend with either MySQL or PHP. Currently, I am storing the latitude and longitude as doubles within the database. I can access them and store them, but I have no idea how I might be able to sort them based on distance. Perhaps I should be using a different type or some technique that is common in this area. TIA.

    Read the article

  • Double right click to Show a PopUpMenu with A TListView !!

    - by djiga4me
    Hi, I have a TListView and TPopupMenu, and I want to show a context menu when I right click on a TListItem. I tried the "AutoPopup" by assigning the component, but on a right click the PopupMenu is shown only and the wanted element is not selected. So i tried to use the "OnMouseDown", but we need to click and click again to show the menu on the wanted item. The first click is to select the item and the second shows the menu. But I want just a one click to do the two things. Do you have and idea about the problem? Thank you.

    Read the article

< Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >