class CreateBannerCategories < ActiveRecord::Migration
def change
create_table :banner_categories do |t|
t.integer :banner_id
t.integer :category_id
This file contains 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 "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 |
This file contains 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
# 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 |
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
This file contains 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
# 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' |
This file contains 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
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)" | |
) |
This file contains 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 'net/http' | |
def warning_message | |
puts <<~HEREDOC | |
Usage: | |
$ is_github_down | |
🦄 It's down. Go outside! | |
HEREDOC |
This file contains 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 'net/http' | |
require 'open-uri' | |
require 'open3' | |
require 'json' | |
require 'optparse' | |
require 'tempfile' | |
options = {} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: #{__FILE__} [options]" |
This file contains 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
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")}' |
This file contains 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
fi = Float::INFINITY | |
p = 1 | |
p *= 2 while 2**p < fi | |
a = p/2 | |
b = p | |
m = a/2 | |
p = a + m |
NewerOlder