Skip to content

Instantly share code, notes, and snippets.

@jspillers
jspillers / index.html
Last active June 5, 2020 05:40
data-grid-gif
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<link rel='stylesheet' href="https://unpkg.com/@finos/[email protected]/dist/umd/material-dense.dark.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://unpkg.com/@finos/perspective-workspace"></script>
<script src="https://unpkg.com/@finos/perspective-viewer-datagrid"></script>
@jspillers
jspillers / Deformer.cs
Created April 12, 2017 14:00
one method from a c# class
private void FlattenVolume() {
float flattenToY = Mathf.Lerp(deformerCollider.bounds.min.y, deformerCollider.bounds.max.y, flattenTo);
float flattenHeight = Coord.WorldHeightToTerrainHeight(flattenToY, terrain);
foreach (Vertex v in this.localHeightMap.localHeightmapVertices) {
if (v.insideDeformerCollider || (!v.insideDeformerCollider && this.flattenArea)) {
if (v.areaZ < this.terrainArea.terrainHeights.GetLength(0) || v.areaX < this.terrainArea.terrainHeights.GetLength(1)) {
this.terrainArea.terrainHeights[v.areaZ, v.areaX] = flattenHeight;
}
}
@jspillers
jspillers / gtk3_error.sh
Created June 12, 2015 17:17
gtk3 error when requiring gem
➜ ruby gtk3_test.rb
/Users/jarrod/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': dlopen(/Users/jarrod/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-13/2.2.0-static/glib2-2.2.5/glib2.bundle, 9): Library not loaded: @@HOMEBREW_PREFIX@@/opt/gettext/lib/libintl.8.dylib (LoadError)
Referenced from: /Users/jarrod/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-13/2.2.0-static/glib2-2.2.5/glib2.bundle
Reason: image not found - /Users/jarrod/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-13/2.2.0-static/glib2-2.2.5/glib2.bundle
from /Users/jarrod/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/jarrod/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/glib2-2.2.5/lib/glib2.rb:105:in `rescue in <top (required)>'
from /Users/jarrod/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/glib2-2.2.5/lib/glib2.rb:101:in `<top (required)>'
from /Users/jarrod/.rbenv/version
@jspillers
jspillers / vcr_webmock_and_live_http_simultaneously.rb
Created June 9, 2015 20:13
Sandbox test to get VCR, WebMock, and "real" http all working side by side in the same spec suite
require 'rubygems'
require 'rspec'
require 'webmock'
require 'vcr'
require 'pry'
# in a Rails app, this would be in an initializer
WebMock.disable_net_connect!(
allow_localhost: true,
net_http_connect_on_start: true
>> hsh = { :foo => ->(x){ {x: x } }}
=> {:foo=>#<Proc:0x007ff2c20320c0@(irb):9 (lambda)>}
>> hsh[:foo]
=> #<Proc:0x007ff2c20320c0@(irb):9 (lambda)>
>> hsh[:foo].call('qwerasdf')
=> {:x=>"qwerasdf"}
require 'rest_client'
def import(service_url, uri, data)
JSON.parse(
RestClient.post(
"#{service_url}#{uri}",
data.to_json,
content_type: :json,
accept: :json
)
@jspillers
jspillers / run_spec_multiple.rb
Created January 19, 2012 16:48
run specs multiple times with truncated output
#!/usr/bin/env ruby
ARGV[0].to_i.times do |i|
puts "run #{i+1}"
result = `rake SPEC=#{ARGV[1]}`
puts result.match(/(Finished in \d+.\d+ seconds)/)[1]
puts result.match(/(\d+ examples, \d+ failures?)/)[1]
if result.match(/Failed examples:/)
puts ''
puts 'Failed examples:'
@jspillers
jspillers / backbone_sync_hack.coffee
Created December 2, 2011 00:17 — forked from jumski/backbone_sync_hack.coffee
BackboneJS sync hack to namespace params when saving/updating model
###
Usage:
* add model.name property that will be used as a namespace in the json request
* put this code before your Backbone app code
* use toJSON() as usual (so there is no namespacing in your templates)
* your model's data will be sent under model.name key when calling save()
###
# save reference to Backbone.sync
Backbone.oldSync = Backbone.sync
@jspillers
jspillers / backbone.rails.js
Created December 1, 2011 23:52 — forked from tmarek/backbone.rails.js
Makes Backbone.js play nicely with default Rails setup
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.