Skip to content

Instantly share code, notes, and snippets.

@austra
austra / gist:5847cecd4d645182fcbf
Created November 4, 2015 18:10
destroy datetimepicker
$('#banDateOneReal').data("DateTimePicker").destroy();
http://stackoverflow.com/questions/22957699/how-to-change-a-bootstrap-datetimepicker-language-during-running
@austra
austra / gist:9ba13748bdad60da712f
Last active November 5, 2015 16:48
activerecord - .endmost scope - optimized .last
.endmost is what you want when you call .last: the last N records in the result set without having to retrieve all records from the database, and it works with any ordering. You can impose filtering before, Message.where(…).in_order.endmost(10), and afterwards to filter your final results as well Message.in_order.endmost(10).where(…).
class Message
class << self
def in_order
order(created_at: :asc)
end
def recent(n)
in_order.endmost(n)
@austra
austra / gist:ae39fc95ee7abdc8f061
Created December 7, 2015 23:58
nested datatables
http://live.datatables.net/IroN/399/edit
@austra
austra / Find duplicate cms keys in mongo
Last active February 18, 2016 01:00
Find duplicate cms keys in mongo
Cms::Content.collection.aggregate([{"$group" => {"_id" => "$key", "count" => {"$sum" => 1}}}, {"$match" => {"count" => {"$gt" => 1}}}, {"$sort" => {"count" => -1}}])
@austra
austra / spoilerbot
Last active October 26, 2017 19:48
spoilerbot
188,139,85,078,41,251,234,35,275,136,014,270,179,46,89,172,052,207,192,55,205,42,133,26,37,71,083,153,97,142,197,134,159,109,162,79,184,101,4,169,196,185,195,59,103,204,170,22,247,24,144,036,21,80,065,149,217,3,222,104,60,232,64,224,44,161,231,094,230
@austra
austra / gist:451d0a527adf0d7fbf165701d7f65932
Created August 25, 2016 22:00
Kill irb sessions after x minutes of inactivity
# Add some methods to IRB::Context and IRB::Irb
# for easier timeout implementation.
class IRB::Irb
def status
@signal_status
end
end
class IRB::Context
attr_reader :irb
@austra
austra / gist:a5682ec0fc3af6d11057de40d512de42
Last active December 9, 2024 12:03
Rails Performance Resources
https://www.youtube.com/watch?v=kZcqyuPeDao
https://gist.github.com/nateberkopec/2b1f585046adad9a55e7058c941d3850
https://www.speedshop.co/2015/07/15/the-complete-guide-to-rails-caching.html
https://www.railsspeed.com/
https://www.speedshop.co/2015/07/29/scaling-ruby-apps-to-1000-rpm.html
https://www.speedshop.co/2015/10/07/frontend-performance-chrome-timeline.html
https://github.com/ruby-prof/ruby-prof
https://github.com/schneems/get_process_mem
https://github.com/ko1/allocation_tracer
https://github.com/evanphx/benchmark-ips
@austra
austra / gist:a007b49774339b70c9bd8aedd6f5ecce
Last active December 16, 2016 20:05
Rails REST Resources
http://www.sm-cloud.com/ruby-json-mapping/
http://jsonapi-rb.org/#rails
https://github.com/trailblazer/representable
https://github.com/trailblazer/roar
https://github.com/remiprev/her
https://github.com/lostisland/faraday_middleware/wiki
http://blog.excelwithcode.com/ruby-api-clients.html
@austra
austra / stock
Last active January 11, 2017 21:49
stock
dis,5,108.59
nflx,3,130.91
@austra
austra / gist:43de145033ab881cf0012ed942504848
Created March 16, 2017 16:41
Ruby Benchmark with ObjectSpace
require 'objspace'
require 'benchmark'
Benchmark.bmbm do |bm|
bm.report("using [] :") do
GC.start
mem_before = ObjectSpace.memsize_of_all
before = GC.stat[:total_allocated_objects]