Answer by Hubro for Why isn't my Exception being caught by catch?
SolutionI neglected to specify use Exception; in the file containing the try/catch.PonderingI know it's intentional that each namespace in PHP should define its own Exception for many reasons, but I...
View ArticleAnswer by Hubro for Is there a Vim plugin for previewing markdown files?
I recently found a Chrome extension that makes Chrome able to properly open and display markdown files: Markdown preview (no longer available, you can use Markdown Preview Plus now).Then it was just a...
View ArticlePython/tkinter - How do I get the window size including borders on Windows?
I'm trying to position my window based on with width and height of the window. On Windows, the window size reported by wm_geometry, winfo_width and winfo_height is the size of the client area, i.e. the...
View ArticleIs there any documentation on the package.json file?
Here's an instance of the package.json file that express.js generates{"name": "packagename","version": "0.0.1","private": true,"dependencies": {"express": "2.5.5","stylus": "0.22.2" }}It's fairly...
View ArticleWhy are parentheses optional when using print in Python 2.7?
In Python 2.7 both the following will do the sameprint("Hello, World!") # Prints "Hello, World!"print "Hello, World!" # Prints "Hello, World!"However the following will notprint("Hello,", "World!") #...
View ArticleIs it possible to pass a Literal type to a function and have that function...
I'm trying to write a function for asserting that user input matches a defined Literal type.Basically, given:MyLiteral = Literal["foo", "bar"]I want to write a function that lets me do...
View ArticleSQL: MD5() vs hex()
SQLite doesn't have MD5 built in, so I'm considering using the hash function instead. I don't know much about hashing, but I can see that hash() output is numerical and of varying length while MD5()...
View ArticleHow can I have multiple sibling instances of the same top level fragment...
I am following this guide: https://relay.dev/docs/en/quick-start-guide#composing-fragmentsI am trying to create a higher level fragment container that queries data from the RootQuery:export const...
View ArticleDoes Python classes support events like other languages?
I'm working on my first Python project, and I'm already missing events in my classes. Perhaps it's not even called events in Python, but I would like to create "groups" in my classes to which function...
View ArticleAnswer by Hubro for Interpret as fixed string/literal and not regex using sed
If you're not opposed to Ruby or long lines, you could use this:alias replace='ruby -e "File.write(ARGV[0], File.read(ARGV[0]).gsub(ARGV[1]) { ARGV[2] })"'replace test3.txt abc defThis loads the whole...
View ArticleHow do I attach calculated properties or methods to collections in Astro?
I'm using Astro with strict type checking.I have a collection called "portfolio" and I have a couple of conventions for where images are stored for my portfolio. It goes something like:If...
View ArticleCan I redirect all output to /dev/null from within python?
I'm writing a Python script that'll fork a child process. The parent process should be able to write stuff like Started child at xxxxx, but the child process output should be redirected to /dev/null....
View ArticleHow do I save the current cursor position and load it later in Vimscript?
I've written a function for removing the excess white space in a file:let g:trim_whitespace = 1function! TrimWhitespace() if g:trim_whitespace normal :%s/\s\+$//e endifendfunctionThe issue is that the...
View ArticleCan you get the number of lines of code from a GitHub repository?
In a GitHub repository you can see “language statistics”, which displays the percentage of the project that’s written in a language. It doesn’t, however, display how many lines of code the project...
View ArticleIs it possible for a web server to respond to a HTTP request with an extended...
When you run PHP scripts in the console, all the standard output text from that script shows up in the console window while the script is running. Is it possible for a browser window to similarly...
View ArticleIs it possible to style a text input to fill the width of it's parent?
I have had this issue for years and I've seen similar questions before, but none of them have addressed the fact that when setting width: 100% on an element - paddings, margins and borders will...
View ArticleHow can I tell PHP to dump exceptions as raw text instead of HTML?
When I'm developing my REST API in PHP I'm working with application/json output, so when I get errors while testing in the browser they look like this:<b>Fatal error</b>: Uncaught exception...
View ArticleGet full package module name
For verbose debug messages in my application I'm using a function that returns a helpful prefix. Consider the following example:import inspectdef get_verbose_prefix():"""Returns an informative prefix...
View ArticleWhy doesn't parameter type "Dict[str, Union[str, int]]" accept value of type...
I have a type for a dictionary of variables passed to a template:VariablesDict = Dict[str, Union[int, float, str, None]]Basically, any dictionary where the keys are strings and the values are strings,...
View ArticleHow can I get Bottle to restart on file change?
I'm really enjoying Bottle so far, but the fact that I have to CTRL+C out of the server and restart it every time I make a code change is a big hit on my productivity. I've thought about using Watchdog...
View Article