Creating a thread-safe temporary file name

Dir::Tmpname.create You could use Dir::Tmpname.create. It figures out what temporary directory to use (unless you pass it a directory). It’s a little ugly to use given that it expects a block: require ‘tmpdir’ # => true Dir::Tmpname.create([‘prefix-‘, ‘.ext’]) {} # => “/tmp/prefix-20190827-1-87n9iu.ext” Dir::Tmpname.create([‘prefix-‘, ‘.ext’], ‘/my/custom/directory’) {} # => “/my/custom/directory/prefix-20190827-1-11x2u0h.ext” The block is there for code … Read more

MySQL – Select from a list of numbers those without a counterpart in the id field of a table

This is a problem that is pretty common: generating a relation on the fly without creating a table. SQL solutions for this problem are pretty awkward. One example using a derived table: SELECT n.id FROM (SELECT 2 AS id UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7) AS … Read more

Where is the temp folder on Android devices?

The temporary directory is /data/local/tmp. I’ve seen some comments that claim you need to be rooted to access it but I’m not sure that’s true. Whilst it is true that you need root to freely access /data, this is not required for /data/local/tmp. I have verified this on Android 5.1.1.

How to remove tmp directory files of an ios app?

Yes. This method works well: + (void)clearTmpDirectory { NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL]; for (NSString *file in tmpDirectory) { [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@”%@%@”, NSTemporaryDirectory(), file] error:NULL]; } }

tempfile.TemporaryDirectory context manager in Python 2.7

Another option is the “backports.tempfile” package on pypi: https://pypi.python.org/pypi/backports.tempfile Quoting the project’s description: “This package provides backports of new features in Python’s tempfile module under the backports namespace.” Install with: pip install backports.tempfile Then use it in your script: from backports import tempfile with tempfile.TemporaryDirectory() as temp_dir: # modify files in this dir # here … Read more

php:: how long to tmp files stay?

Files uploaded through POST are deleted right after php script finishes its execution. According to php.net: “The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.”

Environment variable to control java.io.tmpdir?

According to the java.io.File Java Docs The default temporary-file directory is specified by the system property java.io.tmpdir. On UNIX systems the default value of this property is typically “/tmp” or “/var/tmp”; on Microsoft Windows systems it is typically “c:\temp”. A different value may be given to this system property when the Java virtual machine is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)