sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove
sudo reboot
sudo dpkg-reconfigure tzdata
sudo apt-get install -y ntp
| # Setup ActiveRecord | |
| require 'active_record' | |
| ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'benchmark.db') | |
| ActiveRecord::Migration.class_eval { create_table :users } unless ActiveRecord::Base.connection.table_exists? 'users' | |
| class User < ActiveRecord::Base;end | |
| # Use TracerPoint | |
| user = User.new | |
| trace = tracerpoint do | |
| puts user.present? |
| def tracerpoint | |
| calls = [] | |
| trace = TracePoint.new(:call, :c_call) do |tp| | |
| calls << [tp.defined_class, tp.method_id, tp.lineno] | |
| end | |
| trace.enable | |
| yield | |
| trace.disable | |
| { | |
| calls: calls.group_by(&:itself).map {|k, v| {k => v.length}}.sort_by {|h| -h.values.first}, |
| # Usage: | |
| # <%= filestack_image_tag post.filestack_url, resize: { width: 100, height: 200, fit: crop }, oil_paint: { amount: 7 } %> | |
| # | |
| # => https://process.filestackapi.com/[FILESTACK API KEY]/resize=width:72,height:72,fit:crop/oil_paint=amount:7/https://cdn.filestackcontent.com/abc23... | |
| def filestack_image_tag(url, task_options={}, image_tag_options={}) | |
| base_path = "https://process.filestackapi.com/#{Rails.application.config.filestack_api_key}" | |
| task_path = task_options.collect do |task, options| | |
| "#{task.to_s}=#{options.collect{|k,v| "#{k}:#{v}"}.join(',')}" | |
| end.join('/') |
| class Person < ActiveRecord::Base | |
| validates :surname, presence: true, if: "name.nil?" | |
| end |
| A | |
| a | |
| aa | |
| aal | |
| aalii | |
| aam | |
| Aani | |
| aardvark | |
| aardwolf | |
| Aaron |
| # /lib/capistrano/tasks/confirmation.cap | |
| namespace :deploy do | |
| task :confirmation do | |
| color = case fetch(:stage) | |
| when :production then 31 | |
| when :staging then 33 | |
| else 34 | |
| end |
| // afterglow-syntax/styles/colors.less | |
| // Add this to colors.scss in afterglow ui and syntax packages | |
| @white : rgb(255, 255, 255); | |
| @ghost : rgb(250, 250, 255); | |
| @snow : rgb(249, 249, 254); | |
| @vapor : rgb(246, 246, 251); | |
| @white-smoke : rgb(245, 245, 250); | |
| @silver : rgb(232, 232, 237); | |
| @smoke : rgb(230, 225, 225); |
| version: 2 | |
| jobs: | |
| build: | |
| parallelism: 2 # however many CPUs you need/pay for | |
| ############################################# | |
| # Container Setup | |
| ############################################# | |
| docker: | |
| - image: circleci/ruby:2.5.0 |
| module Benchmark | |
| # Similar to Benchmark.realtime, but returns the result of the block along with time taken in milliseconds. | |
| # Ex: Benchmark.perform{ sleep(3); "hello" } => [3003.2030000002123, "hello"] | |
| # | |
| # Benchmark.realtime | https://ruby-doc.org/stdlib-2.5.0/libdoc/benchmark/rdoc/Benchmark.html#method-c-realtime | |
| # Process.clock_gettime | http://ruby-doc.org/core-2.5.0/Process.html#method-c-clock_gettime | |
| def self.perform | |
| t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC) |