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
/** | |
* Simple benchmark copy paste for browsers using Benchmark.js | |
* See their documentation: https://benchmarkjs.com/ | |
* Edit the different suite add() sections below to change your tests or add new ones. | |
*/ | |
var Script = function(url) { | |
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; | |
po.src = url; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); |
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
# Wrap given block with link if.. | |
def link_wrap_if(apply_link, url, opts={}, &block) | |
if apply_link | |
link_to capture(&block), url, opts | |
else | |
capture(&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
require 'benchmark' | |
require 'socket' | |
ENV["RAILS_ENV"] = "test" | |
# Add test folder to load path | |
$: << './test' | |
puts Benchmark.measure{ | |
# Assuming test_helper requires config/environment |
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
urls = "" | |
DATA.each do |l| | |
img = l[/url\([^)]*\)/] | |
urls << "<img src=#{img.gsub(/url\(([^)]*)\)/, '\1')} /><hr />\n" if img | |
end | |
f = File.open("urltest.html", "w") {|file| file.truncate(0) } # Clear file contents | |
f = File.open("urltest.html", "w") | |
f.write urls | |
f.close |
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
// via http://www.redotheweb.com/2015/09/18/declarative-imperative-js.html | |
function getValue(object, propertyName) { | |
if (!propertyName) throw new Error('Impossible to set null property'); | |
return typeof object === 'undefined' ? undefined : object[propertyName]; | |
} | |
function getNestedValue(object, propertyName) { | |
return propertyName.split('.').reduce(getValue, object); | |
} |
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
var input = [[2,6],[3,5],[7,21],[20,21]]; | |
var expectedOutput = [[2,6],[7,21]]; | |
var rangesOverlap = function(range1, range2) { | |
return ( | |
(range1[1] >= range2[0] && range1[1] <=range2[1]) || | |
(range1[0] <= range2[0] && range1[1] >= range2[0]) | |
); | |
}; |
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
var params = { t: 123, type: 'mytype', channelId: 'mychan', badge:'thebadge' }; | |
var allowedPersonParams = ["type", "channelId", "badge", "since", "until"]; | |
// ES5 | |
var result = {}; | |
allowedPersonParams.forEach(function (paramName) { | |
if (currentParams[paramName]) { | |
result[paramName] = currentParams[paramName]; | |
} |
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
:%s/\/\*\{-1}\_.\{-}\*\///g |
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
/* | |
Gmail Client (ideas) | |
Usage: | |
var gmailClient = newGmailClient(myAccessToken); | |
var response = gmailClient.execute({ | |
url: "users/me/messages", | |
headers: {}, |
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
Zwei Dinge hat das Denken zu leisten: uns aus der naiven zur vertiefen Welt- | |
und Lebensbejahung zu füren und uns von ethischen Regungen zu einer | |
denknotwendigen Ethic gelangen zu lassen. | |
Vertiefe Welt- und Lebensbejahung besteht darin, dass wir den Willen haben, | |
unser Leben und alles durch uns irgendwie beeinflussbare Sein zu erhalten und | |
auf seinen höchsten Wert zu bringen. Sie verlangt von uns, dass wir alle | |
Ideale der materiellen und geistigen Vervollkommnung des Menschen, der | |
Gesellschaft und der Menschheit denken und uns durch sie zu stetem Wirken und | |
stetem Hoffen bestimmen lassen. Sie erlaubt uns nicht, uns auf uns selber |