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
| A | |
| a | |
| aa | |
| aal | |
| aalii | |
| aam | |
| Aani | |
| aardvark | |
| aardwolf | |
| Aaron |
| class Person < ActiveRecord::Base | |
| validates :surname, presence: true, if: "name.nil?" | |
| end |
| # 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('/') |
| 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}, |
| # 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? |
| #!/usr/bin/env bash | |
| ################################################## | |
| # Bash Prompt | |
| ################################################## | |
| # Current configuration produces: | |
| # 00:00:50 jeff@edison:~/Dev/humani.se (git:master:156d0b4) ruby-2.2.0 | |
| # → _ |
| #!/usr/bin/env ruby | |
| require 'capybara' | |
| require 'capybara/poltergeist' | |
| class Scraper | |
| include Capybara::DSL | |
| Capybara.register_driver :poltergeist do |app| | |
| Capybara::Poltergeist::Driver.new app, | |
| phantomjs_options: ['--load-images=no','--ignore-ssl-errors=yes'], | |
| js_errors: false, |
| def deflate(hash) | |
| hash.collect do |k,v| | |
| [k.to_s].push v.is_a?(Hash) ? v.to_a.flatten : v | |
| end.flatten.collect(&:to_s).sort | |
| end | |
| event1 = { foo: 'bar', bars: [4,6,10] } | |
| event2 = { bars: [10,4,6], foo: 'bar' } | |
| event1 == event2 |
| Open iTerm2 over full-screen'd apps (HACK) | |
| ------------------------------------------ | |
| READ: https://gitlab.com/gnachman/iterm2/issues/1570 | |
| defaults write /Applications/iTerm.app/Contents/Info LSUIElement true | |