Skip to content

Instantly share code, notes, and snippets.

View wmertens's full-sized avatar

Wout Mertens wmertens

View GitHub Profile
@wmertens
wmertens / nix.tmLanguage
Created December 1, 2014 00:05
Nix syntax highlighting in TextMate format
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>nix</string>
</array>
<key>name</key>
<string>Nix</string>
@wmertens
wmertens / nix.YAML-tmLanguage
Last active October 6, 2022 19:42
Syntax highlighting for Nix in Sublime Text YAML-tmLanguage format
# [PackageDev] target_format: plist, ext: tmLanguage
# Made by Wout.Mertens@gmail.com
# This grammar tries to be complete, but regex-based highlighters
# can't be full parsers. Therefore it's a bit looser than the Nix
# parser itself and some legal constructs will be marked as illegal.
# It seems to work fine for nixpkgs.
# Cute hacks: Check out the attrset-for-sure and friends definitions
---
name: Nix
scopeName: source.nix
@wmertens
wmertens / q-promise-cache.coffee
Created June 21, 2013 10:30
Using cached promises for better resource use
# We have a function that loads some resource. It might get called multiple times by our application, for example a web server.
# We use a stored promise to serve as both a cache and a hook for multiple callers to get the same result
# JavaScript version at the bottom
Q = require 'q'
loadPromise = null
doLoad = ->
if not loadPromise
# get a fresh result
loadPromise = Q.delay(1000).then -> Date.now()
# after 1 second clear cache