w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Current Month and Year in Subject for Automated Batch Job E-mail
Just use the date function: $lastMonth = date('m-Y',strtotime('last month')); $email_subject = "($lastMonth) Report for MS-SQL."; If you want yesterday: $yesterday = date('m-d-Y',strtotime('yesterday')); // Change format as needed

Categories : PHP

phing - delete directory contents without directory itself
I have just tried it myself and the same code would not delete the include folder. Only way to make it do so was to set the includeemptydirs to true. Maybe it's a version problem, but still, I would try calling it like this: <delete> <fileset dir="folder" casesensitive="false" includeemptydirs="false"> <exclude name="excluded.php"/> </fileset> </delete>

Categories : PHP

Sencha Touch 2: recursive message boxes
Make your call a function, and call that function as the callback if the email is not valid: function showPrompt() { Ext.Msg.prompt( 'My Title', //The title bar text 'This is the first message', //The message box body text function (btn, text) { if (btn == 'ok') { if (showAlert(text)) { Ext.Msg.alert('', 'Please, fix it', showPrompt); } else { //do something useful } } }, //some more params ); }

Categories : Javascript

How to change the current working directory to a specific directory and execute a program under the specific directory?
One of your principal problems is that you don't capture the return value (output) of the command in backticks. You are merely throwing away the output you want. Do something like: my $output = `perl ./script.pl` system("perl ./script.pl")

Categories : Perl

Python joining current directory and parent directory with os.path.join
You can use normpath, realpath or abspath: import os goal_dir = os.path.join(os.getcwd(), "../../my_dir") print goal_dir # prints C:/here/I/am/../../my_dir print os.path.normpath(goal_dir) # prints C:/here/my_dir print os.path.realpath(goal_dir) # prints C:/here/my_dir print os.path.abspath(goal_dir) # prints C:/here/my_dir

Categories : Python

border-radius doesn't quite touch div contents
You can resolve this by removing the border, since you have a black border on a black background you can't see where one starts and the other ends! .round_box { /* border: 2px solid #333; REMOVE THIS */ -webkit-border-radius: 10px; -moz-border-radius: 10px; -ms-border-radius: 10px; -o-border-radius: 10px; border-radius: 10px; overflow: hidden; margin-bottom: 10px; } .round_box .title_bar { background: #333; color: #fff; font-weight: bold; padding: 7px; } Working version

Categories : CSS

After I deleted a directory, it always prompts "shell-init error retrieving current directory getcwd solve" when log on bash
When opening a new shell or xterm, it's started in the working directory of the process that started it. If you e.g. cd /proc && xterm, the new terminal will place you in /proc. Whatever's starting your terminal had positioned itself in /home/desktop/zeno, and now all the terminals are trying to start there. If you make that process change directory (by rebooting, for example), the terminals will start in a directory that exists and you will no longer get this error.

Categories : Linux

Sencha Touch 2 Tab Panel: Contents in other tabs are in the wrong place
Try not to set the activeItem in the list. Add to the launch method the following line: Ext.Viewport.down('.tabpanel').setActiveItem(1); That way it works.

Categories : Extjs

How to print the name of my current directory's parent directory
You can use ${PWD%/*}: $ echo $PWD /home/me/test/t $ echo ${PWD%/*} /home/me/test As the expression ${string%substring} Strips shortest match of $substring from back of $string (reference).

Categories : Shell

Cancel current UIScrollView touch
Try disabling the panGestureRecognizer for the scroll view (and then reenabling it). This will cancel the current session of the recogniser: self.scrollView.panGestureRecognizer.enabled = NO; self.scrollView.panGestureRecognizer.enabled = YES;

Categories : IOS

Adding an indicator at the current touch position?
Well, you definitely 'can' add a crosshair at your current touch position. I can tell you one of the many possible ways of doing this. Implement the - (IBAction)handlePan:(UIPanGestureRecognizer *)recognizer action handler. Load an image of a crosshair into an UIImage (say overlayImage): overlayImage =[UIImage imageNamed:@"crosshair.png"]; and set it into an UIView (say overlayView). [This can be done in your viewDidLoad method itself.] Now, add the following code to your handlePan method: CGPoint translation = [recognizer translationInView:colorView]; //whichever view you want. _overlayView.center = CGPointMake(_overlayView.center.x + translation.x, _overlayView.center.y + translation.y); [recognizer setTranslation:CGPointMake(0, 0) inV

Categories : IOS

Delete current node in recursive ng-repeat
Try this: http://jsfiddle.net/dzpGY/ You were close, it is $parent.data.nodes but, you can not put that into $scope.delete since this methods $scope would refer to the tree's root $scope, and you want to refer to the leafs parent. You can create a separate controller for each leaf of ng-repeat and put a delete() method there.

Categories : Angularjs

Get the current directory name via php script in another directory
I am not 100% sure of your questions, but it sounds like you are looking for the URL/Directory of the page you are currently on, not the directory of the header? What about: $_SERVER['PHP_SELF']; $_SERVER['REQUEST_URI']; $_SERVER['SCRIPT_NAME']; $_SERVER['SCRIPT_FILENAME']; $_SERVER['DOCUMENT_ROOT']; Those all give info about the current file open by the server based on the HTTP request it received.

Categories : PHP

C Recursive Directory copy of sub folders
It looks like it's failing to insert the directory separator character (/) between the base directory and the appended part. Assuming name = "/home/foo/bar", EndPtr will point at the '' at the end, and then e->d_name is copied there, without anything in-between. This is wrong, it will create a mashed-up filename.

Categories : C

Add recursive command to set sub directory permissions in C#
First, if your target framework is 4.0, recommend that you use the Directory.EnumerateFiles method (you can also find 3rd code that does the same thing.) Assuming this is a no-go, you can simplify your recursive processing by using the yield keyword, e.g. make a traverse method based on yield -- I'm showing this with a filter function to since it would often be useful in directory traversal ad should give you ideas. static IEnumerable<string> traverse(string path, Func<string, bool> filter) { foreach (string f in Directory.GetFiles(path).Where(filter)) { yield return f; } foreach (string d in Directory.GetDirectories(path)) { foreach (string f in traverse(d, filter)) { yield return f; } } } Then you use tr

Categories : C#

How to get direction of place wherever we touch in map from current location in Android
try this try { Intent directioIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr=" + strSourceLatitude + "," + strSourceLongitude + "&daddr=" + strDestinationLatitude + "," + strDestinationLongitude)); directioIntent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); startActivity(directioIntent); } catch (Exception e) { Utilities.showToast(GetDirectionActivity.this, "Google Map is not installed on your device."); }

Categories : Android

Recursive directory processing in a BAT file with a twist
For a) question: FOR /F "TOKENS=*" %%d IN ('DIR ABCXYZ /S /AD /B') DO SET variable=%%d For a) and b) question: FOR /D /R "ABC" %%d IN (*.*) DO IF /I "%%~nxd"=="XYZ" (SET variable=%%d& GOTO :EOF) but this will exit batch script, so you need: ... your batch code CALL :GET_XYZ ... your batch code GOTO :EOF :GET_XYZ FOR /D /R "ABC" %%d IN (*.*) DO IF /I "%%~nxd"=="XYZ" (SET variable=%%d& GOTO :EOF) ECHO XYZ not found! GOTO :EOF

Categories : Windows

PHP Recursive Directory Iterator - ignore certain files.
Add a filter layer between RecursiveIteratorIterator and RecursiveDirectoryIterator: Create a RecursiveFilterIterator and code the accept() function that returns true if you want the element to be in the result. Put the directory iterator into the filter iterator, put the filter iterator in the RecursiveIteratorIterator. Iterate. There is no predefined SKIP constant for such special cases as "__MACOSX" directories.

Categories : PHP

Cocoa contents of directory
Lets just take 1 of your 3: [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"directoryName" error:nil] You should include the error parameter and check what it contains You need to supply a full path, not just a "directoryName" As a result you'll get an array containing the file names of the files in the directory So if you want the full path you can do: NSString *directoryPath = ...; NSArray *fileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:...]; for(NSString *fileName in fileNames) { NSLog(@"%@", [directoryPath stringByAppendingPathComponent:fileName]); }

Categories : Objective C

Is there a way to read contents of a directory from web app
You cannot access file system of user machine from pure web application. This task can be implemented using trusted applet or java application executed via java web start or trusted flash component or other native component (browser plugin). Applets are almost obsolete and require JVM on client side. Java web start still requires JVM. All signed components (java based, flash, native code) require user approval. I think that better and more modern way is to use a great feature of HTML 5 that allows not navigation to specific location on disk (that was possible since HTML 1.0) but also selecting a full directory. Take a look on the following discussion for details: Does HTML5 allow drag-drop upload of folders or a folder tree?

Categories : Java

PHP Zip: Extract contents of a directory
I managed to get it to work by working with file streams manually instead of using extractTo(). The script extracts all the files in the base of the archive and all the files in directories in the base of the archive in to the output folder. For example, if this is the archives contents: - d0001 - My Folder - view.php - tasks.txt - file1.txt - picture1.png - document.doc - d2 - another1.png - pic2.gif - doc1.txt - mylist.txt The contents of the output directory will look like this: - My Folder - view.php - tasks.txt - file1.txt - picture1.png - document.doc - another1.png - pic.gif - doc1.txt - mylist.txt The code: function rrmdir($dir, $removebase = true) { if(is_dir($dir)) { $objects = scandir($dir); foreach($objects as $object) {

Categories : PHP

How to add the contents of a directory to a zip file?
Python's zipfile module allows you to manipular ZIP compressed archives. The ZipFile.namelist() method returns a list of files in an archive, and the ZipFile.write() method lets you add files to the archive. z = zipfile.ZipFile('myfile.zip') The os.walk method allows you to iterate over all the files contained in a directory tree. for root, dirs, files in os.walk('mydir'): for filename in files: z.write(os.path.join(root, filename)) Replacing a file in an archive appears to be tricky; you can removed items by creating a temporary archive and then replacing the original when you're done as described in this question. It might be easier just to call the zip command instead, but put these together and you should be able to get to where you want.

Categories : Python

How to find ASP.NET DataGrid current cell contents
Found the answer: You can use the click event hanlder of the DataGrid which has the paramter e As DataGridCommandEventArgs. Sub MYGrid_Click(ByVal Src As Object, ByVal e As DataGridCommandEventArgs) e contains data about the row which was clicked. For example to find data for the 3rd cell in the clicked row you can use this: Item.Cells(2).Text it is a Bound Column(assuming)

Categories : C#

How to get recursive directory path using inotify-tools in terminal
Use the %w modifier: inotifywait -m -r --format '%w%f' ....... To pass the output of inotifywait as an argument to a php script, which will read it for the argv variable you could do this: inotifywait -m -r --format '%w%f' ....... | while read -r line do php script.php "$line" done Otherwise, if you want the php script to read the output of inotifywait from the standard input, then you can just pipe to your script: inotifywait -m -r --format '%w%f' ....... | php script.php

Categories : PHP

Cannot see contents of directory with local Apache
Have you added the directive in Apache2.2confhttpd.conf <Directory "C:ApacheHtDoc"> Options Indexes FollowSymLinks Order Allow,Deny Allow from All </Directory> If you haven't, add that and restart apache. Edit Path for the httpd.conf may vary according to your install.

Categories : Windows

Open folder contents into directory above
I will give you a hint. Use php file_get_contents('file_dir') to read the file into a string Use php file_put_contents('file_dir') to create the file Also use php unlink('file_dir') function to delete a file if necessary If you need to remove directory, use php rmdir() function. If you do not need to access the files, you can just use php copy($source, $dest) function to copy your files from one directory to another. Then you can delete them from old directory.

Categories : PHP

Get current x and y co-ordinates of touch (if the user is touching) every 20 milliseconds - Timers, Schedulers?
final TextView xCoord = (TextView) findViewById(R.id.textView1); final TextView yCoord = (TextView) findViewById(R.id.textView2); final View touchView = findViewById(R.id.textView3); touchView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { final int action = event.getAction(); switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: { xCoord.setText(String.valueOf((int) event.getX())); yCoord.setText(String.valueOf((int) event.getY())); break; } case MotionEvent.ACTION_MOVE:{ xCoord.setText(String.valueOf((int) event.getX())); yCoord.setText(String.valueOf((int) event.getY())); break; } } return true; } });

Categories : Android

PHP FILES Recursive backup of directories, deleting main directory
As shown from your function-output, the directories are not empty. I suppose that the data is of low value and just needs to be backed up. I assume you are running Linux from your choice of a slash rather than a backslash. Naturally directories incur links or inodes, with metadata, which in linux can be checked via df -hi The Inode-Ids of files can be shown via the -i flag of ls ls -i filename ls -iltr ls -ltri `echo $HOME` Inodes take up space, and introduce overhead in file-system operations. So much to the motivation to remove the directories. PHP's rmdir function to remove directories requires that The directory must be empty, and the relevant permissions must permit this. It is also non-recursive. Approach 1: flatten filenames and move the files to a backup directory, t

Categories : PHP

Non recursive makefile for manu sources directories with flat .obj directory
Simply include a makefile that create explicit dependencies: # Makefile OBJ_DIR:=objects SRC_FILES := $(notdir $(SRCS)) all: $(SRC_FILES:%.c=$(OBJ_DIR)/%.o) tmp_srcs := $(SRCS) include $(foreach dummy, $(SRCS), object_rule.mk) $(OBJ_DIR)/.sentinel: mkdir -p $(dir $@) && touch $@ The trick is in the combination of the include statement and a foreach. The foreach will generate as many "object_rule.mk" as there are files listed in SRCS. The included makefile, object_rule.mk simply generates the object rule for the corresponding source file like this: ifeq (,$(tmp_srcs)) $(error this makefile requires the variable tmp_srcs to be set) endif src_path:=$(word 1, $(tmp_srcs)) ifeq (1, $(words $(tmp_srcs))) tmp_srcs:= else tmp_srcs:=$(wordlist 2, $(words $(tmp_srcs)), $(tmp_src

Categories : C

Delete all files from a directory except for folder and it's contents
The problem is the way in which the recursive function calls are done: the main function private static void WalkDirectory(DirectoryInfo directory) deletes all files and is called every time (even while analysing a subdirectory). Here you have a fix to make this code work as you wish: private static void WalkDirectory(DirectoryInfo directory) { if (directory.Name.ToLower() != "data") { // Scan all files in the current path foreach (FileInfo file in directory.GetFiles()) { file.Attributes &= ~FileAttributes.ReadOnly; var name = file.Name; name = name.ToLower(); if (name != "test.txt") { file.Delete(); } } DirectoryInfo[] subDire

Categories : C#

Invalid project contents directory error
After using chown command on my www folder recursively, the problem was gone. I think the problem was that eclipse can't create new files inside those folders. (Duh!) So: sudo chown -R /var/www user:group

Categories : PHP

Powershell download entire directory contents
Unless PowerShell is a requirement, using wget would be an easier way to mirror something like that: wget --mirror --no-parent --accept=tif http://gisdata.nd.gov/NAIP/2012/zGeoTiffs/

Categories : Powershell

Reading directory contents in variable in qshell
There is no need to use arrays here. Just use the output of ls ls -1 /user/test | grep -v '^d' | while read i do echo "$i" done

Categories : Unix

Prevent users accessing image directory contents
How about instead of storing your cached images within the actual site structure as static content fed by IIS, you store the images in a path outside the site. That would ensure no unauthorized user could access them directly. Then you can provide access to those images through a Controller (UserImagesController maybe) Action that can validate that the image being requested is one to which the current user has access. Your check might end up being as simple as checking the requested UserName parameter of the action is the same as your current user's UserName. With this approach you can also control the cache headers, expiration, etc, of those images.

Categories : Asp Net Mvc

NSFileManager list directory contents excluding directories
You can go a little deeper with a directory enumerator. How about this? NSDirectoryEnumerator *dirEnumerator = [localFileManager enumeratorAtURL:directoryToScan includingPropertiesForKeys:[NSArray arrayWithObjects:NSURLNameKey, NSURLIsDirectoryKey,nil] options:NSDirectoryEnumerationSkipsSubdirectoryDescendants errorHandler:nil]; NSMutableArray *theArray=[NSMutableArray array]; for (NSURL *theURL in dirEnumerator) { // Retrieve the file name. From NSURLNameKey, cached during the enumeration. NSString *fileName; [theURL getResourceValue:&fileName forKey:NSURLNameKey error:NULL]; // Retrieve whether a directory. From NSURLIsDirectoryKey, also // cached during the enumeration. NSNumber *isDirectory; [theURL getResourceValue:&isDirectory forKey:NSURL

Categories : Objective C

Compare directory contents to database column in Joomla
You problem is that in if(stripos($result, $file)), $result is an array, not a string. Turn on error reporting in the Joomla Configuration to see this. You should be seeing a message like: Warning: stripos() expects parameter 1 to be string However, I recommend the following change as it is a bit cleaner: $dir = 'directory/of/files'; $files1 = scandir($dir); $db = JFactory::getDBO(); $query = "SELECT image FROM #__tablename WHERE something LIKE 'something else'"; $db->setQuery($query); $result = $db->loadResultArray(); $diff = array_diff($files1, $result); // print_r($diff);die; foreach ( $diff as $file ) { unlink($dir.$file); } Uncomment the print_r first to check it is what you want.

Categories : PHP

PHP Directory Contents - Count error & strip certain files
They are . and .. directories. You can not see them because substr("$dirArray[$index]", 0, 1) != "." returns false for them. In while loop you can filter them, or you can just unset first two elements of $dirArray.

Categories : PHP

Is it possible to transfer the contents of a whole directory using the built in Ruby Net::FTP class?
First, get all files and subdirectories in your directory: entries = Dir.glob('my_dir/**/*').sort (sort is required to ensure that every directory goes before its files) Now you can upload all files and create all subdirectories: Net::FTP.open(ftp_server, username, password) do |ftp| entries.each do |name| if File::directory? name ftp.mkdir name else File.open(name) { |file| ftp.putbinaryfile(file, name) } end end end I had no time to test this, so I could miss something.

Categories : Ruby

Populate Listbox with directory contents but only accept certain extensions
You should create a for loop, test your extension, and then add it or not... Something like; Dim AllowedExtension As String = "mp3 mp4" For Each file As String In IO.Directory.GetFiles("c:", "*.*") If AllowedExtension.Contains(IO.Path.GetExtension(file).ToLower) Then listbox1.items.add(file) End If Next Or even more dirty; IO.Directory.GetFiles(path, "*.mp*") Or do it twice; add ListBox1.Items.AddRange(IO.Directory.GetFiles(path, "*.mp3*")) and ListBox1.Items.AddRange(IO.Directory.GetFiles(path, "*.mp4*"))

Categories : Vb.Net

Iterating a DirectoryStream and changing contents of a directory at the same time
The documentation is intentionally vague. The JVM has to run on a number of different kinds of machines: Windows and Unix-derivatives. Different file systems have different behaviors. You must (I repeat, MUST) design for the worst case if you want your program to work reliably on more than one computer. The law of least surprise suggests that you should slurp up the entire DirectoryStream to get a snapshot (or very close to one), iterate over the snapshot, and then re-slurp the stream. You can then compare the different versions of the snapshots to determine changes to the underlying directory.

Categories : Java



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