Skip to content

Instantly share code, notes, and snippets.

tell application "NicePlayer"
set movie_file to path of current movie in front playlist as alias
tell application "Finder"
set label index of movie_file to 6
-- display alert (name of first file in container of movie_file as Unicode text)
set filelist to files in container of movie_file
set all_watched to yes
repeat with the_file in filelist
if name extension of the_file is in {"avi", "mpg", "mp4", "wmv"} and label index of the_file is not equal to 6 then
set all_watched to no
@sorbits
sorbits / align.rb
Created May 24, 2011 21:02 — forked from mads-hartmann/align.rb
align.rb
# Alignes the source
def align(text, regexp, width)
text.to_a.map do |line|
if offset = offsetOfRegexpInLine(line, regexp)
if shouldInsertBefore(line, regexp)
before = line[0..offset-1]
before + ' ' * (width - (before.length)) + line[offset..line.length-1]
else
before = line[0..offset]
before + ' ' * (width - (before.length-1)) + line[offset+1..line.length-1]
@sorbits
sorbits / test_string_anchors.cc
Last active December 21, 2015 05:59
Tests for Onigmo not begin/end of string options
#include <Onigmo/oniguruma.h>
#define ONIG_OPTION_BACKWARD (ONIG_OPTION_MAXBIT << 1)
OnigRegex pattern (char const* ptrn, OnigOptionType options = ONIG_OPTION_NONE)
{
OnigErrorInfo einfo;
OnigRegex regex = nullptr;
OAK_ASSERT_EQ(ONIG_NORMAL, onig_new(&regex, (OnigUChar const*)ptrn, (OnigUChar const*)ptrn + strlen(ptrn), options, ONIG_ENCODING_UTF8, ONIG_SYNTAX_DEFAULT, &einfo));
return regex;
@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>
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 / 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
#import <CoreServices/CoreServices.h>
int main (int argc, char const* argv[])
{
CFShow(LSCopyApplicationURLsForBundleIdentifier(CFSTR("com.macromates.TextMate"), nullptr));
return 0;
}
@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;
@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)
### 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: