Setting Windows PATH for Postgres tools

configuring postreSQL PATH variable on Windows 7 I encountered this issue too. I’m using Git Bash, hence the Unix-style $ prompt on Windows. $ rails db Couldn’t find database client: psql, psql.exe. Check your $PATH and try again. Here’s what I did: In Windows 7, navigate to: Control Panel All Control Panel Items System Advanced … Read more

PHP create random tmp file and get its full path

tmpfile returns a stream-able file pointer. To get the corresponding path, ask the stream for its meta data: $file = tmpfile(); $path = stream_get_meta_data($file)[‘uri’]; // eg: /tmp/phpFx0513a The benefit of the tmpfile approach? PHP automatically removes the $path when $file goes out of scope. With tempnam, you must manually remove the created file.

Get the first part of a url path

This will never throw an error because pathname always starts with a /, so the minimum length of the resulting array will be two after splitting: const firstPath = location.pathname.split(“https://stackoverflow.com/”)[1]; If we are at the domain root, the returned value will be an empty string ” const path = location.pathname.split(“https://stackoverflow.com/”); path = [ ”, ‘questions’, … Read more

What does __FILE__ mean?

The realpath() function gives you the file-system path, with any symbolic links and directory traversing (e.g. ../../) resolved. The dirname() function gives you just the directory, not the file within it. __FILE__ is a magic constant that gives you the filesystem path to the current .php file (the one that __FILE__ is in, not the … Read more

How to fill a Path in Android with a linear gradient?

While steelbytes’ answer will probably give you more control over the individual sections of the gradient, you can do it without the path: Paint m_Paint = new Paint(); protected void onDraw(Canvas canvas) { super.onDraw(canvas); // start at 0,0 and go to 0,max to use a vertical // gradient the full height of the screen. m_Paint.setShader(new … Read more

Converting Relative Paths to Absolute Paths

If I get your problem right, you could do something like this: File a = new File(“/some/abs/path”); File parentFolder = new File(a.getParent()); File b = new File(parentFolder, “../some/relative/path”); String absolute = b.getCanonicalPath(); // may throw IOException

Verifying path equality with .Net

var path1 = Path.GetFullPath(@”c:\Some Dir\SOME FILE.XXX”); var path2 = Path.GetFullPath(@”C:\\\SOME DIR\subdir\..\some file.xxx”); // outputs true Console.WriteLine(“{0} == {1} ? {2}”, path1, path2, string.Equals(path1, path2, StringComparison.OrdinalIgnoreCase)); Ignoring case is only a good idea on Windows. You can use FileInfo.FullName in a similar fashion, but Path will work with both files and directories. Not sure about your … Read more