http://patshaughnessy.net/2012/2/29/the-joke-is-on-us-how-ruby-1-9-supports-the-goto-statement
goto.patch:
--- vm_opts.h
+++ vm_opts.h
@@ -48,7 +48,7 @@
#define OPT_STACK_CACHING 0| # config/initializers/pry_everywhere.rb | |
| require 'sidekiq' | |
| # Perform Sidekiq jobs immediately in development, | |
| # so you don't have to run a separate process. | |
| # You'll also benefit from code reloading. | |
| if Rails.env.development? && ENV['SIDEKIQ_INLINE'].present? | |
| require 'sidekiq/testing' | |
| Sidekiq::Testing.inline! | |
| end |
| # config/locales/defaults/uk.rb | |
| { | |
| uk: { | |
| date: { | |
| # In Ukrainian month name with day and standalone day are different | |
| month_names: lambda do |key, options| | |
| if options[:format] && options[:format] =~ /%-?d %B/ | |
| :'date.month_names_with_day' | |
| else | |
| :'date.month_names_standalone' |
| # app/models/experience.rb | |
| # | |
| # == Schema Information | |
| # | |
| # Table name: experiences | |
| # | |
| # id :integer not null, primary key | |
| # title :string | |
| # description :text | |
| # created_at :datetime not null |
| qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'var allDesktops = desktops(); for (i = 0; i < allDesktops.length; i++) {d = allDesktops[i]; d.wallpaperPlugin = "org.kde.image";d.currentConfigGroup = Array("Wallpaper", "org.kde.image", "General"); d.writeConfig("Image", "file:///path/to/image.png")}' |
| require "socket" | |
| def is_port_open?(ip : String, port : Int32, timeout = 5) | |
| s = TCPSocket.new(ip, port, dns_timeout: timeout, connect_timeout: timeout) | |
| s.close | |
| true | |
| rescue IO::Timeout | |
| false | |
| end |
| Model | |
| .where( | |
| "EXTRACT(dow FROM log_in) IN (1,2,3,4,5)" | |
| ) | |
| .where( | |
| "log_in::time BETWEEN '9:00' AND '18:00'" | |
| ) | |
| .where( | |
| "log_in BETWEEN now()::timestamp - (interval '1 week' AND now()::timestamp)" | |
| ) |
http://patshaughnessy.net/2012/2/29/the-joke-is-on-us-how-ruby-1-9-supports-the-goto-statement
goto.patch:
--- vm_opts.h
+++ vm_opts.h
@@ -48,7 +48,7 @@
#define OPT_STACK_CACHING 0| # encoding: utf-8 | |
| # Build a Hash tree from Array Of file names | |
| # | |
| def build_hash_tree(filenames) | |
| files_tree = filenames.inject({}) { |h, i| t = h; i.split("/").each { |n| t[n] ||= {}; t = t[n] }; h } | |
| end | |
| # Box-drawing character - https://en.wikipedia.org/wiki/Box-drawing_character | |
| # ├ └ ─ │ |
| # Return the longest path prefix (taken character-by-character) that is a prefix of all paths in array. | |
| # If array is empty, return the empty string (''). | |
| # Note that this may return invalid paths because it works a character at a time. | |
| # | |
| def common_prefix(m) | |
| # Given a array of pathnames, returns the longest common leading component | |
| return '' if m.empty? | |
| s1, s2 = m.min, m.max | |
| s1.each_char.with_index do |c, i| | |
| return s1[0...i] if c != s2[i] |