w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Create and show a label after running java application
You're trying adding to add to a panel using GroupLayout. Adding dynamically to that would be quite tricky (if possible), and I do not recommend that. I recommend adding a helper JPanel to the pane, and adding any new components to that helper panel. EDIT: To clear the solution that was used: a helper JPanel was added using the form editor (jPanel3 in the code below). The form designer defaults to using GroupLayout for the added panel too, which would lead to the same problem that was to be solved in the first place, so the layout manager of the helper panel was changed to FlowLayout. The action code ends up being as simple as: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { JLabel jLabel2 = new JLabel(); jLabel2.setText("this is a label"); this.jPanel

Categories : Java

Python: Is it possible to create an tkinter label which has a dynamic string when a function is running in background?
Yes, it is possible. There are two ways to do it: Whenever you want to update the label from your code you can call the_widget.configure(the_text). This will change the text of the label. You can create an instance of a tkinter.StringVar, and assign it to the textvariable attribute of a label. Whenever you change the value of the variable (via the_variable.set(the_text), the label will automatically update. Note that for either of these to work, the event loop needs to be able to process events (ie: you won't see anything if your function takes a long time to run and you never call update_idletasks or re-enter the event loop).

Categories : Python

Linq - how to subtract current index DateTime item with previous index DateTime item
Query If you want to get the TimeSpans for each of the waiting periods between consecutive Flight Segments, you can use this: Flight flight = ...; IEnumerable<TimeSpan> query = flight.Segments .SelectPairs((a, b) => b.DepartureDate - a.ArrivalDate); For a Flight with N Segments, this will give you N - 1 TimeSpans. Edit: If you want to get the total amount of waiting time between all Segments on a Flight, you can augment the LINQ query like this: TimeSpan totalWaitingTime = flight.Segments .SelectPairs((a, b) => b.DepartureDate - a.ArrivalDate) .Aggregate(TimeSpan.Zero, (s, t) => s + t); Helper public static IEnumerable<TResult> SelectPairs( this IEnumerable<T> source, Func<T, T, TResult> selector) { var first = true; var pr

Categories : C#

getting Indian current datetime in java
Try this.. It is just about the timezone. Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("IST")); Date date = calendar.getTime(); System.out.println(date);

Categories : Jsp

Java JodaTime Get the Current DateTime
Right from the Java docs: http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html What you're looking to do seems to be the first example there: DateTime dt = new DateTime(); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); String str = fmt.print(dt); If it's not the exact format that you're looking for, Java docs will show you the way.

Categories : Android

How to get all datetime instances of the current week, given a day?
I'd use datetime.date() instead to make it clear we are calculating dates here, and use date.weekday() to get the current weekday instead of using the .isocalendar() call, giving us a 0-based weekday number (0 is Monday). import datetime today = datetime.date(2013, 06, 26) dates = [today + datetime.timedelta(days=i) for i in range(0 - today.weekday(), 7 - today.weekday())] Demo: >>> from pprint import pprint >>> import datetime >>> today = datetime.date(2013, 06, 26) >>> pprint([today + datetime.timedelta(days=i) for i in range(0 - today.weekday(), 7 - today.weekday())]) [datetime.date(2013, 6, 24), datetime.date(2013, 6, 25), datetime.date(2013, 6, 26), datetime.date(2013, 6, 27), datetime.date(2013, 6, 28), datetime.date(2013, 6, 29), datet

Categories : Python

Getting Current time to display in Label. VB.net
try total.Text = DateTime.Now.ToString() or Dim theDate As DateTime = System.DateTime.Now total.Text = theDate.ToString() You declare Start as an Integer, while you are trying to put a DateTime in it, which is not possible.

Categories : Vb.Net

Get Repeater Label in the current "row" being accessed
I believe it's not working because you aren't finding the controls. FindControl will return null if it can't find the control, and Convert.ToString will return an empty string if the object value is null. From what I can see, you are searching for the wrong string ID. So instead of Date, it should be lblDate. If you are in debug build mode, keep in mind that ASP.NET loves to change your control names at runtime, so "lblDate" control might not actually be "lblDate". So you can try debugging on the browser and inspect your elements' IDs for their actual IDs. Also, you probably want to do this instead if you want the label's actual data (notice the .Text): ((Label)item.FindControl("lblDate")).Text

Categories : C#

How can I mark the current tab's label with a star?
Unfortunately, one cannot simply use tabpagenr() to query the current tab page. Apparently, Vim internally switches through the tab pages when evaluating 'guitablabel'. As a workaround, I use an :autocmd to set a tab-scoped variable. With that, one can use a %{...} expression to add the asterisk for the current tab page: au TabEnter * let t:current = 1 au TabLeave * let t:current = 0 set guitablabel=%{exists('t:current')&&t:current?'*':''}%N/ %t %M

Categories : Vim

why i can't save the current DateTime.Now using Entity Framework
Do not switch the Optmistic Concurrency Updates off you will hide the problem and not fix it. do the following: using (var db = new MyEntities()) { using (var transaction = new TransactionScope()) { var newGroup = new Groups { GroupDate = DateTime.Now, GroupName = "someName" }; db.Groups.Add(newGroup); db.SaveChanges(); transaction.Complete(); } } The different now you are creating the TranscationScope inside the DBContext I hope this will solve your problem.

Categories : C#

Insert current datetime based onclick
If you use parameters I think your query should be query = "INSERT INTO dbo.url_map (long_url, expiry_date) Values (@long_url, @expiry_date)"; //this way sqlcommand make sense SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@long_url", tbLongURL.Text); cmd.Parameters.AddWithValue("@expiry_date", DateTime.Today);

Categories : Asp Net

I want to add current datetime for a image which is taken from camera API using phonegap
you can do that using c# by this code FileStream fs = new FileStream(@"c:myImage.jpg", FileMode.Open, FileAccess.Read);//or .jpg, etc... Image image = Image.FromStream(fs); fs.Close(); Bitmap b = new Bitmap(image); Graphics graphics = Graphics.FromImage(b); var date = Convert.ToString(DateTime.Now); graphics.DrawString(date, this.Font, Brushes.Black, image.Width - (date.Length*5), 0); b.Save(@"c:myImage.jpg", image.RawFormat); image.Dispose(); b.Dispose(); if this dose not help inform me to search other method

Categories : HTML

Setting a date to current using DateTime and modifying it
Answered in this SO thread: $date = date('Y-m-d', strtotime('-7 days')); Or with DateTime class: $date = new DateTime('7 days ago'); echo $date->format('Y-m-d');

Categories : PHP

How to reference the current chunk label in knitr?
You can use opts_current$get eg... opts_current$get(name = 'label') eg cat(knit(text =" ```{r 'hello'} render_markdown(strict=TRUE) opts_current$get(name = 'label') ``` ")) Which gives render_markdown(strict = TRUE) opts_current$get(name = "label") ## [1] "hello"

Categories : R

Simple Form: How can I create a custom wrapper that does not wrap the input and create a label?
This code below may result in your expected HTML: config.wrappers :category_tab, tag: "ul" do |ul| ul.use :html5 ul.wrapper tag: "li" do |li| li.wrapper tag: "label" do |label| label.use :input, label: false end end end

Categories : Ruby On Rails

How to set the terminal title to show the current running command while it's running and to show it in brackets once it's finished?
You can (ab)use PS1 by putting the same escape sequence in so that every time the prompt is printed, the title gets updated. export PS1="33]2;[$(history 1 | sed 's/^[ ]*[0-9]*[ ]*//g')]07$PS1" The final PS1 just keeps your old prompt for the actual command line. I don't actually use this, but it should work.

Categories : Linux

Issue to get current system datetime dynamically using windows service
The answer to this forum question says: If your Windows Service is running under the SYSTEM account or other account without a profile it will use the settings defined under the HKEY_USERS/.DEFAULT/Control Panel/International registry key. You can change these values from Control Panel / Regional and Language Options / Advanced by checking the check box Apply all settings to the current user account and to the default user profile. Also, read more about the issue on this similar question: Why is my CurrentCulture en-GB and my CurrentUICulture en-US.

Categories : C#

Conversion from DateTime to Unix Epoch Time in Current Timezone
This is almost certainly the most immediate problem: c.Set(CalendarField.Month, month); My guess is that you're expecting 1 to mean January here - but java.util.Calendar uses 0-based months. You probably want: c.Set(CalendarField.Month, month - 1); There may also be time zone issues, but concentrate on the big ones first - being out by a whole month will almost never be a time zone issue. Alternatively, to get the milliseconds since the unix epoch, you can stick to the .NET types - or even use my Noda Time library. Using just DateTime: private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); static long GetMillisecondsSinceUnixEpoch(int year, int month, int day, int hour, int minute) { DateT

Categories : C#

Get label name of top running activity in the stack Android
try this i dont know whether it help you or not , PackageManager pm = context.getPackageManager(); RunningAppProcessInfo info = am.getRunningAppProcesses().get(0); try { CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName, PackageManager.GET_META_DATA)); System.out.println("the label of the app is " + c); Log.w("LABEL", c.toString()); } catch(Exception e) { //Name Not FOund Exception }

Categories : Android

Updating.. message label not showing when running a thread
You need to run those two lines outside the thread. You aren't going to be able to access the label from the background thread. Normally, when dealing with status updates from a background thread there's a more complex approach because you send more than one, but in your case it's extremely simple (and that's not a jab, there's something to be said about simplicity) because you just want to let the user know you're updating. So, set those two lines just before the start: StatusLabel.Visible = true; StatusLabel.Text = "Updating, please wait.."; t1.Start();

Categories : C#

Why queries are running slower after converting the column from VARCHAR to DATETIME
The EXPLAIN shows the type column is "ALL" which means it's scanning the whole table, it's not using the primary key or any index to help. It can't use the primary key index, because you're only searching on the 2nd and 3rd columns. To get an index to help, you need your search columns to be the leftmost columns of the index. You also should have the columns involved in equality comparison listed to the left of columns involved in range comparison. So you need an index on (Source, Record_datetime). MySQL also tries to be intelligent about avoiding using an index when the index isn't helpful enough and would just be needless overhead. For example, if the specific date range you're searching for (>= '2012-06-12') is the majority of the table, it just falls back to an "ALL" (table-scan)

Categories : Mysql

MySQL query running a long time converting datetime to date
In the join statement you showed us, you are transforming the datetime (into a plain date) in order to compare it. That means that the database engine will have to examine every *single* record in the table to see if they meet the criteria you're after. Even if you have an index on ins_date, the engine will not be able to use it to find the records you're after. See if you can re-craft the query to use the columns in their native form (i.e. without any transformation applied to them). If you have to apply some kind of transformation to a column in order to do a join or filter, try to do it only to the tiniest table in that join, to reduce the number of records that have to be retrieved and transformed. If you can, and this is a query that runs more than only occasionally, see if you

Categories : Mysql

Run a new Hadoop streaming job from current running Job
For most Java jobs it's simple to run a .jar within a Java program. Same with Python streaming jobs. $HADOOP_HOME/bin/hadoop jar $HADOOP_HOME/hadoop-streaming.jar -input myInputDirs -output myOutputDir -mapper org.apache.hadoop.mapred.lib.IdentityMapper -reducer /bin/wc

Categories : Hadoop

How can I update the current script before running it?
Yes, you can update the script you're running, then execute it again. (Just make sure to exit the first script after updating.) Here's some sample code I created: Write-Host "Starting script" if ($(Get-Item G:selfUpdater2.ps1).CreationTimeUtc -gt $(Get-Item G:selfUpdater.ps1).CreationTimeUtc) { Copy-Item G:selfUpdater2.ps1 G:selfUpdater.ps1 $(Get-Item G:selfUpdater.ps1).CreationTimeUtc = [DateTime]::UtcNow &G:selfUpdater.ps1 exit } Write-Host "Continuing original script; will not get here if we updated." Note that, if you have parameters to pass around, you'll have to pass them to the target script. Since your updated script may well have more or fewer parameters than your current script (some bound, some unbound by the current script), you'll need to iterate through

Categories : Powershell

Why will Qt not create a text file when running or debugging from inside Qt, but will create it when directly from the debug folder?
You probably used a relative path, and inside QtCreator the "current directory" from where the executable is ran is not necessarily the directory where the executable is. Try: qDebug() << QDir::currentPath(); It will tell you where you should expect your file to be written.

Categories : C++

Why method now in Python is obtained as datetime.datetime.now instead of datetime.time.now?
"Now" is a point in time. That means date matters; if it's noon now, yesterday noon is not also now. (Time of day also matters; 9 AM today is also not now.) Thus, it makes sense to have a datetime.datetime.now, but not a datetime.time.now. It could make sense to have a datetime.time.currentlocaltime or datetime.time.currentutctime, but those methods don't exist. You could put in a feature request if you want.

Categories : Python

Check if there are any running processes in the current tab of terminal
One simple solution would be to take each command that you're running in a terminal and append "; exit" (Without the quotes) to it. For example, if one of your commands was "ls", you would change it to "ls; exit". Unfortunately, this doesn't work if you want to leave the terminal windows up to see results of what's being displayed. That can be solved by outputting the results of the first commands to some file, though. Again using the example of ls, you could run "ls >> testfile.txt; exit" to output the results of ls to a file, and then have the terminal window close after it finishes executing.

Categories : Shell

how to get systemc sc_module_name of current running module
Don't use the built-in macro for the constructor. Use the following, assuming that module name is "counter": counter(sc_module_name _name):sc_module(_name) { cout << "Creating object " << _name; } You can do various things with _name after you include <string>. You can use string(), concatenate with the + operator, etc.

Categories : C++

how to get path to ruby.exe that is running current script on windows?
You may take a look at rubinius configure(build_ruby) So, currently it looks as follows: require 'rbconfig' def build_ruby unless @build_ruby bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"] bin += (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '') @build_ruby = File.join(RbConfig::CONFIG['bindir'], bin) end @build_ruby end I also tried the following: require 'rbconfig' File.join( RbConfig::CONFIG['bindir'], RbConfig::CONFIG['RUBY_INSTALL_NAME'] + RbConfig::CONFIG['EXEEXT'] ) It works for me just as good.

Categories : Ruby

Get Class in which current test case is running in Junit
To get class name use @Test public void setUp() throws Exception Class clazz = this.getClass(); //if you want to get Class object String name = clazz.getCanonicalName(); //you want to get only class name }

Categories : Java

Moment js create datetime in certain timezone
Assuming you are talking about moment-timezone, this does not currently exist in the 0.0.1 release, but has been requested. There is a pending pull request, but it has not yet been merged because there is still some lacking functionality. So you can go try adding that PR manually, or you can wait until it is stable. You might also consider using one of the other time zone libraries instead.

Categories : Javascript

Python interactive shell running copy.py on current directory?
When Python imports a module, the module search path order is: the directory containing the input script (or the current directory). PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH). the installation-dependent default. Now, when raising an exception, Python runs specific code. Any code that tries to import the copy Python module will instead import your module and print the string in it. This is why you shouldn't use names that are also names of standard Python modules.

Categories : Python

how to create datetime from a negative epoch in Python
This works for me: datetime.datetime(1970, 1, 1) + datetime.timedelta(seconds=(-3739996800000/1000)) → datetime.datetime(1851, 6, 27, 0, 0) This would have been better asked on StackOverflow since it is more Python specific than it is GIS-specific.

Categories : Python

create datetime irrespective of system date
The date/time is stored in a particular format regardless of the system locality. Only the the output is affected by the locality. Regardless of how it "looks" you can always change the output using the ToString method And the various formats You can even implement a global cultureinfo to apply which may be what you're looking for

Categories : C#

How to create datetime object from "16SEP2012" in python
Use datetime.datetime.strptime: >>> datetime.datetime.strptime('16Sep2012', '%d%b%Y') datetime.datetime(2012, 9, 16, 0, 0)

Categories : Python

CakePHP 1.3 - create() not setting created datetime?
created DEFAULT NULL CakePHP will only populate created if it is defined as NULL: By defining a created and/or modified field in your database table as datetime fields (default null), CakePHP will recognize those fields and populate them automatically whenever a record is created ...

Categories : PHP

running multiple process in current shell (using {} ) with atleast one command to be run as background
As & is a valid command delimiter, there is no need for ;. { echo "42" & sleep 3; }

Categories : Bash

Error while running a batch with a file as parameter that does not belong to the current directory
Well, the use of %~f1 does NOT guarantee that the file exists! If the parameter given to the Batch file includes the full path, then %~f1 just return the same information and does not check for the existence of the file. I suggest you to test the Batch file below: @ echo off echo "%~f1" if exist "%~f1" ( findstr /r "I.*=" "%~f1" >outer.TXT ) else ( echo File does NOT exist! )

Categories : Batch File

Running a subprocess bash script from Python in the scripts current directory
Yep, Just before your loop programitically save the current working directory and change the current working directory to /some%s before the subprocess.call and then set it back to the original value when you are done. import os Orig = os.path.abspath('.') for i in range(1,100): os.chdir('/some%s' % i) subprocess.call(['./task.sh' % i, arg1]) os.chdir(Orig)

Categories : Python

Unable to bind to port 80, but running on the current shell works without any issues
you need root access to bind to lower ports like port 80. rvmsudo executes in root context and therefore it works. cap task executes in a normal user context (probably deploy) depending on your configuration. you should add sudo ability to cap deploy user and make sure your cap task uses sudo to start unicorn.

Categories : Ruby On Rails



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