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
$ irb | |
irb(main):001:0> class Fixnum | |
irb(main):002:1> def plus_with_two_plus_two_is_five(other) | |
irb(main):003:2> other += 1 if self == 2 && other == 2 | |
irb(main):004:2> plus_without_two_plus_two_is_five(other) | |
irb(main):005:2> end | |
irb(main):006:1> alias_method :plus_without_two_plus_two_is_five, :+ | |
irb(main):007:1> alias_method :+, :plus_with_two_plus_two_is_five | |
irb(main):008:1> end | |
Rubinius::InvalidBytecode: instruction argument is not a Fixnum: code: call, ip: 13 |
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
module SingletonWithClassDelegator | |
extend ActiveSupport::Concern | |
included do | |
include Singleton | |
original_delegate_method = method(:delegate).unbind if self.respond_to?(:delegate) | |
extend SingleForwardable | |
if original_delegate_method.present? | |
# restore the delegate of ActiveSupport that has been overshadowed by SingleForwardable | |
define_singleton_method :delegate, original_delegate_method |
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
"use strict"; | |
const Sequelize = require('sequelize'); | |
const Promise = Sequelize.Promise; | |
const DEFAULT_BATCH_SIZE = 3000; | |
/** | |
* Port of ActiveRecord::Base.find_each of Rails. |
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
"use strict"; | |
const AWS = require('aws-sdk'); | |
const bluebird = require('bluebird'); | |
/** | |
* @returns {Promise.<boolean>} - is on 'master' instance or not | |
*/ | |
module.exports = bluebird.coroutine(function* (opts) { | |
if (opts == null) { |
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
files: | |
"/tmp/crontab": | |
mode: "000777" | |
owner: 'ec2-user' | |
group: 'ec2-user' | |
content: | | |
30 02 * * * sudo /usr/sbin/execute-in-eb-node-app 'node bin/is-eb-master.js' && sudo /usr/sbin/execute-in-eb-node-app 'npm run daily-maintenance' | |
encoding: plain | |
container_commands: | |
01-copy_eb_bin: |
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
export type SubsetOf<T> = { | |
[P in keyof T]?: T[P]; | |
}; |
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
<?php | |
// https://github.com/WebDevStudios/Automatic-Featured-Images-from-Videos/blob/1.2.0/automatic-featured-images-from-videos.php | |
/** | |
* If a YouTube or Vimeo video is added in the post content, grab its thumbnail and set it as the featured image. | |
* | |
* @since 1.0.0 | |
* | |
* @param int $post_id ID of the post being saved. | |
* @param string $video_thumbnail_url URL of the image thumbnail. |
OlderNewer