This file contains hidden or 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
require ‘ffi’ | |
module Scrape | |
extend FFI::Library | |
ffi_lib ‘./debug/libscrape.dylib’ | |
attach_function :sum, [:int32, :int32], :int32 | |
end | |
puts Scrape.sum(2, 3) == 5 ? “Gone Dun It!” : “Uhhhh????” |
This file contains hidden or 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
source ‘https://rubygems.org' | |
gem ‘ffi’ |
This file contains hidden or 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
#[no_mangle] | |
pub extern fn sum(x: i32, y: i32) -> i32 { | |
x + y | |
} |
This file contains hidden or 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
[package] | |
name = "scrape" | |
version = "0.1.0" | |
authors = ["Mike Piccolo <[email protected]>"] | |
[lib] | |
name = "embed" | |
crate-type = ["dylib"] |
This file contains hidden or 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
fn sum(x: i32, y: i32) -> i32 { | |
x + y | |
} | |
#[test] | |
fn it_works() { | |
assert!(sum(1, 2) == 3); | |
} |
This file contains hidden or 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
#minitest/spec | |
# Drop SOLO in the name of the test you want to run and then run | |
# solo and tab complete the path/to/the/test/file.rb | |
solo() { | |
ruby -Itest $1 --name /SOLO/ | |
} | |
# describe SomeClass do | |
# it "does some stuff SOLO" do |
This file contains hidden or 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
guard "minitest", all_on_start: false, start_on_start: false do | |
# with Minitest::Spec | |
watch(%r|^test/(.*)_test\.rb$|) | |
watch(%r|^app/(.*)/(.*)\.rb$|) { |m| "test/#{m[1]}/#{m[2]}_test.rb" } | |
watch(%r|^lib/(.*)([^/]+)\.rb$|) { |m| "test/#{m[1]}#{m[2]}_test.rb" } | |
watch(%r|^test/test_helper\.rb$|) { "test" } | |
watch(%r|^test/support/|) { "test" } | |
end | |
This file contains hidden or 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
import Ember from 'ember'; | |
var Pollable = Ember.Mixin.create({ | |
afterModel: function (model, transition) { | |
var self = this; | |
this._super(model, transition); | |
var interval_info = this.get('interval_info'); | |
if (!interval_info) { | |
interval_info = Ember.Object.create({ |
This file contains hidden or 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
MoneyRails.configure do |config| | |
config.register_currency = { | |
:priority => 1, | |
:iso_code => "USD1", | |
:name => "USD with subunit of 4 digits", | |
:symbol => "$", | |
:symbol_first => true, | |
:subunit => "Subcent", | |
:subunit_to_unit => 10000, | |
:thousands_separator => ",", |
This file contains hidden or 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
# Monkey patch for ActiveRecord::Base to return serialized JSON in the format | |
# of an ActiveModel::Serializer. | |
module SerializedJson | |
extend ActiveSupport::Concern | |
def to_serial(serializer=nil, opts={}) | |
if self.respond_to?(:map) | |
serializer ||= (self.base_class.name + "Serializer").constantize | |
serialized_collection = self.map do |resource| |