Skip to content

Instantly share code, notes, and snippets.

@sorbits
sorbits / Color Marks.tmCommand
Last active March 3, 2024 16:33 — forked from gdsmith/Color Marks.tmCommand
Textmate command to find, create and add color marks for hex and rgb colors
#!/usr/bin/env ruby -wU
require 'erb'
require 'fileutils'
require 'shellwords'
# extension to String to extract colours into rgb array
class String
# hex to array
def h2a
@sorbits
sorbits / every
Last active February 22, 2024 03:58
Run «command» only every «number» time invoked
#!/usr/bin/env bash
progname=$(basename $0)
version="1.0 (2014-08-17)"
step=2
function create_hash {
openssl dgst -sha1 -binary <<< "$1" | xxd -p
}
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/un.h>
int main (int argc, char const* argv[])
{
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
if(fd != -1)
{
char const* socket_path = "/tmp/test.socket";
@sorbits
sorbits / macos.css
Created May 27, 2020 06:20
CSS variables (and minimal setup) for TextMate web output
:root {
--textColor: rgba(0, 0, 0, 1.00);
--textBackgroundColor: rgba(255, 255, 255, 1.00);
--selectedTextColor: rgba(0, 0, 0, 1.00);
--selectedTextBackgroundColor: rgba(179, 215, 255, 1.00);
--linkColor: rgba(0, 104, 218, 1.00);
--headerTextColor: rgba(0, 0, 0, 0.85);
--labelColor: rgba(0, 0, 0, 0.85);
@sorbits
sorbits / gist:64da7bbfb46486d8da66d8f502b4ca30
Created May 27, 2020 05:43
System defined colors (macOS)
textColor
linkColor
textBackgroundColor
labelColor
secondaryLabelColor
tertiaryLabelColor
quaternaryLabelColor
systemBlueColor
### Keybase proof
I hereby claim:
* I am sorbits on github.
* I am sorbits (https://keybase.io/sorbits) on keybase.
* I have a public key ASCRO9t0xfm4YjzZaIbm6yx5y2_lWRfwfKKiIsVCnDEKoAo
To claim this, I am signing this object:
@sorbits
sorbits / clang.mm
Created January 16, 2016 10:34
Extract most C/Cocoa symbols via libclang
#import <clang-c/Index.h>
#import <Foundation/Foundation.h>
#import <regex>
#import <stdio.h>
#import <map>
#import <string>
#import <set>
template <typename _InputIter>
std::string strings_to_regexp (_InputIter first, _InputIter last)
@sorbits
sorbits / volumes.cc
Created April 24, 2018 02:15
Get list of browsable volumes
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/ucred.h>
#include <string.h>
#include <vector>
#include <string>
std::vector<std::string> volumes ()
{
std::vector<std::string> res;
#import <CoreServices/CoreServices.h>
int main (int argc, char const* argv[])
{
CFShow(LSCopyApplicationURLsForBundleIdentifier(CFSTR("com.macromates.TextMate"), nullptr));
return 0;
}
@sorbits
sorbits / CSS Colors in Gutter.rb
Created February 15, 2017 02:49
Create new command and set scope selector to `source.css` and semantic class to `callback.document.did-open, callback.document.did-save`
#!/usr/bin/env ruby -wU
require 'erb'
require 'fileutils'
require 'shellwords'
# extension to String to extract colours into rgb array
class String
# hex to array
def h2a
if self.length == 4