Skip to content

Instantly share code, notes, and snippets.

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 / 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 / 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