Posts Tagged ‘programming’
Java: Determine if String is a URL/URI or file
public boolean isLocalFile(String file) {
try {
new URL(file);
return false;
} catch (MalformedURLException e) {
return true;
}}
- Make sure the filename is correct (proper capitalization, matching extension etc – as already suggested).
- Use the
Class.getResource
method to locate your file in the classpath – don’t rely on the current directory:URL url = insertionSort.class.getResource("10_Random"); File file = new File(url.toURI());
- Specify the absolute file path via command-line arguments:
File file = new File(args[0]);
In Eclipse:
- Choose “Run configurations”
- Go to the “Arguments” tab
- Put your “c:/Users/HackR/somewhere/10_myjava.txt.or.something” into the “Program arguments” section
Software Sec: C / C++ Buffer overflows and Robert Morris
- over-read or over-write
- could be during iteration (running off the end), or direct access (pointer arithmetic)
- this is a general definition; some people use more specific definitions of differing types of buffer overflows
A buffer overflow is a bug that affects low-level code, typically C and C++ with significant sec implications
- dump/steal information
- corrupt information
- run code (payload)
- OS Kernels
- embedded systems
- HPC servers
Loaders and Linkers
A linker or link editor is a computer program that takes one or more object files generated by a compiler and combines them into a single executable file, library file, or another object file.
A loader is the part of an operating system that is responsible for loading programs and libraries. It is one of the essential stages in the process of starting a program, as it places programs into memory and prepares them for execution. Loading a program involves reading the contents of the executable file containing the program instructions into memory, and then carrying out other required preparatory tasks to prepare the executable for running. Once loading is complete, the operating system starts the program by passing control to the loaded program code.
All operating systems that support program loading have loaders, apart from highly specialized computer systems that only have a fixed set of specialized programs. Embedded systems typically do not have loaders, and instead the code executes directly from ROM. In order to load the operating system itself, as part of booting, a specialized boot loaderis used. In many operating systems the loader is permanently resident in memory, although some operating systems that support virtual memory may allow the loader to be located in a region of memory that is pageable.
In the case of operating systems that support virtual memory, the loader may not actually copy the contents of executable files into memory, but rather may simply declare to the virtual memory subsystem that there is a mapping between a region of memory allocated to contain the running program’s code and the contents of the associated executable file. (See memory-mapped file.) The virtual memory subsystem is then made aware that pages with that region of memory need to be filled on demand if and when program execution actually hits those areas of unfilled memory. This may mean parts of a program’s code are not actually copied into memory until they are actually used, and unused code may never be loaded into memory at all.
http://en.wikipedia.org/wiki/Loader_(computing)
C Primer Plus
C: C v. C++, Object Orientation
C++ graphs object oriented programming* tools to the C language
C: Virtues and Shortcoming of C
Virtues
- Powerful control structures
- Fast (and efficient, like an assembly language)
- Compact code (small programs)
- Portable (moreso than other languages)
Shortcomings
- Use of pointers — errors are hard to trace
- Can be difficult to follow
C: Dennis Ritchie, history of C
C was created by Dennis Ritchie of Bell Labs in 1972, while Ritchie worked with Ken Thompson on designing Unix.
2 Problems with Inductive Logic Programming
Inductive Logic Programming (ILP), Link Discovery (LD), Evidence Extraction and Link Discovery (EELD)
Inductive logic programming (ILP) is a subfield of machine learning which uses logic programming as a uniform representation for examples, background knowledge and hypotheses. Given an encoding of the known background knowledge and a set of examples represented as a logical database of facts, an ILP system will derive a hypothesised logic program which entails all the positive and none of the negative examples.
Schema: positive examples + negative examples + background knowledge => hypothesis.
Inductive logic programming is particularly useful in bioinformatics and natural language processing. Ehud Shapiro laid the theoretical foundation for inductive logic programming[1][2] and built its first implementation (Model Inference System) in 1981:[3] a Prolog program that inductively inferred logic programs from positive and negative examples. The term Inductive Logic Programming was first introduced[4] in a paper by Stephen Muggleton in 1991.[5] The term “inductive” here refers to philosophical (i.e. suggesting a theory to explain observed facts) rather than mathematical (i.e. proving a property for all members of a well-ordered set) induction.
http://www.cs.utexas.edu/~ml/papers/ld-bkchapter-04.pdf
Introduction to the Stack
The stack stores information about how a function is called, the parameters it takes, and how it should return after it is finished executing.