bip - business in progress Heiner Paulsen, Dennis Junker 17. Apr 2018 Heiner Paulsen, Dennis Junker bip - business in progress 17. Apr 2018 1 / 10 bip Enterprise Resource Planning (ERP) for Finance & Accounting Human resources Order Processing Supply chain management Project management Customer relationship management ... Heiner Paulsen, Dennis Junker bip - business in progress 17. Apr 2018 2 / 10 project development Heiner Paulsen, Dennis Junker bip - business in progress 17. Apr 2018 3 / 10 generic DB-access HTTP-Server E-Mailing CSV/Excel import/export XBRL odt/pdf printfiles ... Heiner Paulsen, Dennis Junker bip - business in progress 17. Apr 2018 4 / 10 overview Heiner Paulsen, Dennis Junker bip - business in progress 17. Apr 2018 5 / 10 classes classes classes why Common LISP? Macros class description method definition print settings error handling writing log files message to browser roll-back on error process clean up restart while debugging accomplished shutdown recompiling ... Heiner Paulsen, Dennis Junker bip - business in progress 17. Apr 2018 9 / 10 bip - business in progress Heiner Paulsen, Dennis Junker 17. Apr 2018 Heiner Paulsen, Dennis Junker bip - business in progress 17. Apr 2018 10 / 10 Self-modifying code (for fun and profit) Simple steps ● Ensure that DISASSEMBLE + reassemble is perfectly faithful to the original machine code ● Manipulate the asm (fun) prior to re-assembly ● Reap benefits (profit) Example 1: static linking / unlinking * (defun f (x) (g x)) * (disassemble 'f) ... ; B0: FF7508 ; B3: E98002F5FD PUSH QWORD PTR [RBP+8] JMP #x204BA038 # * (disassemble-memory #x204BA038 5) ; Size: 5 bytes. Origin: #x204BA038 ; 8: E973FA0A02 JMP #x22569AB0 After static linking: ; B0: FF7508 ; B3: E9F8FCFFFF # PUSH QWORD PTR [RBP+8] JMP #x22569AB0 # Did it work? Before: perf stat baseline/sbcl --load make-host-1.sh 27,054,177,733 branches # 766.426 M/sec 35.313061039 seconds time elapsed After: perf stat experiment/sbcl --load make-host-1.sh 26,135,644,543 branches 32.360553825 seconds time elapsed # 809.109 M/sec Example 2: Precise heap use profiler (defun f (n) (list (make-string n :element-type 'base-char))) ; 6B1: 4D8B5D18 MOV R11, [R13+24] ; 6B5: 4D85DB TEST R11, R11 ; 6B8: EB16 JMP L0 ; 6BA: 660F1F440000 NOP ; 6C0: FF14253800B021 CALL QWORD PTR [#x21B00038] ENABLE-SIZED-ALLOC-COUNTER ; 6C7: 90 NOP ; 6C8: 4885C0 TEST RAX, RAX ; 6CB: 0F1F440000 NOP ; 6D0: L0 ; Run it * (sb-aprof::aprof-run (lambda () (f 15))) % Bytes Count Function 100.0 48 F 66.7 32 1 SIMPLE-BASE-STRING 33.3 16 1 LIST * (disassemble ’f) ; 6C0: F049FF8318000000 LOCK INC QWORD PTR [R11+24] ; 6C8: F049018320000000 LOCK ADD [R11+32], RAX Example 3: ELFinating an executable 1. 2. 3. 4. Disassemble everything Emit as textual assembly into ‘tempfile.s’ “cc -o exename tempfile.s $(SBCL_OBJS)” “perf record exename && perf report --stdio” 3.35% exename (flet gethash3) 3.24% libc-2.24.so 1.68% exename 1.26% exename with-recursive-system-lock-thunk in __memset_erms sb-c::lz-compress cl:equal Learning Kanji with Emacs Wojciech Gac wojciech.s.gac@gmail.com April 17, 2018 Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 1 / 10 Motivation Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 2 / 10 Motivation Japanese writing system Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 2 / 10 Motivation Japanese writing system I Hiragana Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 2 / 10 Motivation Japanese writing system I Hiragana - 46 characters (plus modifiers) Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 2 / 10 Motivation Japanese writing system I I Hiragana - 46 characters (plus modifiers) Katakana Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 2 / 10 Motivation Japanese writing system I I Hiragana - 46 characters (plus modifiers) Katakana - 46 characters (plus modifiers) Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 2 / 10 Motivation Japanese writing system I I I Hiragana - 46 characters (plus modifiers) Katakana - 46 characters (plus modifiers) Kanji Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 2 / 10 Motivation Japanese writing system I I I Hiragana - 46 characters (plus modifiers) Katakana - 46 characters (plus modifiers) Kanji - 2,000 - 3,000 in common use, Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 2 / 10 Motivation Japanese writing system I I I Hiragana - 46 characters (plus modifiers) Katakana - 46 characters (plus modifiers) Kanji - 2,000 - 3,000 in common use, 13,108 covered by industrial standards Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 2 / 10 Two-fold path of su↵ering Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 3 / 10 Two-fold path of su↵ering Learning the stroke order of characters Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 3 / 10 Two-fold path of su↵ering Learning the stroke order of characters Transcribing Kanji to Hiragana Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 3 / 10 Stroke order Position cursor over a character Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 4 / 10 Stroke order Get a diagram of stroke orders Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 4 / 10 Transcription Mark text containing Kanji Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 5 / 10 Transcription Transcribe it to Hiragana Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 5 / 10 Oh yeah. The Lisp thing... ( defun k a n j i m o d e s t r o k e o r d e r ( p o i n t ) ” Take c h a r a c t e r a t p o i n t and t r y t o d i s p l a y i t s stroke order . ” ( i n t e r a c t i v e ”d” ) ( l e t ( ( char ( c h a r a f t e r p o i n t ) ) ) (km : c r e a t e b u f f e r w i t h i m a g e (km : char to hex char ) ) ) ) Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 6 / 10 Oh yeah. The Lisp thing... ( defun km : c r e a t e b u f f e r w i t h i m a g e ( name ) ” C r e a t e new b u f f e r w i t h r e l e v a n t image and s w i t c h to i t . B u f f e r can be c l o s e d by h i t t i n g ‘ q ‘ ” ( w i t h c u r r e n t b u f f e r ( g e n e r a t e n e w b u f f e r name ) ( l e t ( ( image ( g e t s v g f o r k a n j i c o d e name ) ) ) ( iimage mode ) ( iimage mode buffer t ) ( i n s e r t i m a g e image ) ( l o c a l s e t k e y ( kbd ”q” ) ’ k i l l t h i s b u f f e r ) ( switch to buffer ( current buffer ) ) ) ) ) Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 7 / 10 Oh yeah. The Lisp thing... ( defun g e t s v g f o r k a n j i c o d e ( code ) ” R e t u r n an image o b j e c t f o r t h e U n i c o d e code provided . ” ( l e t ( ( image path ( c o n c a t ( expand file name code ⇤ kanji svg path ⇤) ” . svg ” ) ) ) ( c r e a t e i m a g e image path ) ) ) Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 8 / 10 Shoulders of Giants Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 9 / 10 Shoulders of Giants KanjiVG (https://kanjivg.tagaini.net/) Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 9 / 10 Shoulders of Giants KanjiVG (https://kanjivg.tagaini.net/) Kakasi (http://kakasi.namazu.org/) Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 9 / 10 Thank you GitHub - https://github.com/wsgac/kanji-mode MELPA - kanji-mode Wojciech Gacwojciech.s.gac@gmail.com Learning Kanji with Emacs April 17, 2018 10 / 10 I needed a tool for defining and describing protocols and test cases I needed a tool for defining and describing protocols and test cases I needed a tool for defining and describing protocols and test cases I needed a tool for defining andNdescribing e year protocols and testxtcases Next year Protocols „Don’t get so obsessed over protocols.” Protocols „Don’t get so obsessed over protocols.” ~ Robert Strandh, 16th April 2018 Protocols ● Protocol: a set of bindings between operations and data types Protocols ● ● Protocol: a set of bindings between operations and data types Operations: generic functions, macros, ... Protocols ● ● ● Protocol: a set of bindings between operations and data types Operations: generic functions, macros, ... Data types: classes, condition types, ... Protocols ● ● ● ● Protocol: a set of bindings between operations and data types Operations: generic functions, macros, ... Data types: classes, condition types, ... See http://metamodular.com/protocol.pdf Example protocol Example protocol fuelable Example protocol fuelable Example protocol fuelable Example protocol fuelable Example protocol fuelable ● ● (fuel fuelable) (setf (fuel fuelable) new-value) Example protocol fuelable ● ● (fuel fuelable) (setf (fuel fuelable) new-value) (define-protocol fuelable () (:function fuel (object)) (:function (setf fuel) (new-value object))) Example protocol fuelable ● ● (fuel fuelable) (setf (fuel fuelable) new-value) (define-protocol fuelable () (:function fuel (object)) (:function (setf fuel) (new-value object))) (DEFGENERIC FUEL (OBJECT)) (DEFGENERIC (SETF FUEL) (NEW-VALUE OBJECT)) Example protocol fuelable ● ● (fuel fuelable) (setf (fuel fuelable) new-value) (define-protocol fuelable () (:function fuel ((object fuelable)) real) (:function (setf fuel) ((new-value real) (object fuelable)) real)) (DEFGENERIC FUEL (OBJECT)) (DECLAIM (FTYPE (FUNCTION (FUELABLE) REAL) FUEL)) (DEFGENERIC (SETF FUEL) (NEW-VALUE OBJECT)) (DECLAIM (FTYPE (FUNCTION (REAL FUELABLE) REAL) (SETF FUEL))) Example protocol fuelable ● ● (fuel fuelable) (setf (fuel fuelable) new-value) (define-protocol fuelable (:export (fuel)) (:function fuel ((object fuelable)) real) (:function (setf fuel) ((new-value real) (object fuelable)) real)) (DEFGENERIC FUEL (OBJECT)) (DECLAIM (FTYPE (FUNCTION (FUELABLE) REAL) FUEL)) (DEFGENERIC (SETF FUEL) (NEW-VALUE OBJECT)) (DECLAIM (FTYPE (FUNCTION (REAL FUELABLE) REAL) (SETF FUEL))) (EXPORT ‘(FUEL)) Example protocol fuelable ● ● (fuel fuelable) (setf (fuel fuelable) new-value) (define-protocol fuelable (:export (fuel) :documentation „Describes objects which require some sort of fuel in order to function. Fuel is understood as a numerical value.”) (:function fuel ((object fuelable)) real) „Retrieves the amount of fuel in the fuelable.” (:function (setf fuel) ((new-value real) (object fuelable)) real) „Sets the amount of fuel in the fuelable.”) Example protocol fuelable ● ● (fuel fuelable) (setf (fuel fuelable) new-value) (define-protocol fuelable (:export (fuel) :documentation „Describes objects which require some sort of fuel in order to function. Fuel is understood as a numerical value.”) (:function fuel ((object fuelable)) real) „Retrieves the amount of fuel in the fuelable.” (:function (setf fuel) ((new-value real) (object fuelable)) real) „Sets the amount of fuel in the fuelable.”) (find-protocol ‘fuelable) ;; => # Inheritance fuelable Inheritance fuelable wheeled automobile Inheritance fuelable wheeled automobile Future work PROTEST is a work in progress Future work PROTEST is a work in progress ● Does class FOO participate in protocol BAR? Future work PROTEST is a work in progress ● ● Does class FOO participate in protocol BAR? How does class FOO participate in protocol BAR? Future work PROTEST is a work in progress ● ● ● Does class FOO participate in protocol BAR? How does class FOO participate in protocol BAR? Output HTML/TeX – via CCLDoc Future work PROTEST is a work in progress ● ● ● ● Does class FOO participate in protocol BAR? How does class FOO participate in protocol BAR? Output HTML/TeX – via CCLDoc Broaden the documentation Future work PROTEST is a work in progress ● ● ● ● ● Does class FOO participate in protocol BAR? How does class FOO participate in protocol BAR? Output HTML/TeX – via CCLDoc Broaden the documentation Write a paper Future work PROTEST is a work in progress ● ● ● ● ● ● Does class FOO participate in protocol BAR? How does class FOO participate in protocol BAR? Output HTML/TeX – via CCLDoc Broaden the documentation Write a paper Check if we have any time for questions Reddit 1.0 (and some table flips) ● CMUCL-specific code CMUCL-specific code ● No documentation or tests ● CMUCL-specific code ● No documentation or tests ● Rough code quality ● CMUCL-specific code ● No documentation or tests ● Rough code quality ● Missing database schema ● CMUCL-specific code ● No documentation or tests ● Rough code quality ● Missing database schema ● Plaintext passwords in database ● ( ಠ⇥ಠ) ⇤┻━┻ ● Somewhat understandable code Somewhat understandable code ● Very few calls to CMUCL primitives (sockets and threads) ● Somewhat understandable code ● Very few calls to CMUCL primitives (sockets and threads) ● It worked! ● Somewhat understandable code ● Very few calls to CMUCL primitives (sockets and threads) ● It worked! ● It worked well enough to boost Reddit into its current size ● ┬─┬ (º_º ) *actually not that easy ┻━┻ ⌅ ¯\(⇧)/¯ ⌅ ┻━┻ FIN