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
module ActiveAdmin | |
class Resource | |
module Controllers | |
# Returns a properly formatted controller name for this | |
# config within its namespace | |
def controller_name | |
[namespace.module_name, resource_name.plural.camelize + "Controller"].compact.join('::') | |
end |
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
require 'spec_helper' | |
class TheCopenhagenModel < Restish::Model | |
end | |
describe Restish::Errors do | |
context '#from_hash' do | |
let(:model) { TheCopenhagenModel.new(owner: 'Schrödinger', name: 'cat', alive: true) } | |
let(:errors) { { 'alive' => ['is invalid'], 'cyanide_flask' => ["can't be empty"] } } |
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
require 'benchmark' | |
N = 50000 | |
STRING = "asd sda sda sd" | |
Benchmark.bm do |b| | |
b.report('gsub, s') do | |
N.times { STRING.gsub(/\s/, '') } | |
end | |
b.report('gsub, s+') do |
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
#!/usr/bin/env ruby | |
require 'nokogiri' | |
require 'active_record' | |
require "sqljdbc4.jar" | |
ActiveRecord::Base.establish_connection( | |
:adapter => "jdbcmssql", | |
:driver => "com.microsoft.sqlserver.jdbc.SQLServerDriver", | |
:url => "jdbc:sqlserver://192.168.0.18;databaseName=oms_db_cod_12", |
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
fs = require('fs') | |
util = require('util') | |
path = require('path') | |
flatten = (a, b) -> | |
if typeof b is 'undefined' | |
b = a | |
a = [] | |
b = b.reduce(flatten, []) if typeof b is 'object' | |
a = [a] if typeof a isnt 'object' |
NewerOlder