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
| MRI 2.0.0p353: | |
| $ ruby test.rb | |
| 1 | |
| 1 | |
| 102 | |
| 102 | |
| JRuby 1.7.9: | |
| $ ruby test.rb | |
| 19 |
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 'sequel' | |
| require 'benchmark' | |
| # createdb factories_test | |
| DB = Sequel.connect 'postgres://localhost/factories_test' | |
| DB.drop_table? :test | |
| DB.create_table :test do | |
| primary_key :id |
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
| (The MIT License) | |
| Copyright (c) 2012-2013 Myron Marston | |
| Permission is hereby granted, free of charge, to any person obtaining | |
| a copy of this software and associated documentation files (the | |
| "Software"), to deal in the Software without restriction, including | |
| without limitation the rights to use, copy, modify, merge, publish, | |
| distribute, sublicense, and/or sell copies of the Software, and to | |
| permit persons to whom the Software is furnished to do so, subject to |
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
| # support/group_helpers.rb | |
| module GroupHelpers | |
| def self.start_transaction | |
| # @_conn = DB.pool.send :acquire, Thread.current | |
| @_conn = DB.pool.hold{|conn| conn } | |
| DB.send(:add_transaction, @_conn, {savepoint: true}) | |
| DB.send(:begin_transaction, @_conn, savepoint: true) | |
| 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
| http://rubysource.com/streaming-with-rails-4/ | |
| http://www.highcharts.com/ | |
| https://bitbucket.org/cleonello/jqplot/wiki/Home | |
| http://www.dreamfactory.com/ | |
| http://coding.smashingmagazine.com/2013/08/09/absolute-horizontal-vertical-centering-css/ | |
| http://tech.pro/blog/1486/client-side-storage-options | |
| https://www.globalsign.com/ssl/ssl-open-source/ | |
| http://nowardev.wordpress.com/2012/05/16/create-debian-package-for-script-and-simple-project-with-cmake-and-cpack/ | |
| http://shvets.github.io/blog/2013/09/14/nodejs_and_karma.html |
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 'benchmark' | |
| require 'active_support/hash_with_indifferent_access' | |
| Benchmark.bmbm do |x| | |
| l1 = []; l2 = [] | |
| # writing: | |
| # simulate objects returned by Sequel queries: | |
| x.report('creating array or regular hashes'){10_000.times{ l1 << { id: 1, name: 'column value' } }} | |
| x.report('creating array or proposed hashes'){10_000.times{ l2 << HashWithIndifferentAccess.new({ id: 1, name: 'column value' }) }} |
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
| ruby symbols-performance.rb | |
| Rehearsal ------------------------------------ | |
| 0.540000 0.010000 0.550000 ( 0.543421) | |
| 0.680000 0.020000 0.700000 ( 0.705931) | |
| --------------------------- total: 1.250000sec | |
| user system total real | |
| 0.240000 0.000000 0.240000 ( 0.244554) | |
| 0.380000 0.000000 0.380000 ( 0.391517) |
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
| class User < Sequel::Model(:jsec_user) | |
| plugin :devise | |
| # other available modules: | |
| # :token_authenticatable, :registerable, :confirmable, :lockable, :timeoutable and :omniauthable | |
| # :recoverable, :rememberable, :trackable, :validatable, :encryptable | |
| devise :database_authenticatable, :timeoutable #, etc | |
| 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
| select username, count(*) over() from user order by username limit 5 offset 0; |
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
| # for simple use case - doesn't take into account multiple occurrences | |
| parseParams = (search = window.location.search)-> | |
| d = (str)-> decodeURIComponent str.replace /\+/g, ' ' | |
| query = search.substring 1 | |
| regex = /(.*?)=([^\&]*)&?/g | |
| params = {} | |
| params[d(m[1])] = d(m[2]) while m = regex.exec query | |
| params |