Skip to content

Instantly share code, notes, and snippets.

@josephholsten
josephholsten / highlight-names.md
Last active November 10, 2023 19:31
Tree Sitter Highlight Classes

I've noticed that some of the themes in helix are using undocumented highlight selectors. Well that's no surprise, these are comming from highlight.scm files in tree-sitter grammars, while the least terrible reference to these classes seems to be https://docs.helix-editor.com/themes.html

We can do better. So first I'm going to just start collecting notes from existing grammars. Two main things will be here: references to "standard" classes, and also guidance for how to change "non-standard" classes.

Standard

Current doc source: https://github.com/helix-editor/helix/blob/master/book/src/themes.md

  • attribute - Class attributes, HTML tag attributes
#!/bin/sh
die()
{
[ $# -eq 0 ] && exit 1
[ $# -gt 1 ] && \
echo "error initiated at line $1 :
$2" 1>&2 || \
echo "$1" 1>&2
#cloud-config
write_files:
- path: /etc/cinc/client.rb
permissions: '0644'
owner: root:root
content: |
chef_server_url "${chef_server_url}"
- path: /etc/cinc/validation.pem
permissions: '0644'
@josephholsten
josephholsten / fib.js
Created July 21, 2017 08:10
Fibonacci for Webtask.io
var request = require('request')
// Fib takes an integer from the query param q, recursively calculates the fibonacci function and returns its value
var Fib = function (context, callback) {
// apiURI should be set to the URI for this webtask
var api = context.secrets.apiURI
// fib(x) is provided by the query param "q"
var x = parseInt(context.data.q)
switch (x) {
case 0:
@josephholsten
josephholsten / fasd-fzf.sh
Last active June 21, 2017 22:54
fasd with fzf for interactive selection
# same default aliases as fasd, but with fzf(1) for interactive selection
# fzf(1)
export FZF_DEFAULT_COMMAND='ag -g ""'
FZF_PATH="/usr/local/opt/fzf"
if [ -f "$COMPLETION_PATH" ]; then
source "$FZF_PATH/shell/completion.bash"
source "$FZF_PATH/shell/key-bindings.bash"
fi
class Chef::Node
# dig takes a node or databag and traverses through node/hash attributes according to the provided path
# databagitem.dig('this.attribute.here')
def dig(path, default=nil)
# works fine in chef 10
path.split(".").inject(self) do |l,k|
if l.respond_to?(:keys)
(l.to_hash[k] || l.to_hash[k.to_sym] || default)
else
default

Keybase proof

I hereby claim:

  • I am josephholsten on github.
  • I am josephholsten (https://keybase.io/josephholsten) on keybase.
  • I have a public key whose fingerprint is 7E72 3E2A 5F1F 457B 74F4 D581 6E32 20D0 113E F38D

To claim this, I am signing this object:

@josephholsten
josephholsten / check-http-json.rb
Created January 4, 2016 06:53
Simplest HTTP+JSON sensu plugin
#! /usr/bin/env ruby
# check-simple-http-json - show how to check a url, grab its json, and
require 'sensu-plugin/check/cli'
require 'json'
require 'net/http'
require 'uri'
class CheckSimpleHttpJson < Sensu::Plugin::Check::CLI
option :url,