w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Parsing different time formats into short time format
I think this actually so string[] formats = { "hh", "hhtt", "hh tt", "%h", "%htt", "%h tt", @"h:mm", @"h:mmtt", @"h:mm tt", @"hh:mm", @"hh:mmtt", @"hh:mm tt", @"d.hh:mm:ss", @"d.hh:mm:sstt", @"d.hh:mm:ss tt", "fffff", "hhmm", "hhmmtt", "hhmm tt" }; DateTime newDate = new DateTime(); if (DateTime.TryParseExact(txtStartTime.Text, formats, null, DateTimeStyles.None, out newDate)) { txtStartTime.Text = newDate.ToShortTimeString(); }

Categories : C#

I have a short html form with a php for loop which allows the user to build the same form up to ten times on the page
If I understood your question correctly, you are trying to add more content or replace content on a webpage that has already been generated with PHP. I think what you are trying to do can be achieved using AJAX. AJAX is a technique for creating dynamic webpages. AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page. In your case, the process can be described in 3 steps: the browser making a new request to your server (using javascript) the server processes the request and sends some information back to the browser the browser deals with that information (again using javascript) and then updates part of the webpage There is

Categories : PHP

How to use short assets path in Twig Template for Symfony2?
You can include all css in a folder like this: {% stylesheets 'bundles/main/js/lightbox/css/*' filter='cssrewrite' %} <link href="{{ asset_url }}" rel="stylesheet" type="text/css" /> {% endstylesheets %}

Categories : PHP

How do I set a PHP cookie for one second or a short period of time?
Yes, you are doing it right! time()+1 is completely valid. Here is more information from the PHP manual about cookie expiration time: This is a Unix timestamp so is in number of seconds since the epoch. In other words, you'll most likely set this with the time() function plus the number of seconds before you want it to expire. Or you might use mktime(). time()+60*60*24*30 will set the cookie to expire in 30 days. If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes). But one (1) second is, as commented, a little bit too short to be useful.

Categories : PHP

JFormattedTextField and short time format
Given a SimpleDateFormat("MM/dd/yyyy"), the lenient interpretation of the Calendar value 30/11/2013 is 6/11/2015. You can defeat this behavior by specifying setLenient(false) in the format used to construct your JFormattedTextField. In this example, an InputVerifier is used to check a List<SimpleDateFormat> for valid entries. For example, static { validForms.add(new SimpleDateFormat("MM/dd/yyyy")); validForms.add(new SimpleDateFormat("MM/dd/yy")); for (SimpleDateFormat f : validForms) { f.setLenient(false); } } Addendum: In your updated example, SimpleDateFormat f = new java.text.SimpleDateFormat("MM/dd/yyyy"); f.setLenient(false); jFormattedTextField1.setFormatterFactory( new javax.swing.text.DefaultFormatterFactory( new javax.swing.text.Date

Categories : Java

check exist external XML with short time
My solution is... Im checked ping on external device with use this function. function icmpChecksum($data){ if (strlen($data)%2) $data .= "x00"; $bit = unpack('n*', $data); $sum = array_sum($bit); while ($sum >> 16) $sum = ($sum >> 16) + ($sum & 0xffff); return pack('n*', ~$sum); } // Making the package $type= "x08"; $code= "x00"; $checksum= "x00x00"; $identifier = "x00x00"; $seqNumber = "x00x00"; $data= "Scarface"; $package = $type.$code.$checksum.$identifier.$seqNumber.$data; $checksum = icmpChecksum($package); // Calculate the checksum $package = $type.$code.$checksum.$identifier.$seqNumber.$data; // And off to the sockets $socket = socket_create(AF_INET, SOCK_RAW, 1); socket_set_option ( $socket, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>1, "usec"=>0) ); socket_con

Categories : Xml

C # win form button short cut on tab control
You would need to use global hotkeys. here is a thead that shows how its done: Set global hotkeys using C#

Categories : C#

how to hinder the short waiting time while pushing a button?
What you're seeing is the repeat delay. If you type in a document and hold down a key, you'll see that there is a small delay before the repeated character is displayed. There will be a value that you can configure in the operating system to either increase or decrease the delay, but this is not what your program should do. Instead, install an event filter for handling the keys. You can read about how to do that here.

Categories : Qt

Printing 'long' or 'short' form of a string
a simple if statement inside the printOrder method would suffice, for example public String printOrder(String format){ if(format.equals("Long"){ print and return the long version }else{ print and return the short version } }

Categories : Java

Short cut way of collecting form input values using javascript
Indeed there is: $("#save").click(function () { var postData = $("#idOfYourForm").serialize(); $.ajax({ type: "POST", url: "<?php echo base_url(); ?>main_controller/save_data", data: postdata, // it is perhaps better to specify the dataType // of the data expected back from the server // for readability dataType: 'json', success: function (data) { if (data.notify) { alert('success'); } else { alert('Failed'); } } }); // maybe you need this return false; }); http://api.jquery.com/serialize/

Categories : Javascript

Gmail Snooze error: moveSnoozes "service invoked too many times in a short time"
The error you got is because creating 200 labels at the speed-of-code is too fast for Gmail and considered abuse of it's API. SO, as the error message suggests, you could use Utilities.sleep(1000) to wait a second between each label creation. I'm not familiar with the script (Boomerang works well for me), but you might try making your 30, 60, 90 180 day labels by hand and letting the script pick up on them. Then you don't need to worry about the label creation at all. In an effort to help you better understand the code you are reading. Below is an explanation of what's going on and how to insert the Utilities.sleep(). You will need to decide for how long you want to wait 1000ms means that you're waiting for 200 seconds, and if you have 3 min to spare that will do just fine. You could exp

Categories : Google Apps Script

How can I turn off interrupt that switching threads in OS, on short time, for my critical part of code?
Short answer: You generally can't. Longer answer: If you have a critical task, you could try to up the priority of that thread, but it's not going to help indefinitely, because modern (non-realtime) OS's do not allow a thread to "take all the CPU in the machine". Further, ANY interrupt can cause your task to be scheduled. The timer is the one that does it based on time-quanta, but for example if another task is waiting for a network packet, that task will be placed in the runnable queue when such a packet comes in, so the scheduler will run at that point, and make a decision if it's time to run another thread (which technically could be NEITHER your thread, nor the network-packet-waiting thread). Likewise, if your thread touches some memory that has been swapped out to disk, it obvious

Categories : C++

How do I add product short description on the product list template page on Magento?
You can use in the list.phtml file this. $_product->getShortDescription(); but Magento does not load all the attributes on the product listing page. Go to the admin pannel Catalog->Attributes-> Manage Attributes and edit the short description attribute. Set “Used in product listing” to “Yes”. Save and clear the cache.

Categories : Magento

Why django form.as_p call form.clean method when template renders?
As far as I can see in the source django has a _html_output helper function to return the function form.as_p(). If there is data bound to the form (like yours), then the BaseForm class property errors is called. This function calls the forms full clean. So I think this behaviour is intentionally to render form errors.

Categories : Django

Why won't CloudFormation execute my command?
Your commands block should be nested inside the config block, at the moment it is at the same level in the hierarchy. "AWS::CloudFormation::Init" : { "config" : { "files" : { "c:\Packages\WebDeploy_amd64_en-US.msi" : { "source" : "http://download.microsoft.com/download/1/B/3/1B3F8377-CFE1-4B40-8402-AE1FC6A0A8C3/WebDeploy_amd64_en-US.msi" } }, "commands" : { "1-installwebdeploy" : { "command" : "msiexec.exe /i c:\Packages\WebDeploy_amd64_en-US.msi ADDLOCAL=ALL /qn /norestart" } } }, }

Categories : Amazon

AWS - Automatic deployment (.NET) to CloudFormation stack
cloud-init is used with windows too. See the documentation for bootstrapping Windows stacks.

Categories : Amazon

Why won't my CloudFormation script download a file?
Jonathon, I tried your template and the file downloaded successfully for me. You can check the cfn logs on the instance. They are in c:cfnlog. My cfn-init.log shows: 2013-07-19 21:30:18,269 [DEBUG] Parent directory c: est does not exist, creating 2013-07-19 21:30:18,269 [DEBUG] Writing content to c: estgoogle-logo.png 2013-07-19 21:30:18,269 [DEBUG] Retrieving contents from http://www.google.com/images/srpr/logo4w.png 2013-07-19 21:30:18,316 [DEBUG] No mode specified for c: estgoogle-logo.png 2013-07-19 21:30:18,316 [WARNING] Unsupported OS for setting owner/group: nt And my cfn-wire.log shows: 2013-07-19 21:30:18,269 [DEBUG] Request: GET http://www.google.com/images/srpr/logo4w.png [headers: {'Accept-Encoding': 'identity, deflate, compress, gzip', 'Accept': '*/*', 'User-Agent': 'pyth

Categories : Amazon

Litle endian unsigned short in C++ to Big endian signed short in Java
On the C++ side, use htons() to turn your shorts from host endianness to network endianness (htons: Host TO Network Short). On the Java side, read form the socket, write into a ByteArrayOutputStream; once you have all the data, wrap this ByteArrayOutputStream's underlying byte array into a ByteBuffer. Read the shorts using the ByteBuffer's .getShort().

Categories : Java

Is it possible to create a SNS subscription with CloudFormation without creating a topic?
As you already discovered, AWS CloudFormation doesn't provide the expected AWS::SNS::Subscription resource (yet) and I'm not aware of this being possible by any other means, unfortunately - guess the rationale is that both are either managed within a template or externally, but your use case is sound and I can see no fundamental reason why this shouldn't be available (maybe they'll add it at some point, AWS is usually expanding their APIs over time to address such inconsistencies/missings).

Categories : Amazon

Simple form format a time field to show '21:30' instead of entire UTC time string
You can add attr_accessor to your model (for example formatted_time) and use this field for get fromatted time and set it. Before save you can parse value of @formatted_time and apply it to time_of_event field.

Categories : Ruby On Rails

Installing Windows applications/extensions with Amazon CloudFormation
For your example of WebDeploy, you could add this: "C:\Webdeploy\WebDeploy_amd64_en-US.msi" : { "source" : "http://download.microsoft.com/download/1/B/3/1B3F8377-CFE1-4B40-8402-AE1FC6A0A8C3/WebDeploy_amd64_en-US.msi" } as a element of this section of the template "WindowsServer": { "Type" : "AWS::EC2::Instance", "Metadata" : { "AWS::CloudFormation::Init" : { "config" : { "files" : { You could then add this command: "1-installwebdeploy" : { "command" : "msiexec.exe /i C:\Webdeploy\WebDeploy_amd64_en-US.msi ADDLOCAL=ALL /qn /norestart" } to the list of commands.

Categories : Amazon

After a form is filled once, I blank out the form before filling it the next time (new conversation), but the borders remain red
I'm not sure, what you want to achieve. I would need to see some code. If you change the value programmatically you can update the validation ui with the event refreshvalidityui on the form field. If you want to reset the ui, you can either trigger a reset event on the form or resetvalidityui on the form field $('input').val('foo').trigger('refreshvalidityui'); or $('input').val('foo').trigger('resetvalidityui'); or $('form').trigger('reset'); Please let me know, if this helps.

Categories : Validation

Generating subnet CIDR blocks programmatically in CloudFormation templates (or adding integers together)
My solution for these kinds of issues was to use a legitimate programming language to compile a template into a CloudFormation JSON document. I used PHP 5.4, Twig and Symfony Console, but YMMV. Essentially, you do the math ahead of time in the programming language, then use that data as you write-out your JSON document.

Categories : Amazon

How I open a form at a time under MDI parent form?
You can read up about mutual exclusion http://msdn.microsoft.com/en-us/library/system.threading.mutex.aspx It is a general solution to make sure you only have 1 thing (thread, process, form, whatever) of something at the same time. You can even use it inter application. An example is shown here: http://www.dotnetperls.com/mutex You can create multiple mutexes, one for each form. Or one for a set of forms, in what ever combination suits you. Example Scenario: Form1 creates a mutex with name X Form2 is being loaded checks whether mutex X is created, if so it closes itself. Of course you will need to make sure the mutex is Disposed / released when the creator (Form1 in this example) closes, to allow other forms to show.

Categories : C#

Convert short to VariantType (extract VariantType from short)
Your code should be fine: The following works perfectly: short num = 4; VariantType vt = (VariantType)num; Console.WriteLine(vt); And outputs "Single". This means that whatever problem you are having is not with the rough line of code you are using. That having been said the actual line you are using (ie VariantType vt = (VariantType)vt; is not going to work because the vt on the right hand side of the equation is invalid since it is unassigned (since you haven't finished declaring it). You should get a "Use of unassigned local vairable 'vt'" when you attempt to compile that. I'm assuming that the line is a mistake but if not you should explain what you are actually trying to do with that line.

Categories : C#

Django datetimefield time in template
Try {{ model.datetime|date:"g:i a" }} If you want a different format, refer to the documentation here

Categories : Python

Is it possible to have a form in a ListView template?
Yes, but all the form process will have to be made by the ListView itself. That is simple, considering you can inherit the behaviour from ModelFormMixin. You will only need one url (to the list view). The template will look like: {% if user.is_authenticated %} <form action="" method="POST"> {% csrf_token %} {{ form }} <input type='submit' value='POST'/> </form> {% endif %} And your view: from django.views.generic.list import ListView from django.views.generic.edit import ModelFormMixin class ListWithForm(ListView, ModelFormMixin): model = MyModel form_class = MyModelForm def get(self, request, *args, **kwargs): self.object = None self.form = self.get_form(self.form_class) # Explicitly states what get to call: r

Categories : Django

PHP Template class / engine processing time
You'd have to run benchmarks to get a definitive answer, but I would expect to get the best performance by simply making your templates PHP files, i.e. set your template variables in a local context and include the "template" file there directly. The benchmark [site has changed and does not offer the benchmark anymore (mention removed)] certainly indicates that it's faster than most template engines (not surprising, as the interpreter does all the parsing for you). Of course, many people discourage using PHP files as templates because it doesn't enforce any separation of concerns - your template is a source file. It's a workable approach, but it does put all of the burden on the developer to not do the wrong thing in the templates. As far as the actual performance of the str_replace()

Categories : PHP

How to change the data template of control at run time
You can do this using Triggers also <Grid> <Grid.Resources> <Style x:Key="DynamicTemplateStyleList" TargetType="ListView"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=DataContext.IsMonthlyChecked}" Value="True"> <Setter Property="ItemTemplate" Value="{StaticResource MonthlyDataTemplate}"/> </DataTrigger> <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=DataContext.IsOneTimeChecked}" Value="True

Categories : Wpf

Pulse the template every time it is rendered in Meteor
Here's a simple blink. Animating background color requires additional libraries, see jQuery animate backgroundColor . var pulseNode = function(node) { if(!node.style) return; var prev = node.style['background-color'] || 'rgba(255,0,0,0)'; $(node).css('background-color', 'red'); setTimeout(function() { $(node).css('background-color', prev); }, 1000); }; pulse = function(template) { for(var node = template.firstNode; true; node = node.nextSibling) { pulseNode(node); if(node === template.lastNode) return; } } Now, for each template you want to use this, do Template.asdf.rendered = function() { pulse(this); }

Categories : CSS

MVC 4 Editor Template for Displaying Time in HH:mm Format
After reading this MVC 3 - Html.EditorFor seems to cache old values after $.ajax call , I realized that before binding, HtmlHelper will look into ModelState. Not sure what is the intention/benefit of checking the ModelState, instead of binding what ever the value supplied. However I added this code in my controller before setting the value. Now it works fine. ModelState.Remove("StartTime"); ModelState.Remove("EndTime"); bookingViewModel.StartTime = Convert.ToDateTime(startTime); bookingViewModel.EndTime = Convert.ToDateTime(endTime); return View("Booking", bookingViewModel);

Categories : C#

show form data in template
In order to retrieve the value of your dictionary in django, you can use the following syntax: ReporForm.get_optons_display() So for example, if you wanted to check if the database query was 'All' or the key '5' you could simply do: if ReporForm.get_optons_display() == 'ALL': #do something Django Docs An excerpt for an example: Views.py #Query your database to retrieve your instance of 'ReporForm' #I will assume there is a primary key of some type (Reportcode) foo = ReporForm.objects.get(ReportCode = 1234) #Pass foo to the context context = {'foo':foo} #Send this context to your render_to_response so it goes to template reportform.html <b>You have selected the option :</b> '{{ foo.get_optons_display }}'

Categories : Django

django form.errors in template
You have assigned; form = UserCreationForm() more number of times than required. It should be: if request.method == "POST" : form = UserCreationForm(request.POST, request.FILES) #since request.POST is present, populate the form with POST values if form.is_valid(): #Check if its valid print "form is valid" form.save() return render_to_response("action_succes.html") else: #invalid case print form.is_valid() #form contains data and errors print form.errors else: form = UserCreationForm() #No post data args = {} args.update(csrf(request)) return render(request, "registration.html", {'form':form}) #Sending the form to view

Categories : Python

Changing a form html name in a template
This could be over simplifying it, but what not just raw output it? <label for="">what ever you want</label> <input type="text" name="{{ form.username.html_name }}" id="{{ form.username.auto_id }}"> I would still do this in the form.py myself but if all you have is the template to work with then it does not need anything fancy here.

Categories : Python

How to use the Django admin template for a form?
I think its better to override the admin interface. https://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates

Categories : Python

Django Form not rendering in template
Any error page or just blank page? Actually I just try your code and get form rendering correct(I don't know how to insert local result image here) Please make sure DEBUG=TRUE in settings.py while it's not the problem. @Burhan I think indent problem only happens because he edits it in stackoverflow. Btw, your form doesn't have a submit button, maybe add it in html like

Categories : Python

Form[] default value in scala template
Unfortunately it doesnt work like this, you have to define the Form's presentation. You may have in your User class: val requestForm = Form( mapping("field1" -> nonEmptyText, "field2" -> nonEmptyText)(User.apply)(User.unapply)) And then you can use your template like this: @(user: Form[User] = User.requestForm) Hope this helps

Categories : Forms

wordpress contact form template
First of all add this line to the top of your script. $hasError = false; Then use this block of code where you want to show success message. if(!$hasError) { // display success message. } Hope this may help you.

Categories : Wordpress

How to Create Form Template in Go Programming?
using template on appengine is only posible if you pass the html from field, because of appengine rules you dont have access to the filesystem here is an example const loginTemplateHTML = `<html> <body> <form action="/login" method="post"> <div><input name="username" type="text" /></div> <div><input name="password" type="password" /></div> <div><input type="submit" value="login"></div> </form> </body> </html> ` var loginTemplate = template.Must(template.New("Login").Parse(loginTemplateHTML)) func login (w http.ResponseWriter, r *http.Request) { if err := loginTemplate.Execute(w,nil); err != nil { http.Error(w, err.String(), http.StatusInternalServe

Categories : Google App Engine

Execute formated time in a slice with html/template
Your Date field has type time.Time. If you format it as a string, and parse it back, you'll once again get a time.Time value, which will still print the default way when the template execution calls its String method, so it's not really solving your problem. The way to solve it is by providing the template with the formatted time string itself instead of a time value, and you can do that in multiple ways. For example: Add a method to your blog post type named FormattedDate or similar, which returns a string properly formatted in the style of your preference. That's the easiest, and probably the nicest way if you don't have a fancy use case. Add a string field to your blog type named FormattedDate or similar; that's very similar to the above option, but you have to be careful to set and

Categories : Google App Engine



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.