This file contains hidden or 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
#!/bin/bash | |
substitution='s/\x1b\[90m/\x1b[92m/g' | |
$(cd $(dirname $0); pwd)/__mocha -c "$@" > >(perl -pe "$substitution") 2> >(perl -pe "$substitution" 1>&2) |
This file contains hidden or 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 'pp' | |
require 'fileutils' | |
file = ARGV[0] | |
dirname = File.basename(file,'.*') | |
FileUtils.mkdir_p dirname | |
source = File.read(file) | |
i = 1 | |
source.gsub(/(?<=<!---).+?(?=--->)/m) do |m| |
This file contains hidden or 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
# @see https://gist.github.com/basgys/5712426#gistcomment-1274422 | |
class UploadFile | |
include ActiveModel::Model | |
include Paperclip::Glue | |
# Paperclip required callbacks | |
define_model_callbacks :save, only: [:after] | |
define_model_callbacks :commit, only: [:after] | |
define_model_callbacks :destroy, only: [:before, :after] |
This file contains hidden or 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
Bundler.require | |
class Hoge | |
attr_accessor :id, :name_bar | |
def initialize(id: nil, name_bar: nil) | |
self.id = id | |
self.name_bar = name_bar | |
end | |
end |
This file contains hidden or 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
def midpoint_displacement(size, rect = [], x = 0, y = 0, depth = 0) | |
result = {} | |
avg_height = ->(heights) { | |
heights.sum / heights.size.to_f | |
} | |
rand_height = ->(h) { | |
(rand - 0.5) * (2.0 ** -(depth * h)) | |
} |
This file contains hidden or 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
module HasUrlHelpers | |
extend ActiveSupport::Concern | |
# URL Helpers for Models | |
# @see https://github.com/rails/rails/blob/aa3dcabd874a3e82e455e85a1c94a7abaac2900a/actionpack/lib/action_controller/metal/url_for.rb | |
# @see https://github.com/rails/rails/blob/b13a5cb83ea00d6a3d71320fd276ca21049c2544/actionpack/lib/abstract_controller/url_for.rb | |
# @see https://github.com/rails/rails/blob/14d3c7c2c9b89fe76a3677f99d102dd6ca729927/actionpack/lib/action_dispatch/routing/url_for.rb | |
# @see https://github.com/rails/rails/blob/14d3c7c2c9b89fe76a3677f99d102dd6ca729927/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb | |
# @see https://github.com/rails/rails/blob/cba27402388380d672199a1a46de0a06ef383332/actionpack/lib/action_dispatch/routing/route_set.rb#L504 | |
class UrlHelpers |
This file contains hidden or 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
on run | |
repeat | |
set pid to executeAutoClicker() | |
log pid | |
delay 5 | |
activateMinecraft() | |
delay 1 | |
toggleAutoClick() | |
delay 60 | |
killAutoClicker(pid) |
This file contains hidden or 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
class Time | |
@@tz_mutex = Mutex.new | |
# @param zone [String] Time zone ID(e.g. +'Asia/Tokyo'+) | |
# @example | |
# require 'time_with_zone' # This module | |
# require 'time' | |
# t = Time.parse('2018-09-12T10:00:00Z') | |
# t.in_time_zone('America/Los_Angeles').dst? # => true | |
# t.in_time_zone('Asia/Tokyo').dst? # => false |
This file contains hidden or 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
#!/bin/bash | |
# Register private hosted zone | |
# @see [aws 起動毎にローカル IP をローカル DNS (Route53) の A レコードに突っ込む - Qiita](https://qiita.com/selfnavi/items/a731514cd8174d86caf5) | |
INSTANCE_ID=`curl http://169.254.169.254/latest/meta-data/instance-id | sed -e 's/^i-//g'` | |
IPV4=`curl http://169.254.169.254/latest/meta-data/local-ipv4` | |
HOSTNAME=`echo "app-:instance-id:.example.local" | sed -e "s/:instance-id:/${INSTANCE_ID}/g"` | |
HOSTED_ZONE_ID=<hosted-zone-id> | |
cat <<JSON > /root/register-route53.json |
This file contains hidden or 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
ActiveAdmin.register FooModel do | |
extend CsvDumpableResource | |
end |