Skip to content

Instantly share code, notes, and snippets.


Michal Srb xixixao

  • Facebook
  • London, UK
View GitHub Profile
xixixao / drawBetterSelection.js
Last active Jun 13, 2021
Mac-like selection background for Codemirror6
View drawBetterSelection.js
import { drawSelection, ViewPlugin, Direction } from "@codemirror/view";
import { combineConfig, Facet, EditorSelection } from "@codemirror/state";
const [_, _2, hideNativeSelection] = drawSelection();
const selectionConfig = Facet.define({
combine(configs) {
return combineConfig(
View testfile.js
* Given the starting source, starting position, and the ending source this
* function guesses where the cursor should move to.
function updateCursor(
startSource: string,
startPosition: {row: number, column: number},
endSource: string,
): {row: number, column: number} {
for (const accuracy of ACCURACIES) {
View CoffeeScript.tmLanguage
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
# This script create a new repo on, then pushes to it the local repo from the current directory.
# It is a fork of Some of Rob's lines just didn't work for me, and to fix them I needed to make it more verbose so that a mere electrical engineer could understand it.
# This script gets a username from .gitconfig. If it indicates that your default username is an empty string, you can set it with
# git config --add github.user YOUR_GIT_USERNAME
# Gather constant vars
xixixao / discrete-event-simulation
Created Dec 4, 2013 Run like: > (new Simulation (ExponentialSampler 2), (ConstantSampler 2)).run 100
View discrete-event-simulation
# (new Simulation (ExponentialSampler 2), (ConstantSampler 2)).run 100
class Simulation
constructor: (@interArrival, @serviceTime) ->
@events = []
@t = 0
@population = 0
xixixao / Switch
Created Apr 3, 2013
Clojure vs Coffee
View Switch
#(defn parting
# "returns a String parting in a given language"
# ([] (parting "World"))
# ([name] (parting name "en"))
# ([name language]
# (condp = language
# "en" (str "Goodbye, " name)
# "es" (str "Adios, " name)
# (throw (IllegalArgumentException.
# (str "unsupported language " language))))))
View gist:4fb78f5f9569b40c01fc
+ (macro [x y]
(: (Fn Num Num Num))
(Js.binary "+" x y))
- (macro [what from]
(: (Fn Num Num Num))
(Js.binary "-" from what))
* (macro [x y]
(: (Fn Num Num Num))
View gist:e8b74ff74e98bdd0c137
Rules (type (Map Char String))
System (record angle: Num base: (List Char) rules: Rules)
tree (fn [angle] (System angle
\M "N[-M][+M][NM]"
\N "NN"
\[ "["
\] "]"
{task, watch, serve} = require 'gump'
bower = require 'gulp-bower-files'
flatten = require 'gulp-flatten'
stylus = require 'gulp-stylus'
jade = require 'gulp-jade'
clean = require 'gulp-clean'
task 'default',
-> watch 'sources'
render: ->
_.table _,
_.thead _, _, "BV" "x1" "x2" "x3" "x4" "RHS"