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 / every
Last active July 4, 2024 03:28
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
}
@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 / 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>
@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
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;
}