Changes for 9-24-21

This commit is contained in:
Tyler Perkins 2021-09-24 00:22:57 -04:00
parent 4e91c7585e
commit ee4f69cffc
9 changed files with 195 additions and 21 deletions

View File

@ -30,6 +30,7 @@ _Ideas.md and Classes.md are encrypted, so these links will not work_
* [[lang/C++|C++]] * [[lang/C++|C++]]
* [[lang/C-sharp|C#]] * [[lang/C-sharp|C#]]
* [[lang/Python|Python]] * [[lang/Python|Python]]
* [[lang/Bash|Bash]]
* [[lang/HTML|HTML]] * [[lang/HTML|HTML]]
* [[lang/CSS|CSS]] * [[lang/CSS|CSS]]
* [[lang/Javascript|Javascript]] * [[lang/Javascript|Javascript]]

101
lang/Bash.wiki Normal file
View File

@ -0,0 +1,101 @@
= Bash =
The shell itself
== Common syntax ==
I tend to forget it sometimes lol
=== Brackets ===
Remember '\[' is a program unto itself. Here are some common flags
* -z
- empty string
* -n not
- empty string
* == aka -eq
- equal
* != aka -ne
- not equal
* -lt
- less than
* -gt
- greater than
* -ge
- greater than or equal
* !
- not
* &&
- and
* ||
- or
* -e
- file exists
* -r
- is readable
* -h
- is symlink
* -d
- is directory
* -s
- has data in it
* -f
- is file
* -x
- is executable
=== Variables ===
{{{
var=55
echo $var
}}}
=== While ===
{{{
while [ condition ]; do
echo "Hello world"
done
}}}
=== Arays ===
{{{
Fruits={'Apple','Banana','Orange'}
Fruits[0]="Apple"
echo ${Fruits[0]}
declare -A sounds
sounds[dog]="bark"
sounds[cow]="moo"
sounds[bird]="tweet"
sounds[wolf]="howl"
echo ${sounds[dog]} # Dog's sound
echo ${sounds[@]} # All values
echo ${!sounds[@]} # All keys
echo ${#sounds[@]} # Number of elements
unset sounds[dog] # Delete dog
}}}
=== Math ===
{{{
$((a + 200)) #add 200 to a
}}}
=== Strings ===
{{{
${FOO%suffix} #remove suffix from foo
${FOO#prefix} #remove prefix from foo
${FOO/from/to} #replace first instance of from with to
${FOO//from/to} #replace all instances of from with to
${#FOO} #length of foo
}}}
[[index]]

View File

@ -14,4 +14,4 @@ drawbacks due to the Object abstraction.
[[../index]] [[index]]

View File

@ -5,4 +5,4 @@ Purely object oriented language that relies on a JIT. Primary library is .NET
[[../index]] [[index]]

View File

@ -4,11 +4,11 @@ Systems language. One of the fastest langs around
== Memory == == Memory ==
* [[bitwise_cast]] - Cast a type as another bit for bit * [[bithacks]] - Wacky was to break memory
== Also See == == Also See ==
[[C++]] [[C++]]
[[../index]] [[index]]

68
lang/bithacks.wiki Normal file
View File

@ -0,0 +1,68 @@
= Bithacks =
Evil memory manipulation for speed
== Bitwise_cast ==
This works for C/C++. Basically all you do it cast like this
{{{C
float cast(int foo){
return (* (float*)&foo);
}
}}}
This is also known as the "evil floating point bit level hacking" from the
quake III fast inverse square root. Great for casting structs as memory for
hashing, or generally treating one set of bits as another type
== Negating Floats ==
{{{
float Negatefloat(float f){
return cast_float_to_uint(f) ^ 0x80000000;
}
}}}
== Fast log base 2 ==
IEE 754 is sci notification of a base 2 value, therefore this works very very
well. Breaks awfully with negtaives so be sure to check
{{{
const unsigned int OneAsInt = 0x3F800000;
const float ScaleUp = float(0x00800000); //2^23
const float ScaleDown = 1.0f/ScaleUp;
float Log2(float x){
return float (cast_float_to_uint(f)-OneAsInt)*ScaleDown
}
}}}
== Fast base 2 exponent ==
This is the opposite of the last one. Does 2^n fast
{{{
const unsigned int OneAsInt = 0x3F800000;
const float ScaleUp = float(0x00800000); //2^23
const float ScaleDown = 1.0f/ScaleUp;
float Log2(float x){
return asfloat (cast_float_to_uint(f)*ScaleUp)+OneAsInt;
}
}}}
== Not accurate square root ==
This doesnt do that well but its better really fast. Does a fast taking of the
float to the power of 0.5
{{{
const unsigned int OneAsInt = 0x3F800000;
float sqrt(float x){
return asfloat((asint(x)>>1)+(OneAsInt>>1));
}
}}}
[[index]]

View File

@ -1,16 +0,0 @@
= Bitwise_cast =
This works for C/C++. Basically all you do it cast like this
{{{C
float cast(int foo){
return (* (float*)&foo);
}
}}}
This is also known as the "evil floating point bit level hacking" from the
quake III fast inverse square root.
== Uses ==
* Casting structs for hashing

20
lang/index.wiki Normal file
View File

@ -0,0 +1,20 @@
= Languages =
== Sections ==
* [[C|C]]
* [[C++|C++]]
* [[C-sharp|C#]]
* [[Python|Python]]
* [[Bash|Bash]]
* [[HTML|HTML]]
* [[CSS|CSS]]
* [[Javascript|Javascript]]
* [[PHP|PHP]]
* [[Rust|Rust]]
* [[Go|Go]]
* [[sql|SQL]]
[[../index]]

View File

@ -1,6 +1,6 @@
= Measurment = = Measurment =
This is also the introduction [[chapter]] This is also the introduction chapter
== Definitions == == Definitions ==