Skip to content

Instantly share code, notes, and snippets.

@matasar
matasar / Open in Github.py
Last active February 16, 2018 19:24
BBEdit script to open the file I'm looking at in github and copy the URL to my pasteboard
#!/usr/local/bin/python3
import os
import re
import subprocess
from typing import Optional, Sequence
from pathlib import Path, PurePath
doc_path: Optional[str] = os.getenv('BB_DOC_PATH')
def n5s(str)
first, num, last = str.match(/([a-zA-Z])(\d+)([a-zA-Z])/).captures
num = num.to_i
puts open("/usr/share/dict/words").grep(/\b#{first}[a-zA-Z]{#{num}}#{last}\b/)
end
> n5s("i18n")
institutionalization
intercrystallization
interdifferentiation
@matasar
matasar / keybase.md
Created March 25, 2015 21:33
Keybase proof

Keybase proof

I hereby claim:

  • I am matasar on github.
  • I am matasar (https://keybase.io/matasar) on keybase.
  • I have a public key whose fingerprint is 7DA0 62DC 46FD 9AF0 0ADB 749A 026F AC25 9E44 F3D4

To claim this, I am signing this object:

@matasar
matasar / Rust.plist
Last active December 19, 2015 20:49
First draft of BBEdit Codeless Language Module for Rust
<?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>BBEditDocumentType</key>
<string>CodelessLanguageModule</string>
<key>BBLMColorsSyntax</key>
<string>YES</string>
<key>BBLMIsCaseSensitive</key>
<string>YES</string>
@matasar
matasar / maven_bberrors.rb
Last active December 16, 2015 11:09
Futzing with BBEdit and maven output.
#!/usr/bin/env ruby
# encoding: UTF-8
require 'stringio'
require 'rubygems'
require 'ruby-debug'
lines = []
ARGF.each_line do |ea|
# strip bash color codes
@matasar
matasar / Music play pause
Last active December 15, 2015 16:19
An applescript that works for both Rdio and iTunes, and does play/pause. I use this with Launchbar to remote control things. You can also replace "playpause" with "previous track" and "next track" for that behavior.
if appIsRunning("Rdio") then
tell application "Rdio" to playpause
else if appIsRunning("iTunes") then
tell application "iTunes" to playpause
end if
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
@matasar
matasar / wat.rb
Created February 24, 2012 01:32
WAT
irb(main):001:0> def method_missing(*args)
irb(main):002:1> puts 'method missing'
irb(main):003:1> end
=> nil
irb(main):004:0> require 'rubygems'
=> true
irb(main):005:0> require 'activesupport'
method missing
method missing
method missing
Total: 387 samples
87 22.5% 22.5% 121 31.3% Thrift::BaseTransport#read_all
77 19.9% 42.4% 77 19.9% garbage_collector
26 6.7% 49.1% 26 6.7% Thrift::FramedTransport#read
25 6.5% 55.6% 181 46.8% Object#read
21 5.4% 61.0% 70 18.1% ActiveSupport::JSON.encode
18 4.7% 65.6% 199 51.4% Object#receive_message
16 4.1% 69.8% 27 7.0% RainbirdClient#encode
14 3.6% 73.4% 14 3.6% Array#include?
11 2.8% 76.2% 65 16.8% Array#to_json
twttr.txt.autoLinkWithEntities = function(text, entities) {
var result = [];
var allEntities = [];
var addEntities = function (key, array) {
if (entities[key]) {
array.push.apply(array, entities[key].map(function (ea) { return {type: key, value: ea}}));
};
};
@matasar
matasar / datebroken.js
Created November 10, 2010 00:32
This is amazing
var date = new Date("Nov 7 2010 1:00 AM PDT");
var bananas = new Date("Nov 7 2010 1:00 AM PDT");
bananas > date //ok
// > false
bananas.setFullYear(2010)
// > 1289120400000
bananas > date //what?
// > true
bananas.getTime() - date.getTime()