Skip to content

Instantly share code, notes, and snippets.

#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 / 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
std::string fontStyle;
if(plist::get_key_path(plist, "settings.fontStyle", fontStyle))
{
bool hasPlain = fontStyle.find("plain") != std::string::npos;
bool hasBold = fontStyle.find("bold") != std::string::npos;
bool hasItalic = fontStyle.find("italic") != std::string::npos;
bool hasUnderline = fontStyle.find("underline") != std::string::npos;
res.bold = hasBold ? bool_true : (hasPlain ? bool_false : bool_unset);
res.italic = hasItalic ? bool_true : (hasPlain ? bool_false : bool_unset);
@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 / test.mm
Created January 16, 2016 10:37
This is the file read by clang.mm (previous gist)
#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum))
#warning "we are OK"
#endif
#import <CoreFoundation/CoreFoundation.h>
#import <MacTypes.h>
#import <stdio.h>
#import <stdint.h>
#import <math.h>
#import <pthread.h>