Skip to main content
10 votes
Accepted

Skipping over failed imports until they are needed (if ever)

There is one issue with your approach which is, in the case of multiple import failure, only the last one can be properly reported: ...
301_Moved_Permanently's user avatar
8 votes
Accepted

Dynamically loading CSS files based on URL or URI in PHP

Most of questions you are asking are not fit for this site and your code does not work as intended but this is an interesting case to review The grave mistake Adding anything to your code just in case ...
Your Common Sense's user avatar
7 votes

Skipping over failed imports until they are needed (if ever)

That's an odd use of the word "default", which, etymologically speaking, means to remove failure, and generally refers to a fallback setting that "just works". I suggest calling it ...
200_success's user avatar
7 votes

Skipping over failed imports until they are needed (if ever)

This answer builds upon the solution presented by Mathias Ettinger If you want to get rid of the try: ... except: ... boilerplate you could implement some kind of ...
AlexV's user avatar
  • 7,278
6 votes

Skipping over failed imports until they are needed (if ever)

Whenever you find yourself trying to replace a standard language feature, the first thing you should think is, There's probably something I'm missing. What's the standard approach to this kind of ...
jpmc26's user avatar
  • 1,233
5 votes

Dynamically loading CSS files based on URL or URI in PHP

Your current battery of if conditions needs a re-think. $_SERVER['PHP_SELF'] -- as long as it has a non-falsey value will evauate to ...
mickmackusa's user avatar
  • 8,694
5 votes
Accepted

Accessing multiple dynamic libraries with the same extern C methods

The code looks correct. It looks like a weird mix of C and C++ though. Assumptions There was a statement that they share the same base class, but I am not sure what it means if they all use C style ...
Incomputable's user avatar
  • 9,589
4 votes

Script to load other .js scripts

few suggestions... I would lose the jQuery part and stick to vanilla js for several reasons jQuery's getScript doesn't add a script to the page like your vanilla ...
I wrestled a bear once.'s user avatar
4 votes

Code to fill PE import address table

; // https://artfulcode.wordpress.com/ ; // https://github.com/cmovz/ ; // License: use it as you wish, just keep this notice. No liability taken. The comments ...
Harith's user avatar
  • 9,807
4 votes

Making a graph of the import structure of a program

If a Python module contains no imports, then the code in the post fails with an error like this: ...
Gareth Rees's user avatar
  • 49.7k
4 votes

Accessing multiple dynamic libraries with the same extern C methods

...
JDługosz's user avatar
  • 11.3k
3 votes
Accepted

Efficient, typesafe runtime selection between "compiler-checked" sets of static config constant

Using class inheritance You can use class inheritance, the constants do inherit. I don't think the boilerplate is that much compared to the constexpr variable approach with designated initializer. It ...
G. Sliepen's user avatar
  • 61.7k
3 votes

Importing modules for private use in Python

NO This is not pythonic... and this is ugly... aaah, I can't get that code out of my head... There is this thing called __all__ 1. How does it work Make a list, put ...
Benoît P's user avatar
  • 799
3 votes

C++ DLL Injector

Compilation flags Please specify for which sets of compilation flags this code is expected to work (it will break if compiled with UNICODE defined, as described ...
hoffmale's user avatar
  • 6,508
3 votes
Accepted

Recursive autoloader to find PHP files

There are several ways to improve the code. Let's start with the constructor. You should not make any assumptions about the place of a file in the current file system, because that makes later ...
fuxia's user avatar
  • 230
3 votes
Accepted

Auto loading code

In order of most to least relevant. 1) There are lots of frameworks for PHP websites / apps and you should consider using one. People have written lots of code that you can take advantage of and won'...
ToXik-yogHurt's user avatar
3 votes

Dynamic module import in Python with exception handling

I mean I'm not a fan of it since it's basically just a list of statements to execute, but then again, the solution via globals and ...
ferada's user avatar
  • 11.1k
3 votes

Simple import system for a large shell program

I don't have enough reputation to comment, but I am rather intrigued by your script, because I also enjoy writing large programs in the shell, and recently have been trying write modular shell scripts....
Shellz's user avatar
  • 61
3 votes

List all classes in a package directory

The limitations of using the __subclasses()__ approach are: You need to load the classes (i.e. have them imported), otherwise it will not work. If you have ...
theQuestionMan's user avatar
3 votes

Import "izip" for different versions of Python

This is roughly twice as fast as using a try/except: import itertools zip = getattr(itertools, 'izip', zip)
Mike McKerns's user avatar
3 votes

Load modules conditionally Python

Sanitising your inputs with argparse As has already been mentioned in comments and @eikonomega’s answer, running arbitrary code from the user is generally dangerous. Using ...
alexwlchan's user avatar
  • 8,575
3 votes
Accepted

PHP autoloader that uses array of file paths

Efficiency, Efficiency, Efficiency! I don't know how big your applications are, but I wouldn't want to recursively scan all the files in my applications, every time a PHP script wants to execute. Want ...
KIKO Software's user avatar
3 votes

Script that uses an uploaded excel file to import data to the database

Some quick comments: The function checkURL is called in a loop, but inside that function you close the Curl connection every time. Instead you could speed up ...
Kate's user avatar
  • 7,588
3 votes
Accepted

Python preprocessor for pipes

Unused import sys as _INTERNAL_SYS is unused. You can delete this. slots Two of your classes define __slots__, where as three ...
AJNeufeld's user avatar
  • 34k
2 votes
Accepted

Dynamic loading of Javascript dependency graph

Your code is already good, but there are just a few things to note: You are not in control which order the browser will complete the loading of the scripts you have added to the DOM, that might be ...
Icepickle's user avatar
  • 825
2 votes

Dynamic loading of Javascript dependency graph

I have JavaScript module for loading dynamically script files by dependency graph: But... why? There are libraries out there that already do this. Take for instance, RequireJS. Most libraries out ...
Joseph's user avatar
  • 25.2k
2 votes

Dynamically loading CSS files based on URL or URI in PHP

I wonder if you are asking the right question. I can't help but wonder where this code block could possibly run in order to make sense. I will have to assume a lot, so here we go: Why don't you ...
Neoan's user avatar
  • 29
2 votes

PHP Autoloader - For classes, traits and interfaces

First, I disagree with the comment of xReprisal about static. A Static method is a useful tool and spoiling it is a waste. However, you are also using a static field and it is not recommended (...
magallanes's user avatar
2 votes

PHP Autoloader - For classes, traits and interfaces

First of all you should use static methods and properties only when there is good reason to do so. Generally you should default to non-static. $path property can ...
xReprisal's user avatar
  • 331

Only top scored, non community-wiki answers of a minimum length are eligible