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
function mapValues(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
result[key] = fn(obj[key], key); | |
return result; | |
}, {}); | |
} | |
function pick(obj, fn) { | |
return Object.keys(obj).reduce((result, key) => { | |
if (fn(obj[key])) { |
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
/** | |
* @license | |
* Video.js 7.6.6 <http://videojs.com/> | |
* Copyright Brightcove, Inc. <https://www.brightcove.com/> | |
* Available under Apache License Version 2.0 | |
* <https://github.com/videojs/video.js/blob/master/LICENSE> | |
* | |
* Includes vtt.js <https://github.com/mozilla/vtt.js> | |
* Available under Apache License Version 2.0 | |
* <https://github.com/mozilla/vtt.js/blob/master/LICENSE> |
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
# Sample DATABASE_URL = dbms://username:password@hostname:port/dbname | |
DB_PROTOCOL=$(echo $DATABASE_URL | cut -d':' -f1) | |
DB_DETAILS=$(echo $DATABASE_URL | cut -d'/' -f3) | |
DB_NAME=$(echo $DATABASE_URL | cut -d'/' -f4) | |
HOST_NAME=$(echo $DB_DETAILS | cut -d'@' -f2 | cut -d':' -f1) | |
PORT=$(echo $DB_DETAILS | cut -d'@' -f2 | cut -d':' -f2) | |
USER_NAME=$(echo $DB_DETAILS | cut -d'@' -f1 | cut -d':' -f1) | |
PASSWORD=$(echo $DB_DETAILS | cut -d'@' -f1 | cut -d':' -f2) | |
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
window.updateParamAndReload = function(paramName, value) { | |
var url = new URL(window.location.toString()) | |
url.searchParams.set(paramName, value) | |
window.location = url | |
} |
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
const { Builder, By, until } = require('selenium-webdriver'); | |
const driver = new Builder() | |
.forBrowser('chrome') | |
.build(); | |
const waitForTitle = () => { | |
return driver.getTitle().then((title) => title.includes('JSFiddle')); | |
} | |
const runTests = () => { |
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
# frozen_string_literal: true | |
# This file defines the configuration for mail reading through pop3 protocol | |
# using 'Mailman' library. Place this file inside `config/initializers` if you are on Rails. | |
# Poll interval must be specified seconds, it defaults to 10 seconds | |
Mailman.config.poll_interval = (ENV['MAILBOX_POLL_INTERVAL'] || 10).to_i | |
# POP3 settings | |
Mailman.config.pop3 = { | |
server: ENV['POP3_SERVER'], |
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
SOURCE_APP = ARGV[0] | |
DESTINATION_APP = ARGV[1] | |
if SOURCE_APP.nil? || DESTINATION_APP.nil? | |
puts 'USAGE: ruby copy_heroku_config.rb SOURCE_APP_NAME DESTINATION_APP_NAME' | |
end | |
# Parsing heroku configs | |
configs = `heroku config --app #{SOURCE_APP}` | |
configs = configs.split('\n') |
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
def files(file) | |
return file unless ( file = Pathname.new(file) and File.directory?(file) ) | |
file.children.map { |f| files(f) } | |
end | |
# files(".") => [#<Pathname:hello.rb>, #<Pathname:spec/hello.rb>, #<Pathname:spec/hai.rb>, ...] |
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
class String | |
def method_missing(method, *args, &block) | |
method_name = method.to_s | |
if method_name.include?("is_") && method_name.include?("?") | |
method_name = method_name.gsub("is_", "")[0..-2] | |
(method_name == self) || (method_name.camelize == self) || (method_name.titleize == self) || (method_name.gsub(" ", "") == self) | |
else | |
super(method, *args, &block) | |
end | |
end |
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
class String | |
def titleize | |
u_split = split("_") | |
s_split = u_split.map { |s| s.split(" ") }.flatten | |
if s.split.empty? | |
capitalize | |
else | |
s_split.map(&:capitalize).join(" ") | |
end |
NewerOlder