Skip to content

Instantly share code, notes, and snippets.

View thomthom's full-sized avatar
🐛
Be vewy vewy quiet, I'm hunting bugs!

Thomas Thomassen thomthom

🐛
Be vewy vewy quiet, I'm hunting bugs!
View GitHub Profile
require 'stringio'
output = StringIO.new
model = Sketchup.active_model
tw = Sketchup.create_texture_writer
model.selection.grep(Sketchup::Face) { |face|
tw.load(face, true)
uvh = face.get_UVHelper(true, true)
uvh_tw = face.get_UVHelper(true, true, tw)
output.puts ""
@thomthom
thomthom / mesh_vertices.rb
Created March 14, 2013 09:40
Experimental mapping of SketchUp's Geom::PolygonMesh points to vertices.
# Experimental mapping of PolygonMesh points to vertices.
#
# Example::MeshVertices.test_map_mesh_vertices
module Example
module MeshVertices
def self.test_map_mesh_vertices
model = Sketchup.active_model
group = model.selection[0]
mesh = Example::MeshVertices.get_group_mesh( group )
tthomas-westm1:~ tthomas2$ rvm --debug --32 requirements ruby-2.0.0-p247
rvm_autolibs_flag=enable
Checking requirements for osx.
requirements code for osx loaded
Found required packages: autoconf, automake, libtool, pkgconfig, apple-gcc42, libiconv, libyaml, libffi, readline, libksba, openssl, curl-ca-bundle, sqlite3, zlib, gdbm, ncurses.
rvm_configure_flags+=( --with-opt-dir=/opt/local )
PATH=/opt/local/bin:/Users/tthomas2/.rvm/gems/ruby-2.0.0-p247/bin:/Users/tthomas2/.rvm/gems/ruby-2.0.0-p247@global/bin:/Users/tthomas2/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/tthomas2/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/tthomas2/src/thomthom-trunk-mac/depot/devtools/perforce
Certificates in '/opt/local/etc/openssl/cert.pem' already are up to date.
Requirements installation successful.
__rvm_rm_rf already gone: /Users/tthomas2/.rvm/tmp/35107*
tthomas-westm1:~ tthomas2$ rvm install 2.0.0 --32 --with-openssl-dir=$HOME/.rvm/usr --with-zlib-dir=$HOME/.rvm/usr
Checking requirements for osx.
Certificates in '/opt/local/etc/openssl/cert.pem' already are up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/tthomas2/.rvm/rubies/ruby-2.0.0-p247, this may take a while depending on your cpu(s)...
ruby-2.0.0-p247 - #downloading ruby-2.0.0-p247, this may take a while depending on your connection...
ruby-2.0.0-p247 - #extracting ruby-2.0.0-p247 to /Users/tthomas2/.rvm/src/ruby-2.0.0-p247
ruby-2.0.0-p247 - #extracted to /Users/tthomas2/.rvm/src/ruby-2.0.0-p247
Applying patch /Users/tthomas2/.rvm/patches/ruby/2.0.0/logging.patch....
ruby-2.0.0-p247 - #configuring...............................................................................................................................................................................................................................................................................
@thomthom
thomthom / Example Usage
Created November 1, 2013 11:18
Snippet for getting UVQ and UV data from 3D points
model = Sketchup.active_model
face = model.selection[0]
uvqh = UVQHelper.new(face)
face.vertices.size.times { |i| p uvqh.transform3DtoUVQ(true, face.vertices[i].position) }
# => Point3d(0, 0, 1)
# => Point3d(1, 0, 1)
# => Point3d(0.839757, 0.451277, 0.451277)
# => Point3d(-0.160243, 0.451277, 0.451277)
@thomthom
thomthom / gist:652e57dbc719b704b0fb85c666bd573d
Created May 2, 2016 19:43 — forked from discordier/gist:ed4b9cba14652e7212f5
options for phpStorm @noinspection annotation
javascript
ES6ValidationInspection
JSAccessibilityCheckInspection
JSBitwiseOperatorUsageInspection
JSCheckFunctionSignaturesInspection
JSClosureCompilerSyntaxInspection
JSCommentMatchesSignatureInspection
JSComparisonWithNaNInspection
JSConsecutiveCommasInArrayLiteralInspection
require 'set'
model = Sketchup.active_model
selected = Set.new(model.selection.to_a)
edges = model.selection.grep(Sketchup::Edge)
faces = Set.new(model.selection.grep(Sketchup::Face))
border = edges.reject { |edge| edge.faces.all? { |face| faces.include?(face) } }
selected.subtract(border)
Thomass-Mac-mini:SubD thomas$ xcodebuild -project SUbD.xcodeproj -target "Ruby 2.0" -showBuildSettings
Build settings for action build and target "Ruby 2.0":
ACTION = build
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = thomas
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
@thomthom
thomthom / angle_from_sagitta.rb
Created June 29, 2018 09:58
Compute arc angle from sagitta and arc length
def time(label)
t = Time.now
yield
puts "#{label}: #{Time.now - t}s"
end
module RosettaCode
def self.sign(x)

Bash-completion is very slow on MSYS2

Bash-completion is very slow on MSYS2 when the current user is a domain user. This describes the cause and the solutions.

Cause

Expansion of ~* is very slow when you use a domain user. For example: