This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Trie.swift | |
// SceneTest | |
// | |
// Created by Greg Titus on 6/7/14. | |
// Copyright (c) 2014 The Omni Group. All rights reserved. | |
// | |
// This is essentially the same data structure as OFTrie in OmniFoundation, except that the OmniFoundation version is mutable and ephemeral, | |
// and this version is immutable and persistent. Every time you add a string to the trie, it replaces all the nodes along the string's path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var currentArtboard = [[[doc currentPage] artboards] firstObject]; | |
var layers = selection; | |
var bounds = getBoundsForLayers(layers); | |
for (var i = 0, len = [layers count]; i < len; ++i) { | |
var layer = [layers objectAtIndex:i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ref: http://iaroslavski.narod.ru/quicksort/DualPivotQuicksort.pdf | |
template<typename T> | |
void DualPivotQuickSort(T *lo, T *hi, const std::function<int32_t(const T &, const T&)> &cmp) | |
{ | |
auto *const hiMinus1 = hi - 1; | |
if (hi - lo < 3) | |
{ | |
if (hi != lo && cmp(*lo, *hiMinus1) > 0) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A simple LUT backed index for faster binary search, with LUT partition encoding | |
// A bloom filter can be attached to it, for when you have many, many values - though in practice | |
// it is rarely needed, especially if the bits(resolution) is over 16 | |
// | |
// You need (1 << bits) * sizeof(T::key) for the lut, e.g if T::key is uint32_t, for a 16bits LUT, that's | |
// 262k. Increasing resolution results in higher lookup efficiency, reducing it results in lower memory requirements | |
template<typename T> | |
static __attribute__((always_inline)) constexpr T MSB(const T n, const uint8_t span) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static inline uint8_t RHeight(void) | |
{ | |
// Assuming probability 1/2 of an element appearing in layer i also appearing in layer i + 1 | |
// We can do the usual toss-the-coin dance, or we can just use RNG once and count the trailing zeros. | |
// Instead of using a loop to count, we can isolate the rightmost 0-bit, turn off all bits and sets that bit to 1, and then | |
// just compute count of trailing zeros instead. | |
const auto r = rand(); | |
const auto v = ~r & (r + 1); | |
const uint8_t tz = __builtin_ctz(v); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var s = context.selection | |
var v = context.document.currentView() | |
var r = v.totalRectForLayers(s) | |
var artboard = [[MSArtboardGroup alloc] initWithFrame:r]; | |
var page = context.document.currentPage(); | |
[page addLayers:[artboard]]; | |
[artboard setGrid:[page grid]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function car() { | |
return { | |
start: function() { | |
console.log("Engine on.") | |
}, | |
accelerate: function() { | |
console.log("Let's go!") | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright 2011 Martin Hawksey | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd existing_git_repo | |
git remote add origin git@github.com:[user]/[reponame].git | |
git push -u origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
svgo --pretty --enable=removeTitle --enable=removeDesc --enable=removeDoctype --enable=removeEmptyAttrs --enable=removeUnknownsAndDefaults --enable=removeUnusedNS --enable=removeEditorsNSData -f folder_with_svg_files |
OlderNewer