Skip to content

Instantly share code, notes, and snippets.

View fourier's full-sized avatar

fourier fourier

View GitHub Profile
@fourier
fourier / factor.lisp
Last active April 25, 2020 09:58
Modifiable environment around function
(defun make-modifieable-adder (initial-factor)
"Creates a pair of 2 functions - one to update
multiplication factor and one to add 2 numbers and multiply
by the multiplication factor"
(let ((mul-factor initial-factor))
(cons
(lambda (new-mul-factor)
(setf mul-factor new-mul-factor))
(lambda (x y)
(* (+ x y) mul-factor)))))
@fourier
fourier / cquery_usage.md
Last active April 9, 2020 17:27
Using cquery with Emacs
@fourier
fourier / funny_bug.c
Created March 19, 2020 14:28
a funny bug
int id = 0;
printf("Id: %d, name: %s\n", id, spec[id]);
printf("Name: %s, Id: %d\n", spec[id], id);
printf("Name: %s\n", spec[id]);
printf("Id: %d\n", id);
// output:
// Id: 0, name: first
// Name: first, Id: 4243464
We are aiming for players to play with pings as close as possible to the pings they used to in their practice games. Some games will be played with a higher ping than usual, however for the European players one should be able to play with a maximum ping 38ms (or at least 52ms in worst cases) for BOTH players.
In general the game can be played on any server both players agree to play on. The tournament Admins insist that the players' server-choice is done with common sense and that pings are kept as low as possible.
However if the players don't agree, the server is determined by the following procedure:
1. Both players have to show their lowest possible ping they can get on 1on1 servers from the list of accredited* servers (see the table below).
2. After that a server has to be found where both players get a ping calculated by the following formula: P1 + N vs P2 + N, where P1 and P2 - best pings to the accredited servers, N is the equal increase of the ping for both players (N could vary in 1-2ms)
Example 1:
@fourier
fourier / cmd.diff
Created June 27, 2019 13:46
Diff command for lisp functions
I find the following diff flags helpful: --ignore-space-change -u -F '\''^(def'\''
@fourier
fourier / lw-config.lisp
Created October 25, 2018 16:27
Simple LispWorks Personal configuration
#-:LISPWORKS-PERSONAL-EDITION (load-all-patches)
#+(and LISPWORKS-PERSONAL-EDITION MSWINDOWS) (load "C:/apps/asdf/asdf.lisp")
;;; The following lines added by ql:add-to-init-file:
#-quicklisp
(let ((quicklisp-init #+:MSWINDOWS "C:/apps/quicklisp/setup.lisp"
#-:MSWINDOWS (merge-pathnames ".quicklisp/setup.lisp"
(user-homedir-pathname))))
(format *standard-output* "ql init: ~s" quicklisp-init)
(when (probe-file quicklisp-init)
@fourier
fourier / gist:70bf9fde027c203aff3a2d4a9f8f4323
Last active October 20, 2018 20:21
LispWorks notes about undefined function
CL-USER 12 > (compile-file "c:/Sources/lisp/test-undefined.lisp")
;;; Compiling file c:/Sources/lisp/test-undefined.lisp ...
;;; Safety = 3, Speed = 1, Space = 1, Float = 1, Interruptible = 1
;;; Compilation speed = 1, Debug = 2, Fixnum safety = 3
;;; Source level debugging is on
;;; Source file recording is on
;;; Cross referencing is on
; (top-level-form 0)
; crap
;; Processing Cross Reference Information
@fourier
fourier / macro-logger.lisp
Created October 14, 2018 15:50
Log wrapper around function, macro Common Lisp
(defmacro def-log-fun ((name &rest params) &body body)
(let* ((result-name (gensym))
(params-list
(loop for iter-var in params
collect `(format t ,(concatenate 'string (symbol-name iter-var) ": ~a~%") ,iter-var))))
`(defun ,name (,@params)
(progn
(format t "params:~%")
,@params-list
(let ((,result-name ,@body))
@fourier
fourier / esc.el
Created January 29, 2018 22:11
Emacs bind esc to close temporary windows
;; use Esc to close temporary windows
(let ((hotkey
(if window-system (kbd "<escape>") "\M-q")))
(global-set-key hotkey 'txm-close-temporary-window)
;; in cc-modes M-q redefined
(define-key c-mode-map hotkey 'txm-close-temporary-window)
(define-key c++-mode-map hotkey 'txm-close-temporary-window))
(defun txm-close-temporary-window ()
"Close all temporary windows in current frame.
@fourier
fourier / erc-customize.el
Created January 7, 2016 22:03
Ctrl-up/down in ERC to move between phrases
;; Use ctrl up/down to move between users phrases of different users
(define-key erc-mode-map [C-up] 'txm-goto-previous-phrase)
(define-key erc-mode-map [C-down] 'txm-goto-next-phrase)
(defun txm-goto-previous-phrase ()
"Go to the previous phrase"
(interactive)
;; first go to the beginning of the line
(goto-char
(line-beginning-position))