Compare commits
10 commits
2d6766f0bb
...
18e6cfbb11
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18e6cfbb11 | ||
| eb12c8f9cf | |||
|
|
787c1866e2 | ||
|
|
b0196162a9 | ||
|
|
fdbb99aeeb | ||
|
|
f09f508324 | ||
|
|
010ed93aaf | ||
|
|
6538e6034d | ||
|
|
e213617d4e | ||
|
|
2542c6b1c3 |
12 changed files with 128 additions and 32 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
# src-ed
|
# src-ed
|
||||||
Source code samples for various languages - hello name-your-language world!
|
Source code samples for various languages - hello "name-your-language" world!
|
||||||
|
|
||||||
|
|
||||||
|
The subdirectory "misc-tools" contains miscellaneous utilities that may
|
||||||
|
be of interest or help to a programmer.
|
||||||
|
|
||||||
|
|
|
||||||
33
forth/hello.fs
Executable file
33
forth/hello.fs
Executable file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#! /usr/bin/gforth
|
||||||
|
\
|
||||||
|
\ Sample Hello World! Forth script...
|
||||||
|
\
|
||||||
|
|
||||||
|
\ Define "verinfo"
|
||||||
|
: verinfo s" git describe --abbrev=7 --dirty --always --tags" system ;
|
||||||
|
|
||||||
|
\ Define "printargs"
|
||||||
|
: printargs
|
||||||
|
\ The argc variable contains the count of cmd line args
|
||||||
|
\ in gforth, so we put it's value (@) on the stack plus
|
||||||
|
\ the number one and test if the value is greater than one.
|
||||||
|
argc @ 1 > if
|
||||||
|
\ condition is true, so put the value of argc (@)
|
||||||
|
\ on the stack and the value one as the range of
|
||||||
|
\ our do loop - we don't pring arg 0 which is the
|
||||||
|
\ name of the program.
|
||||||
|
argc @ 1 do i arg type space loop cr
|
||||||
|
else
|
||||||
|
\ condition is false, so don't print anything
|
||||||
|
cr
|
||||||
|
then ;
|
||||||
|
|
||||||
|
|
||||||
|
\ Obligatory Hello World with some version info
|
||||||
|
.( Hello Forth World! Version: ) verinfo cr
|
||||||
|
|
||||||
|
|
||||||
|
\ Show list of command line arguments
|
||||||
|
.( Command line args: ) printargs
|
||||||
|
|
||||||
|
bye
|
||||||
12
misc-tools/what
Executable file
12
misc-tools/what
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# what - get SCCS identification information
|
||||||
|
#
|
||||||
|
# SCCS was the source code control system distributed
|
||||||
|
# with AT&T Unix System III and V.
|
||||||
|
#
|
||||||
|
for i in "$@";
|
||||||
|
do
|
||||||
|
echo "$i:"
|
||||||
|
strings "$i" | grep -e '@(#)' | sed 's/^.*[@][(][#][)]\(.*\)/ \1/'
|
||||||
|
done
|
||||||
|
|
@ -1,17 +1,24 @@
|
||||||
# Sample makefile to add version/compiler info via an extra
|
# Sample makefile to add version/compiler info via an extra
|
||||||
# object module linked to final binary.
|
# object module linked to final binary.
|
||||||
#
|
#
|
||||||
COMPILER_VER:=$(shell gcc --version)
|
CC=gcc
|
||||||
COMPILER_OPTS=-fopenmp
|
COMPILER_VER:=$(shell $(CC) --version)
|
||||||
|
CFLAGS=-fopenmp
|
||||||
|
LDFLAGS=
|
||||||
GIT_DESCRIBE:=$(shell git describe --abbrev=7 --dirty --always --tags --long)
|
GIT_DESCRIBE:=$(shell git describe --abbrev=7 --dirty --always --tags --long)
|
||||||
|
GIT_AUTHOR:=$(shell git --no-pager log -1 --pretty=format:"%an <%ae>")
|
||||||
|
BUILD_DATE:=$(shell date +"%F %H:%M:%S")
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: hello-omp
|
all: hello-omp
|
||||||
|
|
||||||
versioninfo.txt:
|
versioninfo.txt:
|
||||||
@echo "@(#) Compiler version: ${COMPILER_VER}." >versioninfo.txt
|
@echo "@(#) Build date: ${BUILD_DATE}." >versioninfo.txt
|
||||||
@echo "@(#) Compiler options: ${COMPILER_OPTS}." >>versioninfo.txt
|
@echo "@(#) Compiler version: ${COMPILER_VER}." >>versioninfo.txt
|
||||||
|
@echo "@(#) Compiler options: '${CFLAGS}'." >>versioninfo.txt
|
||||||
|
@echo "@(#) Linker options: '${LDFLAGS}'." >>versioninfo.txt
|
||||||
@echo "@(#) Git info: ${GIT_DESCRIBE}" >>versioninfo.txt
|
@echo "@(#) Git info: ${GIT_DESCRIBE}" >>versioninfo.txt
|
||||||
|
@echo "@(#) Commit author: ${GIT_AUTHOR}" >>versioninfo.txt
|
||||||
|
|
||||||
versioninfo.o: versioninfo.txt
|
versioninfo.o: versioninfo.txt
|
||||||
objcopy --input binary \
|
objcopy --input binary \
|
||||||
|
|
@ -22,8 +29,8 @@ versioninfo.o: versioninfo.txt
|
||||||
versioninfo.txt versioninfo.o
|
versioninfo.txt versioninfo.o
|
||||||
|
|
||||||
hello-omp: hello-omp.c Makefile versioninfo.o
|
hello-omp: hello-omp.c Makefile versioninfo.o
|
||||||
gcc $(COMPILER_OPTS) -DVERSIONINFO="\"$(GIT_DESCRIBE)\"" hello-omp.c \
|
gcc $(CFLAGS) $(LDFLAGS) -DVERSIONINFO="\"$(GIT_DESCRIBE)\"" \
|
||||||
versioninfo.o -o hello-omp
|
hello-omp.c versioninfo.o -o hello-omp
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,15 @@ my $verinfo = `git describe --abbrev=7 --dirty --always --tags`;
|
||||||
print "Hello Perl World! Version: $verinfo\n";
|
print "Hello Perl World! Version: $verinfo\n";
|
||||||
|
|
||||||
# Show list of command line arguments
|
# Show list of command line arguments
|
||||||
print "Command line args: @ARGV\n";
|
print "Command line args: ";
|
||||||
print "ARGV[0] = $ARGV[0]";
|
foreach (@ARGV) {
|
||||||
print "ARGV[1] = $ARGV[1]";
|
print " $_";
|
||||||
print "ARGV[2] = $ARGV[2]";
|
}
|
||||||
|
print "\n";
|
||||||
|
|
||||||
|
# Determine number of physical CPU sockets
|
||||||
|
my $socketcount=`cat /proc/cpuinfo | grep 'physical id' | sort | uniq | wc -l`;
|
||||||
|
print "CPU socket count: $socketcount\n";
|
||||||
|
|
||||||
# print out our animals array in reverse-sorted order
|
# print out our animals array in reverse-sorted order
|
||||||
print "\nValue of animals array:\n";
|
print "\nValue of animals array:\n";
|
||||||
|
|
@ -36,6 +41,27 @@ foreach (keys %fruit_color) {
|
||||||
print "$_ = $fruit_color{$_}\n";
|
print "$_ = $fruit_color{$_}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Read a non-existent environment variable and supply default value...
|
||||||
|
my $some_env_var;
|
||||||
|
if (defined $ENV{'PROBABLY_NOT_THERE'}) {
|
||||||
|
$some_env_var = $ENV{'PROBABLY_NOT_THERE'};
|
||||||
|
} else {
|
||||||
|
$some_env_var = "Default value";
|
||||||
|
}
|
||||||
|
print "\nPROBABLY_NOT_THERE is set to \'$some_env_var\'\n\n";
|
||||||
|
|
||||||
|
# Let's read in the PATH variable from the OS and print it out...
|
||||||
|
my $path_env_var = $ENV{'PATH'};
|
||||||
|
print "OS PATH var is set to: \'$path_env_var\'\n\n";
|
||||||
|
|
||||||
|
# Let's manipulate PATH variable and then restore it
|
||||||
|
print "Adding :/test to PATH variable\n";
|
||||||
|
$ENV{'PATH'} = "$ENV{'PATH'}:/test";
|
||||||
|
print "OS PATH var is set to: \'$ENV{'PATH'}\'\n\n";
|
||||||
|
print "Restoring original PATH value.\n";
|
||||||
|
$ENV{'PATH'} = $path_env_var;
|
||||||
|
print "OS PATH var is set to: \'$path_env_var\'\n\n";
|
||||||
|
|
||||||
# Let's create the file test.out and write animals array to it...
|
# Let's create the file test.out and write animals array to it...
|
||||||
print "\nWriting test.out file...\n";
|
print "\nWriting test.out file...\n";
|
||||||
open(my $out, ">", "test.out") or die "Can't create/open test.out! $!\n";
|
open(my $out, ">", "test.out") or die "Can't create/open test.out! $!\n";
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@ verinfo = subprocess.check_output(["git", "describe", "--abbrev=7",
|
||||||
"--dirty", "--always", "--tags"])
|
"--dirty", "--always", "--tags"])
|
||||||
|
|
||||||
# Obligatory Hello World with some version info
|
# Obligatory Hello World with some version info
|
||||||
print "Hello Python World! Version: " +verinfo
|
print("Hello Python World! Version: {}".format(verinfo))
|
||||||
|
|
||||||
# Show list of command line arguments
|
# Show list of command line arguments
|
||||||
print "Command line args: ",
|
print("Command line args: "),
|
||||||
for i in sys.argv[1:]:
|
for i in sys.argv[1:]:
|
||||||
print " " + i,
|
print(" {}".format(i))
|
||||||
print ""
|
print("")
|
||||||
|
|
||||||
# Determine number of physical CPU sockets
|
# Determine number of physical CPU sockets
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
|
|
@ -29,52 +29,52 @@ if os.name == 'nt':
|
||||||
else:
|
else:
|
||||||
socketcount = subprocess.check_output(["bash","-c",
|
socketcount = subprocess.check_output(["bash","-c",
|
||||||
"(cat /proc/cpuinfo | grep 'physical id' | sort | uniq | wc -l)"])
|
"(cat /proc/cpuinfo | grep 'physical id' | sort | uniq | wc -l)"])
|
||||||
print "CPU socket count: ", socketcount
|
print("CPU socket count: {}".format(socketcount))
|
||||||
|
|
||||||
# print out our animals array in reverse-sorted order
|
# print out our animals array in reverse-sorted order
|
||||||
print "\nValue of animals array:"
|
print("\nValue of animals array:")
|
||||||
for i in sorted(animals, reverse=True):
|
for i in sorted(animals, reverse=True):
|
||||||
print "item = " + i
|
print("item = " + i)
|
||||||
if (i == animals[0]):
|
if (i == animals[0]):
|
||||||
print " Condition is TRUE, \"" +i+ "\" == " + animals[0]
|
print(" Condition is TRUE, \"" +i+ "\" == " + animals[0])
|
||||||
else:
|
else:
|
||||||
print " Condition is FALSE, \"" +i+ "\" != " + animals[0]
|
print(" Condition is FALSE, \"" +i+ "\" != " + animals[0])
|
||||||
|
|
||||||
# print our fruit_color dictionary (key/value pairs)
|
# print our fruit_color dictionary (key/value pairs)
|
||||||
print "\nValue of fruit_color hash:"
|
print("\nValue of fruit_color hash:")
|
||||||
for fruit,color in sorted(fruit_color.items(), reverse=True):
|
for fruit,color in sorted(fruit_color.items(), reverse=True):
|
||||||
print fruit, " = ", color
|
print(fruit, " = ", color)
|
||||||
|
|
||||||
# Read a non-existent environment variable and supply default value...
|
# Read a non-existent environment variable and supply default value...
|
||||||
some_env_var = os.getenv("PROBABLY_NOT_THERE", "Default Value")
|
some_env_var = os.getenv("PROBABLY_NOT_THERE", "Default Value")
|
||||||
print "\nPROBABLY_NOT_THERE is set to '"+some_env_var+"'\n"
|
print("\nPROBABLY_NOT_THERE is set to '"+some_env_var+"'\n")
|
||||||
|
|
||||||
# Let's read in the PATH variable from the OS and print it out...
|
# Let's read in the PATH variable from the OS and print it out...
|
||||||
path_env_var = os.environ['PATH']
|
path_env_var = os.environ['PATH']
|
||||||
print "OS PATH var is set to: '"+path_env_var+"'\n"
|
print("OS PATH var is set to: '"+path_env_var+"'\n")
|
||||||
|
|
||||||
# Let's manipulate PATH variable and then restore it
|
# Let's manipulate PATH variable and then restore it
|
||||||
print "Adding :/test to PATH variable"
|
print("Adding :/test to PATH variable")
|
||||||
os.environ['PATH'] = os.environ['PATH'] + ":/test"
|
os.environ['PATH'] = os.environ['PATH'] + ":/test"
|
||||||
print "OS PATH var is set to: '"+os.environ['PATH']+"'\n"
|
print("OS PATH var is set to: '"+os.environ['PATH']+"'\n")
|
||||||
print "Restoring original PATH value."
|
print("Restoring original PATH value.")
|
||||||
os.environ['PATH'] = path_env_var
|
os.environ['PATH'] = path_env_var
|
||||||
print "OS PATH var is set to: '"+path_env_var+"'\n"
|
print("OS PATH var is set to: '"+path_env_var+"'\n")
|
||||||
|
|
||||||
|
|
||||||
# Let's create the file test.out and write animals array to it...
|
# Let's create the file test.out and write animals array to it...
|
||||||
print "\nWriting test.out file..."
|
print("\nWriting test.out file...")
|
||||||
file = open("test.out", "w")
|
file = open("test.out", "w")
|
||||||
for i in animals:
|
for i in animals:
|
||||||
file.write(i+"\n")
|
file.write(i+"\n")
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
# Now open the file we wrote and read it back...
|
# Now open the file we wrote and read it back...
|
||||||
print "\nContents of test.out file:"
|
print("\nContents of test.out file:")
|
||||||
file = open("test.out", "r")
|
file = open("test.out", "r")
|
||||||
linenum = 1
|
linenum = 1
|
||||||
for line in file:
|
for line in file:
|
||||||
print "line "+str(linenum)+": "+line,
|
print("line "+str(linenum)+": "+line)
|
||||||
linenum += 1
|
linenum += 1
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
|
|
||||||
5
rust/Cargo.lock
generated
Normal file
5
rust/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "rust"
|
||||||
|
version = "0.1.0"
|
||||||
9
rust/Cargo.toml
Normal file
9
rust/Cargo.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "rust"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Ed Braaten <ed.braaten@protonmail.ch>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
3
rust/src/main.rs
Normal file
3
rust/src/main.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, rust world!");
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue