Skip to content

Instantly share code, notes, and snippets.

@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 / 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
}
@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 / 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]
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