diff --git a/Development Tips/Cool Development In Unity EnormousQuickDarklingbeetle.mp4 b/Development Tips/Cool Development In Unity EnormousQuickDarklingbeetle.mp4 new file mode 100644 index 0000000..be9c51e Binary files /dev/null and b/Development Tips/Cool Development In Unity EnormousQuickDarklingbeetle.mp4 differ diff --git a/Development Tips/Drag With Mouse Screen Shot 2017-10-10 at 5.03.54 PM.png b/Development Tips/Drag With Mouse Screen Shot 2017-10-10 at 5.03.54 PM.png new file mode 100644 index 0000000..38e7a53 Binary files /dev/null and b/Development Tips/Drag With Mouse Screen Shot 2017-10-10 at 5.03.54 PM.png differ diff --git a/Development Tips/How to clamp velocity to max and min.png b/Development Tips/How to clamp velocity to max and min.png new file mode 100644 index 0000000..3281077 Binary files /dev/null and b/Development Tips/How to clamp velocity to max and min.png differ diff --git a/Development Tips/How to get Unity Screen Resolution.png b/Development Tips/How to get Unity Screen Resolution.png new file mode 100644 index 0000000..54e7444 Binary files /dev/null and b/Development Tips/How to get Unity Screen Resolution.png differ diff --git a/Development Tips/How to get actual screen width and height.png b/Development Tips/How to get actual screen width and height.png new file mode 100644 index 0000000..5e073c2 Binary files /dev/null and b/Development Tips/How to get actual screen width and height.png differ diff --git a/Development Tips/Strongly Worded Comment about Serialization Screen Shot 2017-10-30 at 7.11.26 PM.png b/Development Tips/Strongly Worded Comment about Serialization Screen Shot 2017-10-30 at 7.11.26 PM.png new file mode 100644 index 0000000..b42c9ba Binary files /dev/null and b/Development Tips/Strongly Worded Comment about Serialization Screen Shot 2017-10-30 at 7.11.26 PM.png differ diff --git a/Development Tips/This could be a useful movement function.png b/Development Tips/This could be a useful movement function.png new file mode 100644 index 0000000..137dae0 Binary files /dev/null and b/Development Tips/This could be a useful movement function.png differ diff --git a/asm/Calling C from Asm with Int Parameter/example b/asm/Calling C from Asm with Int Parameter/example new file mode 100644 index 0000000..9af2e6e Binary files /dev/null and b/asm/Calling C from Asm with Int Parameter/example differ diff --git a/asm/Calling C from Asm with Int Parameter/example.o b/asm/Calling C from Asm with Int Parameter/example.o new file mode 100644 index 0000000..390324f Binary files /dev/null and b/asm/Calling C from Asm with Int Parameter/example.o differ diff --git a/asm/Calling C from Asm with Int Parameter/exampleAsm b/asm/Calling C from Asm with Int Parameter/exampleAsm new file mode 100644 index 0000000..ffb7da5 Binary files /dev/null and b/asm/Calling C from Asm with Int Parameter/exampleAsm differ diff --git a/asm/Calling C from Asm with Int Parameter/myLibrary.c b/asm/Calling C from Asm with Int Parameter/myLibrary.c new file mode 100644 index 0000000..ea633ff --- /dev/null +++ b/asm/Calling C from Asm with Int Parameter/myLibrary.c @@ -0,0 +1,20 @@ +#include "myLibrary.h" +#include +int foo(int a) { + printf ("\n"); + if (a < 100) { + printf("Number is: %i\n",a); + for (int i = 0; i < a; i++) { + printf("d"); + } + printf("\n"); + } + else { + printf("Number very large: %i\n",a); + } + return 0; +} +int doo(char * a) { + printf("Hey | %s |\n",a); + return 0; +} diff --git a/asm/Calling C from Asm with Int Parameter/myLibrary.h b/asm/Calling C from Asm with Int Parameter/myLibrary.h new file mode 100644 index 0000000..f6869b2 --- /dev/null +++ b/asm/Calling C from Asm with Int Parameter/myLibrary.h @@ -0,0 +1,5 @@ +#ifndef WHATEVER_H_INCLUDED +#define WHATEVER_H_INCLUDED + int foo(int a); + int doo(char * a); +#endif \ No newline at end of file diff --git a/asm/Calling C from Asm with Int Parameter/myLibrary.o b/asm/Calling C from Asm with Int Parameter/myLibrary.o new file mode 100644 index 0000000..6e166ef Binary files /dev/null and b/asm/Calling C from Asm with Int Parameter/myLibrary.o differ diff --git a/asm/Calling C from Asm with Int Parameter/myLibraryExample.asm b/asm/Calling C from Asm with Int Parameter/myLibraryExample.asm new file mode 100644 index 0000000..44921eb --- /dev/null +++ b/asm/Calling C from Asm with Int Parameter/myLibraryExample.asm @@ -0,0 +1,18 @@ +; See Readme for instructions + + global _main + extern _foo + + section .text +_main: + sub rsp, 8 + + mov rdi, 0x55 ; Use this instead of 'mov rdi, message' + call _foo + add rsp, 8 + ret + + section .data +message: +default rel ; Add 'default rel' under label + db 0x2 \ No newline at end of file diff --git a/asm/Calling C from Asm with Int Parameter/myLibraryExample.c b/asm/Calling C from Asm with Int Parameter/myLibraryExample.c new file mode 100644 index 0000000..bafb32e --- /dev/null +++ b/asm/Calling C from Asm with Int Parameter/myLibraryExample.c @@ -0,0 +1,13 @@ +// -------------------------------------------------- +// gcc -c myLibrary.c -o myLibrary.o +// gcc -c myLibraryExample.c -o example.o +// gcc example.o myLibrary.o -o example +// ./example +// -------------------------------------------------- + +#include "myLibrary.h" + +int main() { + foo(11); + return 0; +} \ No newline at end of file diff --git a/asm/Calling C from Asm with Int Parameter/myLibraryExample.o b/asm/Calling C from Asm with Int Parameter/myLibraryExample.o new file mode 100644 index 0000000..0ad19df Binary files /dev/null and b/asm/Calling C from Asm with Int Parameter/myLibraryExample.o differ diff --git a/asm/Calling C from Asm with Int Parameter/myLibraryExample2.asm b/asm/Calling C from Asm with Int Parameter/myLibraryExample2.asm new file mode 100644 index 0000000..9523012 --- /dev/null +++ b/asm/Calling C from Asm with Int Parameter/myLibraryExample2.asm @@ -0,0 +1,22 @@ +; ------------------------------------------------------------------------------ +; gcc -c myLibrary.c -o myLibrary.o + +; /usr/local/bin/nasm -f macho64 myLibraryExample.asm && gcc -arch x86_64 -o exampleAsm myLibraryExample.o myLibrary.o && ./exampleAsm +; ------------------------------------------------------------------------------ + + global _main + extern _foo + + section .text +_main: + sub rsp, 8 + + lea rdi, [message] ; Use this instead of 'mov rdi, message' + call _foo + add rsp, 8 + ret + + section .data +message: +default rel ; Add 'default rel' under label + db "Hola, mundo",0 \ No newline at end of file diff --git a/asm/Calling C from Asm with Int Parameter/readme.txt b/asm/Calling C from Asm with Int Parameter/readme.txt new file mode 100644 index 0000000..4b9ac7b --- /dev/null +++ b/asm/Calling C from Asm with Int Parameter/readme.txt @@ -0,0 +1,27 @@ + +To Compile the library: + gcc -c myLibrary.c -o myLibrary.o + +For just the C Example: +Compile + gcc -c myLibraryExample.c -o example.o +Link + gcc example.o myLibrary.o -o example +Run + ./example + +For just the Asm Example: +Compile + /usr/local/bin/nasm -f macho64 myLibraryExample.asm +Link + gcc -arch x86_64 -o exampleAsm myLibraryExample.o myLibrary.o +Run: + ./exampleAsm +All: + nasm -f macho64 myLibraryExample.asm && gcc -arch x86_64 -o exampleAsm myLibraryExample.o myLibrary.o && ./exampleAsm + +Compile the library and CLR the asm: + gcc -c myLibrary.c -o myLibrary.o && nasm -f macho64 myLibraryExample.asm && gcc -arch x86_64 -o exampleAsm myLibraryExample.o myLibrary.o && ./exampleAsm + + + diff --git a/asm/Calling C from Asm with String Parameter/example b/asm/Calling C from Asm with String Parameter/example new file mode 100644 index 0000000..9af2e6e Binary files /dev/null and b/asm/Calling C from Asm with String Parameter/example differ diff --git a/asm/Calling C from Asm with String Parameter/example.o b/asm/Calling C from Asm with String Parameter/example.o new file mode 100644 index 0000000..390324f Binary files /dev/null and b/asm/Calling C from Asm with String Parameter/example.o differ diff --git a/asm/Calling C from Asm with String Parameter/exampleAsm b/asm/Calling C from Asm with String Parameter/exampleAsm new file mode 100644 index 0000000..1b4f47a Binary files /dev/null and b/asm/Calling C from Asm with String Parameter/exampleAsm differ diff --git a/asm/Calling C from Asm with String Parameter/myLibrary.c b/asm/Calling C from Asm with String Parameter/myLibrary.c new file mode 100644 index 0000000..410f099 --- /dev/null +++ b/asm/Calling C from Asm with String Parameter/myLibrary.c @@ -0,0 +1,10 @@ +#include "myLibrary.h" +#include +int foo(int a) { + printf("Hey %d\n",a); + return 0; +} +int doo(char * a) { + printf("Hey | %s |\n",a); + return 0; +} diff --git a/asm/Calling C from Asm with String Parameter/myLibrary.h b/asm/Calling C from Asm with String Parameter/myLibrary.h new file mode 100644 index 0000000..f6869b2 --- /dev/null +++ b/asm/Calling C from Asm with String Parameter/myLibrary.h @@ -0,0 +1,5 @@ +#ifndef WHATEVER_H_INCLUDED +#define WHATEVER_H_INCLUDED + int foo(int a); + int doo(char * a); +#endif \ No newline at end of file diff --git a/asm/Calling C from Asm with String Parameter/myLibrary.o b/asm/Calling C from Asm with String Parameter/myLibrary.o new file mode 100644 index 0000000..ff139e0 Binary files /dev/null and b/asm/Calling C from Asm with String Parameter/myLibrary.o differ diff --git a/asm/Calling C from Asm with String Parameter/myLibraryExample.asm b/asm/Calling C from Asm with String Parameter/myLibraryExample.asm new file mode 100644 index 0000000..9c07daf --- /dev/null +++ b/asm/Calling C from Asm with String Parameter/myLibraryExample.asm @@ -0,0 +1,18 @@ +; See Readme for instructions + + global _main + extern _doo + + section .text +_main: + sub rsp, 8 + + lea rdi, [message] ; Use this instead of 'mov rdi, message' + call _doo + add rsp, 8 + ret + + section .data +message: +default rel ; Add 'default rel' under label + db "Hey there, World!",0 \ No newline at end of file diff --git a/asm/Calling C from Asm with String Parameter/myLibraryExample.c b/asm/Calling C from Asm with String Parameter/myLibraryExample.c new file mode 100644 index 0000000..bafb32e --- /dev/null +++ b/asm/Calling C from Asm with String Parameter/myLibraryExample.c @@ -0,0 +1,13 @@ +// -------------------------------------------------- +// gcc -c myLibrary.c -o myLibrary.o +// gcc -c myLibraryExample.c -o example.o +// gcc example.o myLibrary.o -o example +// ./example +// -------------------------------------------------- + +#include "myLibrary.h" + +int main() { + foo(11); + return 0; +} \ No newline at end of file diff --git a/asm/Calling C from Asm with String Parameter/myLibraryExample.o b/asm/Calling C from Asm with String Parameter/myLibraryExample.o new file mode 100644 index 0000000..20b4fa4 Binary files /dev/null and b/asm/Calling C from Asm with String Parameter/myLibraryExample.o differ diff --git a/asm/Calling C from Asm with String Parameter/myLibraryExample2.asm b/asm/Calling C from Asm with String Parameter/myLibraryExample2.asm new file mode 100644 index 0000000..9523012 --- /dev/null +++ b/asm/Calling C from Asm with String Parameter/myLibraryExample2.asm @@ -0,0 +1,22 @@ +; ------------------------------------------------------------------------------ +; gcc -c myLibrary.c -o myLibrary.o + +; /usr/local/bin/nasm -f macho64 myLibraryExample.asm && gcc -arch x86_64 -o exampleAsm myLibraryExample.o myLibrary.o && ./exampleAsm +; ------------------------------------------------------------------------------ + + global _main + extern _foo + + section .text +_main: + sub rsp, 8 + + lea rdi, [message] ; Use this instead of 'mov rdi, message' + call _foo + add rsp, 8 + ret + + section .data +message: +default rel ; Add 'default rel' under label + db "Hola, mundo",0 \ No newline at end of file diff --git a/asm/Calling C from Asm with String Parameter/readme.txt b/asm/Calling C from Asm with String Parameter/readme.txt new file mode 100644 index 0000000..4b9ac7b --- /dev/null +++ b/asm/Calling C from Asm with String Parameter/readme.txt @@ -0,0 +1,27 @@ + +To Compile the library: + gcc -c myLibrary.c -o myLibrary.o + +For just the C Example: +Compile + gcc -c myLibraryExample.c -o example.o +Link + gcc example.o myLibrary.o -o example +Run + ./example + +For just the Asm Example: +Compile + /usr/local/bin/nasm -f macho64 myLibraryExample.asm +Link + gcc -arch x86_64 -o exampleAsm myLibraryExample.o myLibrary.o +Run: + ./exampleAsm +All: + nasm -f macho64 myLibraryExample.asm && gcc -arch x86_64 -o exampleAsm myLibraryExample.o myLibrary.o && ./exampleAsm + +Compile the library and CLR the asm: + gcc -c myLibrary.c -o myLibrary.o && nasm -f macho64 myLibraryExample.asm && gcc -arch x86_64 -o exampleAsm myLibraryExample.o myLibrary.o && ./exampleAsm + + + diff --git a/asm/Calling My C Library From Assembly/example b/asm/Calling My C Library From Assembly/example new file mode 100644 index 0000000..9af2e6e Binary files /dev/null and b/asm/Calling My C Library From Assembly/example differ diff --git a/asm/Calling My C Library From Assembly/example.o b/asm/Calling My C Library From Assembly/example.o new file mode 100644 index 0000000..390324f Binary files /dev/null and b/asm/Calling My C Library From Assembly/example.o differ diff --git a/asm/Calling My C Library From Assembly/exampleAsm b/asm/Calling My C Library From Assembly/exampleAsm new file mode 100644 index 0000000..bb16995 Binary files /dev/null and b/asm/Calling My C Library From Assembly/exampleAsm differ diff --git a/asm/Calling My C Library From Assembly/myLibrary.c b/asm/Calling My C Library From Assembly/myLibrary.c new file mode 100644 index 0000000..46829f1 --- /dev/null +++ b/asm/Calling My C Library From Assembly/myLibrary.c @@ -0,0 +1,6 @@ +#include "myLibrary.h" +#include +int foo(int a) { + printf("Hey %d\n",a); + return 0; +} diff --git a/asm/Calling My C Library From Assembly/myLibrary.h b/asm/Calling My C Library From Assembly/myLibrary.h new file mode 100644 index 0000000..756cca3 --- /dev/null +++ b/asm/Calling My C Library From Assembly/myLibrary.h @@ -0,0 +1,4 @@ +#ifndef WHATEVER_H_INCLUDED +#define WHATEVER_H_INCLUDED + int foo(int a); +#endif \ No newline at end of file diff --git a/asm/Calling My C Library From Assembly/myLibrary.o b/asm/Calling My C Library From Assembly/myLibrary.o new file mode 100644 index 0000000..b3cb5fe Binary files /dev/null and b/asm/Calling My C Library From Assembly/myLibrary.o differ diff --git a/asm/Calling My C Library From Assembly/myLibraryExample.asm b/asm/Calling My C Library From Assembly/myLibraryExample.asm new file mode 100644 index 0000000..9523012 --- /dev/null +++ b/asm/Calling My C Library From Assembly/myLibraryExample.asm @@ -0,0 +1,22 @@ +; ------------------------------------------------------------------------------ +; gcc -c myLibrary.c -o myLibrary.o + +; /usr/local/bin/nasm -f macho64 myLibraryExample.asm && gcc -arch x86_64 -o exampleAsm myLibraryExample.o myLibrary.o && ./exampleAsm +; ------------------------------------------------------------------------------ + + global _main + extern _foo + + section .text +_main: + sub rsp, 8 + + lea rdi, [message] ; Use this instead of 'mov rdi, message' + call _foo + add rsp, 8 + ret + + section .data +message: +default rel ; Add 'default rel' under label + db "Hola, mundo",0 \ No newline at end of file diff --git a/asm/Calling My C Library From Assembly/myLibraryExample.c b/asm/Calling My C Library From Assembly/myLibraryExample.c new file mode 100644 index 0000000..bafb32e --- /dev/null +++ b/asm/Calling My C Library From Assembly/myLibraryExample.c @@ -0,0 +1,13 @@ +// -------------------------------------------------- +// gcc -c myLibrary.c -o myLibrary.o +// gcc -c myLibraryExample.c -o example.o +// gcc example.o myLibrary.o -o example +// ./example +// -------------------------------------------------- + +#include "myLibrary.h" + +int main() { + foo(11); + return 0; +} \ No newline at end of file diff --git a/asm/Calling My C Library From Assembly/myLibraryExample.o b/asm/Calling My C Library From Assembly/myLibraryExample.o new file mode 100644 index 0000000..3f0913e Binary files /dev/null and b/asm/Calling My C Library From Assembly/myLibraryExample.o differ diff --git a/asm/Calling My C Library From Assembly/myLibraryExample2.asm b/asm/Calling My C Library From Assembly/myLibraryExample2.asm new file mode 100644 index 0000000..9523012 --- /dev/null +++ b/asm/Calling My C Library From Assembly/myLibraryExample2.asm @@ -0,0 +1,22 @@ +; ------------------------------------------------------------------------------ +; gcc -c myLibrary.c -o myLibrary.o + +; /usr/local/bin/nasm -f macho64 myLibraryExample.asm && gcc -arch x86_64 -o exampleAsm myLibraryExample.o myLibrary.o && ./exampleAsm +; ------------------------------------------------------------------------------ + + global _main + extern _foo + + section .text +_main: + sub rsp, 8 + + lea rdi, [message] ; Use this instead of 'mov rdi, message' + call _foo + add rsp, 8 + ret + + section .data +message: +default rel ; Add 'default rel' under label + db "Hola, mundo",0 \ No newline at end of file diff --git a/asm/Calling My C Library From Assembly/readme.txt b/asm/Calling My C Library From Assembly/readme.txt new file mode 100644 index 0000000..9c228f2 --- /dev/null +++ b/asm/Calling My C Library From Assembly/readme.txt @@ -0,0 +1,15 @@ + +To Compile the library: + gcc -c myLibrary.c -o myLibrary.o + +To Compile the C Example + gcc -c myLibraryExample.c -o example.o + +To Link the C Example + gcc example.o myLibrary.o -o example + +To Run the C Example + ./example + + To Compile the Asm Example +/usr/local/bin/nasm -f macho64 myLibraryExample.asm && gcc -arch x86_64 -o exampleAsm myLibraryExample.o myLibrary.o && ./exampleAsm diff --git a/asm/Hello World In Assembly/hello b/asm/Hello World In Assembly/hello new file mode 100644 index 0000000..ee1f062 Binary files /dev/null and b/asm/Hello World In Assembly/hello differ diff --git a/asm/Hello World In Assembly/hola b/asm/Hello World In Assembly/hola new file mode 100644 index 0000000..c8bad89 Binary files /dev/null and b/asm/Hello World In Assembly/hola differ diff --git a/asm/Hello World In Assembly/hola.asm b/asm/Hello World In Assembly/hola.asm new file mode 100644 index 0000000..3766a26 --- /dev/null +++ b/asm/Hello World In Assembly/hola.asm @@ -0,0 +1,24 @@ +; ------------------------------------------------------------------------------ +; Writes "Hola, mundo" to the console using a C library. Runs on Linux or any +; other system that does not use underscores for symbols in its C library. To +; assemble and run: +; +; /usr/local/bin/nasm -f macho64 hola.asm && gcc -arch x86_64 -o hola hola.o && ./hola +; ------------------------------------------------------------------------------ + + global _main + extern _puts + + section .text +_main: + sub rsp, 8 + + lea rdi, [message] ; Use this instead of 'mov rdi, message' + call _puts + add rsp, 8 + ret + + section .data +message: +default rel ; Add 'default rel' under label + db "Hola, mundo",0 \ No newline at end of file diff --git a/asm/Hello World In Assembly/hola.o b/asm/Hello World In Assembly/hola.o new file mode 100644 index 0000000..ebbbd2d Binary files /dev/null and b/asm/Hello World In Assembly/hola.o differ diff --git a/asm/Hello World In Assembly/hw.asm b/asm/Hello World In Assembly/hw.asm new file mode 100644 index 0000000..765891d --- /dev/null +++ b/asm/Hello World In Assembly/hw.asm @@ -0,0 +1,14 @@ +global start +section .text +start: + mov rax, 0x2000004 ; write + mov rdi, 1 ; stdout + mov rsi, msg + mov rdx, msg.len + syscall + mov rax, 0x2000001 ; exit + mov rdi, 0 + syscall +section .data +msg: db "Hello, world!", 10 +.len: equ $ - msg diff --git a/asm/Hello World In Assembly/hw.o b/asm/Hello World In Assembly/hw.o new file mode 100644 index 0000000..b7ed956 Binary files /dev/null and b/asm/Hello World In Assembly/hw.o differ diff --git a/asm/Hello World In Assembly/hw2 b/asm/Hello World In Assembly/hw2 new file mode 100644 index 0000000..c8bad89 Binary files /dev/null and b/asm/Hello World In Assembly/hw2 differ diff --git a/asm/Hello World In Assembly/hw2.asm b/asm/Hello World In Assembly/hw2.asm new file mode 100644 index 0000000..6cbd2aa --- /dev/null +++ b/asm/Hello World In Assembly/hw2.asm @@ -0,0 +1,21 @@ +; -------------------------------------------------------- +; nasm -f macho64 hw2.asm && gcc -arch x86_64 -o hw2 hw2.o && ./hw2 +; -------------------------------------------------------- + + + global _main + extern _puts + + section .text +_main: + sub rsp, 8 + + lea rdi, [message] ; use lea instead of mov rdi + call _puts + add rsp, 8 + ret + + section .data +message: +default rel ; put under label when referencing labeled memory + db "Hola, mundo",0 \ No newline at end of file diff --git a/asm/Hello World In Assembly/hw2.o b/asm/Hello World In Assembly/hw2.o new file mode 100644 index 0000000..ebbbd2d Binary files /dev/null and b/asm/Hello World In Assembly/hw2.o differ diff --git a/asm/Hello World In Assembly/readme.txt b/asm/Hello World In Assembly/readme.txt new file mode 100644 index 0000000..33993ef --- /dev/null +++ b/asm/Hello World In Assembly/readme.txt @@ -0,0 +1,112 @@ +inspired by this: +https://jameshfisher.com/2017/02/20/macos-assembly-hello-world/ + + +Johns-MacBook-Pro:~ johnmcgarey$ brew install nasm +Updating Homebrew... +==> Auto-updated Homebrew! +Updated 1 tap (homebrew/core). +==> Updated Formulae +kops + +==> Downloading https://homebrew.bintray.com/bottles/nasm-2.14.02.mojave.bottle. +==> Downloading from https://akamai.bintray.com/77/77a183895137e0f95d897d3339923 +######################################################################## 100.0% +==> Pouring nasm-2.14.02.mojave.bottle.tar.gz +🍺 /usr/local/Cellar/nasm/2.14.02: 30 files, 2.7MB +==> `brew cleanup` has not been run in 30 days, running now... +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/pcre-8.41.high_sierra.bottle.tar.gz... (1.7MB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/cairo-1.14.10.high_sierra.bottle.tar.gz... (1.6MB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/pkg-config-0.29.2.high_sierra.bottle.tar.gz... (235.8KB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/libtiff-4.0.8_5.high_sierra.bottle.tar.gz... (1MB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/fontconfig-2.12.6.high_sierra.bottle.tar.gz... (1.2MB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/libpng-1.6.34.high_sierra.bottle.tar.gz... (444.4KB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/libffi-3.2.1.high_sierra.bottle.tar.gz... (97.2KB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/little-cms2-2.9.high_sierra.bottle.tar.gz... (377.9KB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/freetype-2.8.1.high_sierra.bottle.tar.gz... (887.6KB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/gobject-introspection-1.54.1.high_sierra.bottle.tar.gz... (1.5MB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/poppler-0.61.1.high_sierra.bottle.tar.gz... (5.9MB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/gettext-0.19.8.1.high_sierra.bottle.tar.gz... (7.8MB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/pixman-0.34.0_1.high_sierra.bottle.tar.gz... (497.9KB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/glib-2.54.2.high_sierra.bottle.tar.gz... (6.9MB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/jpeg-9b.high_sierra.bottle.tar.gz... (296.8KB) +Removing: /Users/johnmcgarey/Library/Caches/Homebrew/openjpeg-2.3.0.high_sierra.bottle.tar.gz... (1.9MB) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/lame... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/pkg-config... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/libtiff... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/ffmpeg... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/xvid... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/little-cms2... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/libpng... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/pixman... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/freetype... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/openjpeg... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/glib... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/cairo... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/gobject-introspection... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/fontconfig... (927B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/libav... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/gettext... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/youtube-dl... (106B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/pcre... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/x264... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/faac... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/jpeg... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/poppler... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/openssl... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/libffi... (64B) +Removing: /Users/johnmcgarey/Library/Logs/Homebrew/httrack... (64B) +Pruned 0 symbolic links and 4 directories from /usr/local +Johns-MacBook-Pro:~ johnmcgarey$ +Johns-MacBook-Pro:~ johnmcgarey$ nasm +nasm: fatal: no input file specified +type `nasm -h' for help +Johns-MacBook-Pro:~ johnmcgarey$ ls +Applications Downloads Movies Projects dwhelper +Desktop Dropbox Music Public git +Documents Library Pictures Sites orDrumbox +Johns-MacBook-Pro:~ johnmcgarey$ cd git +Johns-MacBook-Pro:git johnmcgarey$ ls +Clarity Dev HomeRun Misc +Johns-MacBook-Pro:git johnmcgarey$ cd Dev +Johns-MacBook-Pro:Dev johnmcgarey$ ls +autotracker +Johns-MacBook-Pro:Dev johnmcgarey$ more autotracker/ +autotracker/ is a directory +Johns-MacBook-Pro:Dev johnmcgarey$ cd autotracker/ +Johns-MacBook-Pro:autotracker johnmcgarey$ ls +auto.py bu-fish-of-the-tubes.it bu-white-and-biased.it +Johns-MacBook-Pro:autotracker johnmcgarey$ cd .. +Johns-MacBook-Pro:Dev johnmcgarey$ mkdir nasm +Johns-MacBook-Pro:Dev johnmcgarey$ cd .. +Johns-MacBook-Pro:git johnmcgarey$ ls +Clarity Dev HomeRun Misc +Johns-MacBook-Pro:git johnmcgarey$ cd Dev/ +Johns-MacBook-Pro:Dev johnmcgarey$ ls +autotracker nasm +Johns-MacBook-Pro:Dev johnmcgarey$ cd nams +-bash: cd: nams: No such file or directory +Johns-MacBook-Pro:Dev johnmcgarey$ cd nasm +Johns-MacBook-Pro:nasm johnmcgarey$ ls +Johns-MacBook-Pro:nasm johnmcgarey$ git init +Initialized empty Git repository in /Users/johnmcgarey/git/Dev/nasm/.git/ +Johns-MacBook-Pro:nasm johnmcgarey$ git status +On branch master + +No commits yet + +nothing to commit (create/copy files and use "git add" to track) +Johns-MacBook-Pro:nasm johnmcgarey$ mate hw.asm +Johns-MacBook-Pro:nasm johnmcgarey$ ls +hw.asm +Johns-MacBook-Pro:nasm johnmcgarey$ nasm -version +NASM version 2.14.02 compiled on Dec 27 2018 +Johns-MacBook-Pro:nasm johnmcgarey$ nasm -f macho64 hello.asm +nasm: fatal: unable to open input file `hello.asm' +Johns-MacBook-Pro:nasm johnmcgarey$ nasm -f macho64 hw.asm +Johns-MacBook-Pro:nasm johnmcgarey$ ld -macosx_version_min 10.7.0 -lSystem -o hello hw.o +ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in start from hw.o. To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie +Johns-MacBook-Pro:nasm johnmcgarey$ ./hello +Hello, world! +Johns-MacBook-Pro:nasm johnmcgarey$ mate hw.transcript.txt +Johns-MacBook-Pro:nasm johnmcgarey$ \ No newline at end of file diff --git a/bash/.bash_profile b/bash/.bash_profile new file mode 100644 index 0000000..cd643d3 --- /dev/null +++ b/bash/.bash_profile @@ -0,0 +1,11 @@ + +source ~/.bashrc + +alias pg="pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log" + +export PATH="$PATH:/Applications/Muse" + +export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/Applications/Muse" + +export EDITOR="/usr/local/bin/mate -w" + diff --git a/bash/.bashrc b/bash/.bashrc new file mode 100644 index 0000000..66c6229 --- /dev/null +++ b/bash/.bashrc @@ -0,0 +1,16 @@ + +export BASHGITDIR=~/git/HomeRun/bash/ + +# reloading profiles +source ${BASHGITDIR}.my_bash_profile +source ${BASHGITDIR}.fiverr_bash_profile ${BASHGITDIR}.dev_bash_profile ${BASHGITDIR}.voices_bash_profile + +# Load all of the bash profiles for editing at once +editbash () { + mate ~/.bash_profile ~/.bashrc ${BASHGITDIR}.my_bash_profile ${BASHGITDIR}.fiverr_bash_profile ${BASHGITDIR}.dev_bash_profile ${BASHGITDIR}.voices_bash_profile +} + +# reshell - reload the shell settings +alias r=". ~/.bashrc" + + diff --git a/bash/.dev_bash_profile b/bash/.dev_bash_profile new file mode 100644 index 0000000..2131d30 --- /dev/null +++ b/bash/.dev_bash_profile @@ -0,0 +1,39 @@ + +# Function: backup Lazacademy +# --------------------------------------------- +backupLazacademy() { + + abbreviateddate=`date "+%b%d.%H%M"` + mdyDate=`date "+%m.%d.%Y"` + backupsDirectory="/Users/johnny/Dropbox/Dev/Backups" + targetDirectory="$backupsDirectory/$mdyDate/$abbreviateddate$1" + echo Setting up new directory: $targetDirectory + mkdir -p $targetDirectory + + latestCode="/Users/johnny/Dropbox/Dev/Lazacademy/assets/javascripts" + echo "Copying $latestCode (main.js and app)" + echo "to $targetDirectory" + cp "$latestCode"/main.js "$targetDirectory" + cp -r "$latestCode"/app "$targetDirectory" + echo Done! + cd $targetDirectory +} +alias blaz=backupLazacademy; + + +kickItOff() { + cd /Users/johnny/Dropbox/Dev/Lazacademy + open -a Terminal "./mim.sh" + ./test.sh +} +alias 1=kickItOff + + +# Function: backup Lazacademy +# --------------------------------------------- +getDate() { + + date=`date "+%m/%d/%Y"` + echo $date +} +alias getdate=getDate \ No newline at end of file diff --git a/bash/.fiverr_bash_profile b/bash/.fiverr_bash_profile new file mode 100644 index 0000000..e33b97d --- /dev/null +++ b/bash/.fiverr_bash_profile @@ -0,0 +1,167 @@ + + +# To support various Firefox Profiles: +alias prudence='/Applications/Firefox.app/Contents/MacOS/firefox-bin -P Prudence -no-remote&' +alias default='/Applications/Firefox.app/Contents/MacOS/firefox-bin -P default -no-remote&' +# One in .fiverr_bash_profile called fff +alias ff='/Applications/Firefox.app/Contents/MacOS/firefox-bin -P -no-remote' +moz () { /Applications/Firefox.app/Contents/MacOS/firefox-bin -P $* -no-remote; } + + +alias fiverr='echo "fdir, fff, sfd username, ssd username, pfo, pfs, pfoAll, getUsername, start, finish"' +alias f='/Applications/Firefox.app/Contents/MacOS/firefox-bin -P FreshFiverr -no-remote &' +alias fdir='cd "/Users/johnny/Documents/Fiverr Orders Inwork/";lcd' + +# Jump to the latest directory in this directory +alias latestdir='ls -1ct | head -1' +alias lcd='cd "`latestdir`"' + + +# Function: Setup Fiverr Directory +# --------------------------------------------- +sfd() { + + abbreviateddate=`date "+%b %d"` + targetDirectory="/Users/johnny/Documents/Fiverr Orders Inwork/$abbreviateddate ORDER - $1" + echo Setting up new directory: $targetDirectory + mkdir "$targetDirectory" + + # Copy the garageband template in + echo Setting up garage band: "$targetDirectory/Fiverr - $1.band" + cp -r "/Users/johnny/Dropbox/Johnnys Documents/Jollysites Dropbox/Fiverr Campaign/Fiverr - Template.band" "$targetDirectory/Fiverr - $1.band" + + + # Move the most recently downloaded file into the target directory + # Get the most recently downloaded file in downloads + mostRecentDownload=`find ~/Downloads -type f -iname $(ls -t ~/Downloads | head -1)` + echo Copying $mostRecentDownload to fiverr directory + cp "$mostRecentDownload" "$targetDirectory" + + touch "$targetDirectory/$1_INSTRUCTIONS.txt" + touch "$targetDirectory/$1_currentScript.txt" +} +alias setup-fiverr-directory=sfd + + +# Function: Setup Fiverr SAMPLE Directory +# --------------------------------------------- +ssd() { + + abbreviateddate=`date "+%b %d"` + targetDirectory="/Users/johnny/Documents/Fiverr Orders Inwork/$abbreviateddate SAMPLE - $1" + echo Setting up new directory: $targetDirectory + mkdir "$targetDirectory" + + # Copy the garageband template in + echo Setting up garage band: "$targetDirectory/Fiverr - $1.band" + cp -r "/Users/johnny/Dropbox/Johnnys Documents/Jollysites Dropbox/Fiverr Campaign/Fiverr - Template.band" "$targetDirectory/Fiverr - $1 SAMPLE.band" + + + # Move the most recently downloaded file into the target directory + # Get the most recently downloaded file in downloads + mostRecentDownload=`find ~/Downloads -type f -iname $(ls -t ~/Downloads | head -1)` + echo Copying over $mostRecentDownload + cp "$mostRecentDownload" "$targetDirectory" + + touch "$targetDirectory/$1_notes.txt" + +} +alias setup-sample-directory=ssd + +# Package Fiverr Order +# --------------------------------------------- +pfo() { + fdir + + # zip the most recently touched mp3 with the thank you pdf + alias latestmp3='ls -1ct *.mp3 | head -1' + + # Determine the filename (with their fiverr username) + zipfile="`getUsername` - Thank You from John Delivers.zip" + + # Identify the PDF File I want to use + pdffile="/Users/johnny/Dropbox/Johnnys Documents/Jollysites Dropbox/Fiverr Campaign/Thank You Awesome Fiverr Customer.pdf" + pdffile="/Users/johnny/Dropbox/Johnnys Documents/Jollysites Dropbox/Fiverr Campaign/Bulk Orders Special Offer.pdf" + + #zip -X -j "$zipfile" "$latestmp3" "$pdffile" + zip -X -j "$zipfile" "`latestmp3`" "$pdffile" + + ls -l "`latestmp3`" + + if ls *.zip &> /dev/null; then + unzip -lv "$zipfile" + else + echo "$zipfile was apparently not created" + fi + +} +alias package-fiverr-order=pfo + +# Package Fiverr Order with All +# --------------------------------------------- +pfoAll() { + fdir + + # Determine the filename (with their fiverr username) + zipfile="`getUsername` - Thank You from John Delivers.zip" + + # Identify the PDF File I want to use + pdffile="/Users/johnny/Dropbox/Johnnys Documents/Jollysites Dropbox/Fiverr Campaign/Thank You Awesome Fiverr Customer.pdf" + pdffile="/Users/johnny/Dropbox/Johnnys Documents/Jollysites Dropbox/Fiverr Campaign/Bulk Orders Special Offer.pdf" + + zip -X -j "$zipfile" *.mp3 "$pdffile" + + ls -l *.mp3 + + if ls *.zip &> /dev/null; then + unzip -lv "$zipfile" + else + echo "$zipfile was apparently not created" + fi + +} +alias package-fiverr-order-with-all=pfoAll + +# Package Fiverr Sample +# --------------------------------------------- +pfs() { + fdir + + # zip the most recently touched mp3 with the thank you pdf + alias latestmp3='ls -1ct *.mp3 | head -1' + + # Determine the filename (with their fiverr username) + zipfile="`getUsername` - Thank You for letting me provide this sample.zip" + + # Identify the PDF File I want to use + pdffile="/Users/johnny/Dropbox/Johnnys Documents/Jollysites Dropbox/Fiverr Campaign/Here is the Sample you Requested.pdf" + + #zip -X -j "$zipfile" "$latestmp3" "$pdffile" + zip -X -j "$zipfile" "`latestmp3`" "$pdffile" + + ls -l "`latestmp3`" + + if ls *.zip &> /dev/null; then + unzip -lv "$zipfile" + else + echo "$zipfile was apparently not created" + fi + +} +alias package-fiverr-sample=pfs + + +# set start and end times (by making files with timestamped names) +function start() { + touch "Tstart $(date "+%F %H:%M:%S")"; + echo "Done"; +} +function finish() { + touch "Tdone $(date "+%F %H:%M:%S")"; + echo "Done"; +} + +getUsername(){ + current_dir="`PWD | sed -e 's/.*\- //'`" + echo $current_dir +} \ No newline at end of file diff --git a/bash/.my_bash_profile b/bash/.my_bash_profile new file mode 100644 index 0000000..c6253cd --- /dev/null +++ b/bash/.my_bash_profile @@ -0,0 +1,181 @@ + +chrome () { + /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome $* 2>&1 & +} + +# For Markdown Previewing +startgrip () { + echo "http://localhost:"$2 + grip --user-content --user=judgegroovyman --context=judgegroovyman/shiny-fortnight --pass=vanhalen1 $1 $2 +} + +# cd to the most recently modified directory +alias lcd='cd -- "$(ls -dt -- */ | head -1)"' + +# Jump to the latest sub-sub-directory in programs +alias pdir='cd "/Users/johnny/Dropbox/Johnnys Documents/programs";lcd;lcd' + +# \ +# Theres a backslash for you! + +# This synchronizes my kindle and Calibre directories +function syncTodaysKindleBooksToCalibre() { + kindleBookDirectory="/Users/johnny/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/My Kindle Content" + echo "$kindleBookDirectory" + cd "$kindleBookDirectory" + latestBooks=`find *.azw -mtime -1` + cp -n $latestBooks /Users/johnny/Documents/ebooks/Kindle +} +alias ksync=syncTodaysKindleBooksToCalibre +function syncTodaysCalibreBooksToDropbox(){ + calibreDirectory="/Users/johnny/Documents/ebooks" + cd "$calibreDirectory" + IFS=$'\n' + for file in $(find . -mtime -1 -iname '*.txt') ; do + echo $file + cp -n $file /Users/johnny/Dropbox/Johnnys\ Documents/Goodreader/Calibre + done + for file in $(find . -mtime -1 -iname '*.epub') ; do + echo $file + cp -n $file /Users/johnny/Dropbox/Johnnys\ Documents/Goodreader/Calibre_epub + done + + for file in $(find . -mtime -1 -iname '*.mobi') ; do + echo $file + cp -n $file /Users/johnny/Dropbox/Johnnys\ Documents/Goodreader/Calibre_mobi + done + + echo Complete + cd /Users/johnny/Dropbox/Johnnys\ Documents/Goodreader/ + find . -mtime -1 + +} +alias csync=syncTodaysCalibreBooksToDropbox + + +function fixvid() { avconvert -p PresetAppleM4V720pHD -s "$@" -o out.mp4;} + + +# a simple timer +function countWithDisplayTo() { date; +for (( c=1; c<=$@; c++ )) +do + sleep 1; + echo .; +done; +say "Ohmm"; +date;} +alias c="countWithDisplayTo" + +alias he="open '/Users/johnny/Dropbox/Johnnys Documents/help.rtf'" +alias bp="mate ~/.bp ~/.bash_profile ~/.fiverr_bash_profile ~/.bash_profile_voices ~/.dev_bash_profile" +alias mail="open /Applications/Mail.app" +alias ringtones="open /Users/johnny/Dropbox/Ringtones" + +# this is a simple list reminder of my most useful commands. I can type this anytime to remind me. +alias h="echo he, bp" + +# This is a keyboard maestro shortcut to copy the current safari tab to text mate +alias copytab="osascript -e 'tell application \"Keyboard Maestro Engine\" to do script \"ACEAF863-B21E-4AAC-A168-39BF1899FBFE\"'" + +function makegif2() { + convert +dither -colors 256 -delay 65 -loop 0 $1 $1 $2 $2 $2 $2 tempgif.gif + gifsicle --optimize tempgif.gif > newgif.gif + rm tempgif.gif +} +function makegif3() { + convert +dither -colors 256 -delay 65 -loop 0 $1 $1 $2 $2 $3 $3 $3 $3 tempgif.gif + gifsicle --optimize tempgif.gif > newgif.gif + rm tempgif.gif +} +function makegif() { + args=("$@") + filenameList="" + if [ "$#" -lt 1 ]; then + echo "Put pic parameters please ... " + fi + if [ "$#" -gt 0 ]; then + args=("$@") + + min=0; + max="$#" + for (( min=0; min<=max; min++ )) + do + if [ $min -eq 0 ]; then + filenameList="$filenameList ${args[$min]}" + filenameList="$filenameList ${args[$min]}" + filenameList="$filenameList ${args[$min]}" + fi + + filenameList="$filenameList ${args[$min]}" + filenameList="$filenameList ${args[$min]}" + + newmax=`expr $max - 1` + if [ $min -eq $newmax ]; then + filenameList="$filenameList ${args[$min]}" + filenameList="$filenameList ${args[$min]}" + filenameList="$filenameList ${args[$min]}" + fi + + + done; + + fi + + convert +dither -colors 256 -delay 65 -loop 0 $filenameList ./tempgif.gif + gifsicle --optimize tempgif.gif > newgif.gif + rm tempgif.gif +} + +function templateFunctionWithArgs() { + args=("$@") + echo $0 $1 $2 $3 + echo $args +} + +function chooseRandomFileFromDirectory() { + # Identify the directory with the files + files=(/Users/johnny/"Box Sync"/Fun/beavisandbutthead/*) + + # Determine how many files are in that directory + numberOfFiles=${#files[@]} + echo Total Number of Files: $numberOfFiles + + # Random Number from 0 to the number of files + randomnum=$((RANDOM % numberOfFiles)) + echo Random Number from 0 to $numberOfFiles: $randomnum + + # Choose the Random file + randomFile=${files[$randomnum]} + echo Random File: $randomFile + +} + +# Function: backup Chat +# --------------------------------------------- +backupiChat() { + + abbreviateddate=`date "+%b%d.%H%M"` + mdyDate=`date "+%m.%d.%Y"` + backupsDirectory="/Users/johnny/Desktop" + targetDirectory="$backupsDirectory/$mdyDate/$abbreviateddate" + echo Setting up new directory: $targetDirectory + mkdir -p $targetDirectory + + latestData="/Users/johnny/Library/Containers/com.apple.iChat" + echo "Copying $latestData" + echo "to $targetDirectory" + echo cp -r "$latestData" \"$targetDirectory\" | head + #cp -r "$latestData" \"$targetDirectory\" | head + sleep 1 + + latestData="/Users/johnny/Library/Messages" + echo "Copying $latestData" + echo "to $targetDirectory" + #cp -r "$latestData" "$targetDirectory" + + echo Done! +} +alias bchat=backupiChat; + + diff --git a/bash/.voices_bash_profile b/bash/.voices_bash_profile new file mode 100644 index 0000000..7f46e40 --- /dev/null +++ b/bash/.voices_bash_profile @@ -0,0 +1,41 @@ + + +function ov1() { say -v Karen -f "$@" -o "$@".Karen.m4a ;} +function ov2() { say -v Lee -f "$@" -o "$@".Lee.m4a ;} +function ov3() { say -v Fiona -f "$@" -o "$@".Fiona.m4a ;} +function ov4() { say -v Allison -f "$@" -o "$@".Allison.m4a ;} +function ov5() { say -v Ava -f "$@" -o "$@".Ava.m4a ;} +function ov6() { say -v Kathy -f "$@" -o "$@".Kathy.m4a ;} +function ov7() { say -v Samantha -f "$@" -o "$@".Samantha.m4a ;} +function ov8() { say -v Susan -f "$@" -o "$@".Susan.m4a ;} +function ov9() { say -v Alex -f "$@" -o "$@".Alex.m4a ;} +function ov10() { say -v Tom -f "$@" -o "$@".Tom.m4a ;} + +function sv() { say -v Kathy -f "$@" -o "$@".Kathy.m4a ; + say -v Vicki -f "$@" -o "$@".Vicki.m4a ; + say -v Victoria -f "$@" -o "$@".Victoria.m4a ; + say -v Alex -f "$@" -o "$@".Alex.m4a ; + say -v Bruce -f "$@" -o "$@".Bruce.m4a ; + say -v Fred -f "$@" -o "$@".Fred.m4a ;} +alias six_voices=“sv” + +function add_six_soundtracks_with_script.txt() { + say -v Kathy -f script.txt -o sdtrk.Kathy.m4a ; + muxmovie ./"$@" sdtrk.Kathy.m4a -self-contained -o Kathy_"$@" ; + rm sdtrk.Kathy.m4a ; + say -v Vicki -f script.txt -o sdtrk.Vicki.m4a ; + muxmovie ./"$@" sdtrk.Vicki.m4a -self-contained -o Vicki_"$@" ; + rm sdtrk.Vicki.m4a ; + say -v Victoria -f script.txt -o sdtrk.Victoria.m4a ; + muxmovie ./"$@" sdtrk.Victoria.m4a -self-contained -o Victoria_"$@" ; + rm sdtrk.Victoria.m4a ; + say -v Alex -f script.txt -o sdtrk.Alex.m4a ; + muxmovie ./"$@" sdtrk.Alex.m4a -self-contained -o Alex_"$@" ; + rm sdtrk.Alex.m4a ; + say -v Bruce -f script.txt -o sdtrk.Bruce.m4a ; + muxmovie ./"$@" sdtrk.Bruce.m4a -self-contained -o Bruce_"$@" ; + rm sdtrk.Bruce.m4a ; + say -v Fred -f script.txt -o sdtrk.Fred.m4a ; + muxmovie ./"$@" sdtrk.Fred.m4a -self-contained -o Fred_"$@" ; + rm sdtrk.Fred.m4a ;} +alias ss="add_six_soundtracks_with_script.txt" diff --git a/bash/HIDDEN_FILES_HERE b/bash/HIDDEN_FILES_HERE new file mode 100644 index 0000000..e69de29 diff --git a/bash/bash.md b/bash/bash.md new file mode 100644 index 0000000..2bb1cc5 --- /dev/null +++ b/bash/bash.md @@ -0,0 +1,15 @@ +# running bashrc # + +Mac doesn't execute `~/.bashrc` by default so you have to add `source ~/.bashrc` to `~/.bash_profile` + +# Functions or Aliases # + +```bash +FunctionName () { + commands +} +``` + + + + diff --git a/googlescript/CopyValidatedTextField.gs b/googlescript/CopyValidatedTextField.gs new file mode 100644 index 0000000..ffb363a --- /dev/null +++ b/googlescript/CopyValidatedTextField.gs @@ -0,0 +1,43 @@ +// How to use this: +// 1. From the GUI - Create a form with just one text field that has data validation applied +// 2. From there open the script editor and paste this in as the only code +// 3. Save, Run, then switch back to the form and hit 'preview' at the top +// 4. There should be two text fields now and they should have the same data validation +// Voila. + +// Background: Googlescript for some reason has not implemented any data validation api for forms :( +// Click the star the following google-issue to bring more attention to the problem: +// https://code.google.com/p/google-apps-script-issues/issues/detail?id=4216 + +// Solution: This is NOT a solution. This is merely a workaround for a small part of the missing APIs. +// I thought that while I can't add datavalidation through the API, I CAN duplicate fields through the API so ... +// maybe I can add datavalidation to a field manually and then copy that field. This would let me add new fields +// that have data validation in them as long as the specifics of the datavalidation don't need to change. + + +// Next Steps: Augment so the assumptions below aren't required. +// Consider starting a library of textfields with variously defined datavalidations +// This would let me choose between them in-script +// + +// Another Workaround: This seems to leverage an obscure JQuery library for validation +// I haven't tried this but it seems more advanced though perhaps more difficult to use +// http://morning.am/tutorials/google-forms-and-jquery-validation/ + +// Assumption 1: There is one currently open and active form on your account +// Assumption 2: That form has one and only one text field +// Assumption 3: That forms text field has had data validation added manually (through the GUI) +function CopyValidatedTextField() { + var form = FormApp.getActiveForm(); + Logger.log("Form ID: " + form.getId()); + var items = form.getItems(FormApp.ItemType.TEXT); + var stf; //SelectedTextField + for (var i in items) { + stf = items[i]; + Logger.log(items[i].getTitle() + ': ' + items[i].getId()); + } + // assuming one and only one text field exists + var newTextField = stf.duplicate(); + newTextField.setTitle("This is the copied field!!! - but does it do the same datavalidation?"); + +} diff --git a/googlescript/README.md b/googlescript/README.md new file mode 100644 index 0000000..6d3c9d4 --- /dev/null +++ b/googlescript/README.md @@ -0,0 +1,33 @@ +# shiny-fortnight + +### How to use this: +1. From the GUI - Create a form with just one text field that has data validation applied +2. From there open the script editor and paste this in as the only code +3. Save, Run, then switch back to the form and hit 'preview' at the top +4. There should be two text fields now and they should have the same data validation + Voila. + +### Background: +Googlescript for some reason has not implemented any data validation api for forms :( + Click the star the following google-issue to bring more attention to the problem: + https:code.google.com/p/google-apps-script-issues/issues/detail?id=4216 + +### Solution: This is NOT a solution. +This is merely a workaround for a small part of the missing APIs. + +### What I was thinking +I thought that while I can't add datavalidation through the API, I CAN duplicate fields through the API so ... maybe I can add datavalidation to a field manually and then copy that field. This would let me add new fields that have data validation in them as long as the specifics of the datavalidation don't need to change. + +### Next Steps: +* Augment so the assumptions below aren't required. +* Consider starting a library of textfields with variously defined datavalidations +* This would let me choose between them in-script + + +### Another Workaround: +This seems to leverage an obscure JQuery library for validation +I haven't tried this but it seems more advanced though perhaps more difficult to use +[Google Forms and Jquery Validation](http:morning.am/tutorials/google-forms-and-jquery-validation/) +* Assumption 1: There is one currently open and active form on your account +* Assumption 2: That form has one and only one text field +* Assumption 3: That forms text field has had data validation added manually (through the GUI) diff --git a/googlescript/SplitAllWordsIntoLongRow.gs b/googlescript/SplitAllWordsIntoLongRow.gs new file mode 100644 index 0000000..c68380b --- /dev/null +++ b/googlescript/SplitAllWordsIntoLongRow.gs @@ -0,0 +1,63 @@ +function SplitAllWordsIntoOneLongRow() { + + var inputSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Document With Words to Count"); + var outputSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Every Word"); + + var wordList = [], wordList2D = [], wordCounts = [], wordCounts2D = []; + linesRange = inputSheet.getRange("A:A"); + wordList = getAllWordsInRange(linesRange); + wordCounts = getWordCounts(wordList); + wordCounts2D = convertAssociativeArrayToTwoDimensional(wordCounts); + wordList2D = pushArrayAsSecondDimension(wordList,wordList2D); + + Logger.log(wordCounts2D); + outputSheet.getRange(1,1,wordCounts2D.length,2).setValues(wordCounts2D); + outputSheet.getRange(1,1,wordCounts2D.length,2).sort({column: 2, ascending: false}); +} + +function getAllWordsInRange(inputRange){ + var allWordsInRange = [], wordsInLine = [{}], curLine = ""; + var myLines = inputRange.getValues(); + + for (var row = 0; row < myLines.length; row++) { + if (myLines[row] != '') { + wordsInLine = myLines[row][0].replace(/[.,\/#!$%\^&\*;:{}="'?\-_`~()]/g,"").split(" "); + allWordsInRange.push.apply(allWordsInRange, wordsInLine); + } + } + return allWordsInRange; +} + +function getWordCounts(wordList){ + var wordCountAssociativeArray = [], curWord = ""; + for (var i = 0; i= 0.9 followers to friends +// Rules: <= 1.1 followers to friends + +function mayTheBestFollowersWin() { + // Make the original sheet active again + var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet(); + activeSpreadsheet.setActiveSheet(activeSpreadsheet.getSheetByName("Follower List Prior to Processing")); + + // Input: This is the sheet to read from + var inputSheet = SpreadsheetApp.getActiveSheet(); // originalSheet ***** + var inputSheetRows = inputSheet.getLastRow(); // How many rows in sheet + var inputSheetName = inputSheet.getName(); + + // Output: This is the sheet to write to + var outputSheetName = (new Date()).toLocaleDateString(); //uniqueName + // Create the new sheet (if it already exists then delete it) + var outputSheet = activeSpreadsheet.getSheetByName(outputSheetName); // bestFollowersSheet ***** + if (outputSheet != null) { activeSpreadsheet.deleteSheet(outputSheet); } + outputSheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet(outputSheetName); + + var cRow = 1; // currentRow - keep track of what line we should be writing to right now + var ScreenName, Followers, FriendsWith, FFRatio, DateOfLastTweet, TodaysDate, TimeSinceLastTweet; + + // For every row of the input sheet ***** + for (var i=2; i<=inputSheetRows; i+=1) { + // Extract and Calculate the data we need + ScreenName = inputSheet.getRange(i,1).getValue(); + Followers = inputSheet.getRange(i,6).getValue(); + FriendsWith = inputSheet.getRange(i,7).getValue(); + FFRatio = Followers/FriendsWith; + DateOfLastTweet = inputSheet.getRange(i,13).getValue(); // #TODO: When the spreadsheet format changes these will too + TodaysDate = getCurrentTimeInDays(); + TimeSinceLastTweet = TodaysDate-DateOfLastTweet; + + // Does this user meet our strict criteria + if (0.9 < FFRatio < 1.1) { + if (TimeSinceLastTweet < 1.1) { + Logger.log("%s: Date: %s TimeSince: %s", ScreenName, DateOfLastTweet, TimeSinceLastTweet); + + // If criteria are met + // Write the data out to the output sheet + var myDestination = outputSheet.getRange(cRow,1); + myDestination.setValue(ScreenName); + myDestination = outputSheet.getRange(cRow,2); + myDestination.setValue(FFRatio); + myDestination = outputSheet.getRange(cRow,3); + myDestination.setValue(DateOfLastTweet); + myDestination = outputSheet.getRange(cRow,4); + myDestination.setValue(TimeSinceLastTweet); + + // Increment the line + cRow++; + } + } + } + + function getCurrentTimeInDays(){ + + var myDestination = outputSheet.getRange(cRow,5); + myDestination.setValue("=TODAY()"); + var magicNumber = 25568; // Not particularly proud of this but I'm giving up trying to convert between excel numeric dates and javascript numeric dates. *should* be SO SIMPLE!?! + var adjustment = -1.4; // actually I pulled all of this a day earlier so I'm giving them some slack + // #TODO: zeroize the adjustment the next time I run this because the dates will be fresh then + return new Date().getTime()/1000/60/60/24 + magicNumber + adjustment; + } +} \ No newline at end of file diff --git a/googlescript/highlightText.gs b/googlescript/highlightText.gs new file mode 100644 index 0000000..c7d63be --- /dev/null +++ b/googlescript/highlightText.gs @@ -0,0 +1,19 @@ +function highlightText(findMe) { + var body = DocumentApp.getActiveDocument().getBody(); + var foundElement = body.findText(findMe); + + while (foundElement != null) { + // Get the text object from the element + var foundText = foundElement.getElement().asText(); + + // Where in the Element is the found text? + var start = foundElement.getStartOffset(); + var end = foundElement.getEndOffsetInclusive(); + + // Change the background color to yellow + foundText.setBackgroundColor(start, end, "#FCFC00"); + + // Find the next match + foundElement = body.findText(findMe, foundElement); + } +} \ No newline at end of file diff --git a/googlescript/keywordTShirtSizes.gs b/googlescript/keywordTShirtSizes.gs new file mode 100644 index 0000000..da6ae49 --- /dev/null +++ b/googlescript/keywordTShirtSizes.gs @@ -0,0 +1,84 @@ +// This script takes the spreadsheet as it is output by the google keyword planner +// Then splits the keywords into 3 groups: Small, Medium, High +// It overwrites the first three columns to do so +function KeywordTShirtSizes() { + var sheet = SpreadsheetApp.getActiveSheet(); + var numRows = sheet.getLastRow()-1; // How many rows in sheet + + // Where to output Small Keywords + var sRow = 1; + var sCol = 1; + // Where to output Medium Keywords + var mRow = 1; + var mCol = 3; + // Where to output Large Keywords + var lRow = 1; + var lCol = 5; + + var myDestination = 0; + var myRow = 0; + var myCol = 0; + + // Data starts on row 7 + for (var i=7; i 50) { + if (volume < 150) { + myRow = sRow++; + myCol = sCol; + + + // Output the Keywords + myDestination = sheet.getRange(myRow,myCol); + myDestination.setValue(keyword); + + // Output the Volume + myDestination = sheet.getRange(myRow,myCol+1); + myDestination.setValue(volume); + } + } + + // Medium + if (volume > 150) { + if (volume < 500) { + myRow = mRow++; + myCol = mCol; + + + // Output the Keywords + myDestination = sheet.getRange(myRow,myCol); + myDestination.setValue(keyword); + + // Output the Volume + myDestination = sheet.getRange(myRow,myCol+1); + myDestination.setValue(volume); + } + } + + // Large + if (volume > 500) { + if (volume < 800) { + myRow = lRow++; + myCol = lCol; + + + // Output the Keywords + myDestination = sheet.getRange(myRow,myCol); + myDestination.setValue(keyword); + + // Output the Volume + myDestination = sheet.getRange(myRow,myCol+1); + myDestination.setValue(volume); + } + } + + } +} diff --git a/googlescript/snippets/README.txt b/googlescript/snippets/README.txt new file mode 100644 index 0000000..d6b853e --- /dev/null +++ b/googlescript/snippets/README.txt @@ -0,0 +1 @@ +// Note: This is a snippet bucket of tricks and as a result is not expected to compile diff --git a/googlescript/snippets/count_rows.gs b/googlescript/snippets/count_rows.gs new file mode 100644 index 0000000..60ade63 --- /dev/null +++ b/googlescript/snippets/count_rows.gs @@ -0,0 +1 @@ + var numRows = sheet.getLastRow(); // How many rows in sheet diff --git a/googlescript/snippets/get_unique_date.gs b/googlescript/snippets/get_unique_date.gs new file mode 100644 index 0000000..01b6eda --- /dev/null +++ b/googlescript/snippets/get_unique_date.gs @@ -0,0 +1,2 @@ + var name = (new Date()).toLocaleDateString(); + var bFS = SpreadsheetApp.getActiveSpreadsheet().insertSheet(name); // bestFollowersSheet diff --git a/googlescript/snippets/insert_new_sheet.gs b/googlescript/snippets/insert_new_sheet.gs new file mode 100644 index 0000000..5bcf635 --- /dev/null +++ b/googlescript/snippets/insert_new_sheet.gs @@ -0,0 +1,15 @@ + var name = (new Date()).toLocaleDateString(); + var bFS = SpreadsheetApp.getActiveSpreadsheet().insertSheet(name); // bestFollowersSheet + + +or + + var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet(); + var yourNewSheet = activeSpreadsheet.getSheetByName("Name of your new sheet"); + + if (yourNewSheet != null) { + activeSpreadsheet.deleteSheet(yourNewSheet); + } + + yourNewSheet = activeSpreadsheet.insertSheet(); + yourNewSheet.setName("Name of your new sheet"); \ No newline at end of file diff --git a/googlescript/snippets/iterate_through_rows.gs b/googlescript/snippets/iterate_through_rows.gs new file mode 100644 index 0000000..c87713c --- /dev/null +++ b/googlescript/snippets/iterate_through_rows.gs @@ -0,0 +1,32 @@ +//Sets the row color depending on the value in the "Status" column. +function setRowColors() { + var range = SpreadsheetApp.getActiveSheet().getDataRange(); + var statusColumnOffset = getStatusColumnOffset(); + + for (var i = range.getRow(); i < range.getLastRow(); i++) { + rowRange = range.offset(i, 0, 1); + status = rowRange.offset(0, statusColumnOffset).getValue(); + if (status == 'Completed') { + rowRange.setBackgroundColor("#99CC99"); + } else if (status == 'In Progress') { + rowRange.setBackgroundColor("#FFDD88"); + } else if (status == 'Not Started') { + rowRange.setBackgroundColor("#CC6666"); + } + } +} + +//Returns the offset value of the column titled "Status" +//(eg, if the 7th column is labeled "Status", this function returns 6) +function getStatusColumnOffset() { + lastColumn = SpreadsheetApp.getActiveSheet().getLastColumn(); + var range = SpreadsheetApp.getActiveSheet().getRange(1,1,1,lastColumn); + + for (var i = 0; i < range.getLastColumn(); i++) { + if (range.offset(0, i, 1, 1).getValue() == "Status") { + return i; + } + } +} + + diff --git a/googlescript/snippets/iterate_through_rows_2.gs b/googlescript/snippets/iterate_through_rows_2.gs new file mode 100644 index 0000000..e635090 --- /dev/null +++ b/googlescript/snippets/iterate_through_rows_2.gs @@ -0,0 +1,10 @@ +function SplitInto50() { + var sheet = SpreadsheetApp.getActiveSheet(); + var numRows = sheet.getLastRow()-1; // How many rows in sheet + var outputColumn = 2 + for (var i=2; i