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 ActiveRecord | |
class Schema | |
attr_reader :users, :people | |
def initialize | |
@people = [] | |
@users = [] | |
end | |
def self.define(*args, &block) |
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
# Allow iteration on a flattened Enumerable. | |
# e.g. [1,[2,3],[[4]]].flat.map { |x| x * 2 } | |
# | |
module Enumerable | |
def stack_flat_wip(&block) | |
return to_enum(__method__) unless block_given? | |
idx = [0] | |
curr = self | |
while idx.any? && curr | |
puts idx.inspect |
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 CircularQueue { | |
constructor (size) { | |
this._max = size; | |
this._start = 0; | |
this._end = 0; | |
this._length = 0; | |
this._queue = new Array(size); | |
} | |
enq (item) { |
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
# Using standard library | |
fib = Enumerator.new do |y| | |
a = b = 1 | |
loop do | |
y << a | |
a, b = b, a + b | |
end | |
end | |
p fib.take(10) |
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
function t(type, htmlPropsOrFirstChild, ...children) { | |
const element = document.createElement(type); | |
if (htmlPropsOrFirstChild) { | |
if (htmlPropsOrFirstChild.constructor === Object) { | |
Object.assign(element, htmlPropsOrFirstChild); | |
} else { | |
children.unshift(htmlPropsOrFirstChild); | |
} | |
} |
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
// Put this in JavaScript console (F12 -> "Console") | |
document.querySelectorAll('.d-options input').forEach(function (input) { input.click(); }) |
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
#!/usr/bin/env ruby | |
require 'open-uri' | |
require 'json' | |
USER = 'YOUR-GITHUB-USERNAME' | |
# Generate a token with "repo" scope enabled: https://github.com/settings/tokens/new | |
TOKEN = 'YOUR-PERSONAL-ACCESS-TOKEN' | |
today = Date.today |
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
ALTER DATABASE seek_production CHARACTER SET utf8 COLLATE utf8_unicode_ci; | |
connect seek_production; | |
ALTER TABLE activity_logs CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; | |
ALTER TABLE admin_defined_role_projects CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; | |
ALTER TABLE annotation_attributes CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; | |
ALTER TABLE annotation_value_seeds CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; | |
ALTER TABLE annotation_versions CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; | |
ALTER TABLE annotations CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; |