Last updated: 12/31/2013
- Edit
/etc/default/localeas sudo. - Append
LC_ALL="en_US.UTF-8"at the end of the file, save and quit. sudo locale-gen en_US en_US.UTF-8sudo dpkg-reconfigure locales
| #Signing AWS Requests By Using Signature Version 4 | |
| #http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html | |
| require 'uri' | |
| require 'openssl' | |
| require 'net/http' | |
| require 'cgi' | |
| method = 'GET' | |
| service = 'iam' |
Last updated: 12/31/2013
/etc/default/locale as sudo.LC_ALL="en_US.UTF-8" at the end of the file, save and quit.sudo locale-gen en_US en_US.UTF-8sudo dpkg-reconfigure locales| class Fail2banNotifier | |
| def initialize(options) | |
| @default_options = options | |
| @default_options[:logfile] ||= Rails.root.join('log', 'fail2ban.log') | |
| # Roll over every 30M, keep 10 files | |
| @logger ||= Logger.new(@default_options[:logfile], 10, 30*1024*1024) | |
| end | |
| def call(exception, options={}) |
| = form_for(@tank_configuration) do |f| | |
| - if @tank_configuration.errors.any? | |
| #error_explanation | |
| h2 | |
| = pluralize(@tank_configuration.errors.count, "error") | |
| | prohibited this tank_configuration from being saved: | |
| ul | |
| - @tank_configuration.errors.full_messages.each do |msg| | |
| li | |
| = msg |
| def queue_time(queue, cashier) | |
| # 每個位置一起減去當中最小的值 | |
| def subtract_the_min(arr) | |
| arr.map do |ele| | |
| ele - arr.min | |
| end | |
| end | |
| # 如果 at_a_certain_moment 裡面有0 -> 找到這個位置,塞入下一個顧客 ->直到每個位置都不是0 |
| # 1) Create your private key (any password will do, we remove it below) | |
| $ cd ~/.ssh | |
| $ openssl genrsa -des3 -out server.orig.key 2048 | |
| # 2) Remove the password | |
| $ openssl rsa -in server.orig.key -out server.key |
| #!/usr/bin/perl | |
| # | |
| # Script to download/clone all of your Github repos | |
| # | |
| # Copyright Nicholas Humfrey, 22nd August 2017 | |
| # | |
| # License: http://unlicense.org | |
| # | |
| use JSON; |
| #!/usr/bin/ruby | |
| # Create display override file to force Mac OS X to use RGB mode for Display | |
| # see http://embdev.net/topic/284710 | |
| require 'base64' | |
| data=`ioreg -l -d0 -w 0 -r -c AppleDisplay` | |
| edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten | |
| vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten |
| # config/initializers/activestorage.rb | |
| Rails.application.config.to_prepare do | |
| # Provides the class-level DSL for declaring that an Active Record model has attached blobs. | |
| ActiveStorage::Attached::Macros.module_eval do | |
| def has_one_attached(name, dependent: :purge_later, acl: :private) | |
| class_eval <<-CODE, __FILE__, __LINE__ + 1 | |
| def #{name} | |
| @active_storage_attached_#{name} ||= ActiveStorage::Attached::One.new("#{name}", self, dependent: #{dependent == :purge_later ? ":purge_later" : "false"}, acl: "#{acl}") | |
| end |