I have an upload script that I need to check the file extension, then run separate functions based on that file extension.  Does anybody know what code I should use?  if (FILE EXTENSION == ???) { FUNCTION1 } else if { FUNCTION2 }
58941
I want to use a Track-Bar to change a Form's opacity. This is my code: decimal trans = trackBar1.Value / 5000; this.Opacity = trans;  When I build the application, it gives the following error:  Cannot implicitly convert type decimal to double   I have tried using trans and double, but then the Control doesn't work. This code worked fine in a past VB.NET project.
22444
Need help in adding another function using the below script. I would like to have a timestamp "start" and "end" on two different columns, whenever the other two separate columns are edited. Based on the below script, I could only have one time stamp, from one column which is the column 2 and time stamp on column 10.  function onEdit()  {  var s = SpreadsheetApp.getActiveSheet();  if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet    var x = s.getActiveCell();    if( x.getColumn() == 2 ) { //checks the column      var nextCell = x.offset(0, +8);      if( nextCell.getValue() === '' ) //is empty?        var time = new Date();      time = Utilities.formatDate(time, "GMT", "hh:mm");        nextCell.setValue(time);    };  }; }
3386
Is there a function to extract the extension from a filename?
84496
I would like to create a shell script that will check to make sure all files in a directory are image files.  We recently had an issue where a hacker was able to generate a file in a directory and mask it as a .jpg file. I would like to create a shell script to check all files in the directory to make sure they are real jpg, gif or png files.
111364
Some guy called one of my Snipplr submissions "crap" because I used if ($_SERVER['REQUEST_METHOD'] == 'POST') instead of if ($_POST)  Checking the request method seems more correct to me because that's what I really want to do. Is there some operational difference between the two or is this just a code clarity issue?
12947
In bash I often use for-loops such as the following  for file in *.type; do    sommecommand "$file";  done;   to perform an operation for all files matching *.type. If no file with this ending is found in the working directories the asterisk is not expanded and usually I will get an error message saying that somecommand didn't find the file. I can immediately think of several ways to avoid this error. But adding a conditional does not seem to be very elegant. Is there a short and clean way to achieve this?
75442
I have a directories with .MP3 files which I'd like to change the extensions to .mp3. What's the easiest way to do this? I'm think something along the lines of:  find /RootPath -type f -iname "*.mp3" -exec mv {} sed s/.*MP3/\1.mp3/ \;    ...though I know that isn't quite right. :) The substitution isn't correct and I'm not sure how to use both a mv and a sed command with -exec in find.  Would I need a bash script for this?
110498
That's it. If you want to document a function or a class, you put a string just after the definition. For instance:  def foo():     """This function does nothing."""     pass   But what about a module? How can I document what a file.py does?
42297
I am looking for a simple way to get a mime type where the file extension is incorrect or not given, something similar to  only in .Net.
8265
I have now seen 2 methods for determining if an argument has been passed to a JavaScript function. I'm wondering if one method is better than the other or if one is just bad to use?   function Test(argument1, argument2) {       if (Test.arguments.length == 1) argument2 = 'blah';        alert(argument2);  }   Test('test');   Or   function Test(argument1, argument2) {       argument2 = argument2 || 'blah';        alert(argument2);  }   Test('test');   As far as I can tell, they both result in the same thing, but I've only used the first one before in production.  Another Option as mentioned by :  function Test(argument1, argument2) {     if(argument2 === null) {         argument2 = 'blah';     }      alert(argument2); }   As per Juan's comment, it would be better to change Tom's suggestion to:  function Test(argument1, argument2) {     if(argument2 === undefined) {         argument2 = 'blah';     }      alert(argument2); }
31397
What can you do with the eval command? Why is it useful? Is it some kind of a built-in function in bash? There is no man page for it..
123777
What is the difference between the three functions and when to use them??
60361
I want a script to sleep unless a certain file is modifed/deleted (or a file created in a certain directory, or ...). Can this be achieved in some elegant way? The simplest thing that comes to my mind is a loop that sleeps for some time before checking the status again, but maybe there is a more elegant way?
30205
I want to check for empty arrays. Google gave me varied solutions but nothing worked. Maybe I am not applying them correctly.  Function GetBoiler(ByVal sFile As String) As String 'Email Signature     Dim fso As Object     Dim ts As Object     Set fso = CreateObject("Scripting.FileSystemObject")     Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)     GetBoiler = ts.ReadAll     ts.Close End Function  Dim FileNamesList As Variant, i As Integer ' activate the desired startfolder for the filesearch FileNamesList = CreateFileList("*.*", False) ' Returns File names ' performs the filesearch, includes any subfolders ' present the result ' If there are Signatures then populate SigString Range("A:A").ClearContents For i = 1 To UBound(FileNamesList)     Cells(i + 1, 1).Formula = FileNamesList(i) Next i  SigString = FileNamesList(3)  If Dir(SigString) &lt;&gt; "" Then     Signature = GetBoiler(SigString) Else     Signature = "" End If   Here if FileNamesList array is empty, GetBoiler(SigString) should not get called at all. When FileNamesList array is empty, SigString is also empty and this calls GetBoiler() function with empty string. I get an error at line   Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)   since sFile is empty. Any way to avoid that?
53046
I have files in a directory (/home/user/example) that I need to verify and match. Each file has a control and data file. I want to check if for each file there is a corresponding file of the other. For example, if example.ctl has a match with example.out or example.out has a corresponding file with example.ctl.   I had written a nested for loop and  with many if else statements. But this seemed to be far too complex for a basic check like this. I wanted to see if anyone had a better solution.   Example files in directory:  example.ctl example.out   example_1.ctl example_1.out   example_2.ctl example_2.out
31267
Is there a method in the System.IO namespace that checks the validity of a filename?  For example, C:\foo\bar would validate and :"~-* would not  Or a little trickier, X:\foo\bar would validate is there is an X: drive on the system, but wouldn't otherwise.  I suppose I could write such a method myself, but I'm more interested in a built-in one.
76432
On wikipedia, the article for  says:      For the .sh file extension type, see .   How about other unix shells?  I know that the   is used inside the file to indicate an interpreter for execution, but I wonder:    What are the pros and cons for files extensions vs no file extensions?