Skip to content

Instantly share code, notes, and snippets.

View mbixby's full-sized avatar

Michal Obrocnik mbixby

View GitHub Profile
@mbixby
mbixby / gist:2359042
Created April 11, 2012 12:29
Translate directory tree to a tree
data Tree a = Leaf a | Node a [Tree a]
scanDir :: String -> IO (Tree String)
scanDir path = do
contents <- getDirectoryContents path `catch` const (return [])
let files = sort . filter (`notElem` [".", ".."]) $ contents
let pathsAndFiles = zip (repeat path) files
tree <- forM pathsAndFiles $ \(path, file) -> do
isDirectory <- doesDirectoryExist path
if isDirectory
-- parseExpr :: something -> Either ParseError Expression
convert :: String -> Either String String
convert input = case parseExpr input of
Left err -> Left $ show err
Right x -> Right $ show x
-- Want:
convert = magicfunction show $ parseExpr
@mbixby
mbixby / EXTNull.h
Last active December 14, 2015 17:59
EXTNull
/**
EXTNull
Experimental
EXTNull is a subclass of NSNull that acts more like nil.
Calling unrecognized methods on EXTNull *will not* throw
a NSInvalidArgumentException but again return EXTNull.
@mbixby
mbixby / Markdown.tmlanguage
Last active December 15, 2015 15:19
Quick fix for bullet coloring in Markdown.tmlanguage
<dict>
<key>begin</key>
<!-- By default, maximum number of spaces before the bullet
character is 3. To support multiple nested lists, I changed
it to infinite. -->
<string>^[ ]*([*+-])(?=\s)</string>
<key>captures</key>
<dict>
<key>1</key>
@mbixby
mbixby / Gruntfile.coffee
Last active December 19, 2015 12:09
Gruntfile
"use strict"
module.exports = (grunt) ->
grunt = (require 'grunt-utilities') grunt
# Note that for performance reasons we're only matching one level
# down: 'test/spec/{,*/}*.js'. If you want to match all subfolders,
# use 'test/spec/**/*.js'
grunt.initConfig
yeoman:
@mbixby
mbixby / Incremental compilation output
Created September 12, 2013 13:30
Incremental compilation output from Grunt
⚡ gn watch:main annotations-client master *
Running "watch:main" (watch) task
Waiting...OK
>> File "app/abc.coffee" changed.
Running "coffee:compile" (coffee) task
File tmp/javascript/app/abc.js created.
Running "file_did_change" task
@mbixby
mbixby / gist:3dae2026a77a9a3d3de9
Last active January 5, 2019 06:55
Webpack Named Modules Plugin
var RequestShortener = require("webpack/lib/RequestShortener");
var _ = require("lodash");
/**
* TODO Docs
* @example new NamedModulesPlugin(/^\.\/app\/(viewmodels|records|adapters)/, /^\.\/app\/(.*)\.js$/)
*/
function NamedModulesPlugin(fileWhitelistRegex, replacementRegex) {
this.fileWhitelistRegex = fileWhitelistRegex;
this.replacementRegex = replacementRegex;
@mbixby
mbixby / materialUiStyles.js
Created April 26, 2017 14:34
Extending Material UI styles
import { merge } from 'lodash'
// This module allows us to completely customize all of Material UI's JSS stylesheets
// to define our own theme.
//
// Note that you Material UI's JSS is often tied to application logic and you may
// deviate from the official Material UI spec.
//
// Unlike using the `overrides` feature of jss-theme-reactor, here you have access to
// the original calculated styles and theme. Notably you can do deep merge (lodash.merge)
@mbixby
mbixby / prompt.sh
Created July 19, 2022 14:07
Prompt
PROMPT="${pwd} ${git}
%(?..)%B›%b%{$reset_color%} "
# Gun safety lock
alias rm "rm -i"
# General UNIX
alias cp='cp -iv'
alias df='df -h'
alias du='du -h'

{ "telemetry.enableCrashReporter": false, "telemetry.enableTelemetry": false, "workbench.activityBar.visible": false, "editor.fontSize": 15.5, "editor.fontFamily": "Monaco Lives For Powerline", "editor.fontLigatures": true, "editor.wordWrap": "on", "editor.wordWrapColumn": 90, "editor.suggest.showStatusBar": true,