Skip to content

Instantly share code, notes, and snippets.

Avatar
🐛
Be vewy vewy quiet, I'm hunting bugs!

Thomas Thomassen thomthom

🐛
Be vewy vewy quiet, I'm hunting bugs!
View GitHub Profile
View bash-completion-slowness-on-msys2.md

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:

@thomthom
thomthom / angle_from_sagitta.rb
Created Jun 29, 2018
Compute arc angle from sagitta and arc length
View angle_from_sagitta.rb
def time(label)
t = Time.now
yield
puts "#{label}: #{Time.now - t}s"
end
module RosettaCode
def self.sign(x)
View interior_erase.rb
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)
@thomthom
thomthom / gist:652e57dbc719b704b0fb85c666bd573d
Created May 2, 2016 — forked from discordier/gist:ed4b9cba14652e7212f5
options for phpStorm @noinspection annotation
View gist:652e57dbc719b704b0fb85c666bd573d
javascript
ES6ValidationInspection
JSAccessibilityCheckInspection
JSBitwiseOperatorUsageInspection
JSCheckFunctionSignaturesInspection
JSClosureCompilerSyntaxInspection
JSCommentMatchesSignatureInspection
JSComparisonWithNaNInspection
JSConsecutiveCommasInArrayLiteralInspection
View GetUVs.rb
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 ""
View Xcode Build Settings
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 / Example Usage
Created Nov 1, 2013
Snippet for getting UVQ and UV data from 3D points
View Example Usage
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)
View rvm install with openssl and zlib
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...............................................................................................................................................................................................................................................................................
View Ruby 32bit rvm
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*
@thomthom
thomthom / mesh_vertices.rb
Created Mar 14, 2013
Experimental mapping of SketchUp's Geom::PolygonMesh points to vertices.
View mesh_vertices.rb
# 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 )
You can’t perform that action at this time.