Skip to content

Instantly share code, notes, and snippets.

View cheeyeo's full-sized avatar
💭
Researching on use of transformers in computer vision

Chee Yeo cheeyeo

💭
Researching on use of transformers in computer vision
View GitHub Profile
@cheeyeo
cheeyeo / concept.js
Last active March 19, 2021 08:45
tracking when window.open closes
// http://stackoverflow.com/questions/3291712/is-it-possible-to-open-a-popup-with-javascript-and-then-detect-when-the-user-clo
// The window.opener property refers to the page that spawned this popup.
// For example, if I wrote a function named callingPageFunction on my original page, I would call it from the popup like this:
$(window).unload(function() {
window.opener.callingPageFunction()
});
var wnd = window.open("file.html", "youruniqueid", "width=400, height=300");
/**
* Simple event dispatcher
*
* Example
*
* var MyConstructor = function () {
* var self = this
* var count = 0
* setInterval(function () {
* self.emit('tick', {count: count})
class ActiveSupport::IntegrationCase < ActiveSupport::TestCase
include Capybara
include Rails.application.routes.url_helpers
self.use_transactional_fixtures = false
# Checks for missing translations after each test
teardown do
unless source.blank?
# Natively, Enumerators get JSONized like "#<Enumerator::Lazy:0x007f8714807080>", or they explode, either of which is a problem.
# We want them to make an array, and do it lazily so we don't have to keep the items in memory!
class Enumerator
def to_json(state)
state.depth += 1
string = "[\n"
first_item = true
self.each do |item|
@cheeyeo
cheeyeo / capture.rb
Last active August 29, 2015 14:16
Capture output from stdout
require "tempfile"
# Captures the given stream and returns it:
#
# stream = capture(:stdout) { puts 'notice' }
# stream # => "notice\n"
#
# stream = capture(:stderr) { warn 'error' }
# stream # => "error\n"
@cheeyeo
cheeyeo / link.md
Created February 20, 2015 20:51
Content security policy and related gems