This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set par(justify: true) | |
*Goal*: being able to add line numbers, which are correct even in case of long lines that need wrapping. | |
*Strategy*: duplicate the code block, once for getting the line numbers correct, and the other for syntax highlighting. The idea is to split lines and prefix each line with its line number such that line wrapping should be respected. | |
#show raw.where(block: true): it => { set par(justify: false); grid( | |
columns: (100%, 100%), | |
column-gutter: -100%, | |
block(width: 100%, inset: 1em, for i, line in it.text.split("\n") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function varargout = cached(cache_filepath, f, varargin ) | |
if exist(cache_filepath, 'file') == 2 | |
load(cache_filepath, 'varargout'); | |
else | |
[varargout{1:nargout}] = f( varargin{:} ); | |
save(cache_filepath, 'varargout'); | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Msg = Debounce VirtualTime | ... | |
-- create a deferred (by timeout) command taking currentVirtualTime as an argument | |
checkIfNothingHappenedIn : Time -> VirtualTime -> Cmd Msg | |
checkIfNothingHappenedIn timeout currentVirtualTime = | |
deferredCmd timeout (Debounce currentVirtualTime) | |
deferredCmd : Time -> Msg -> Cmd Msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isItLongEnoughCmd : Cmd Msg | |
isItLongEnoughCmd = Task.perform IsItLongEnough Time.now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type alias Model = { ... , state : Debounce.State } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Avoid costly calculations while the window size is in flux. | |
jQuery(window).on(‘resize’, _.debounce(calculateLayout, 150)); |