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 maybe = (fn) => | |
function (...args) { | |
if (args.length === 0) { | |
return | |
} | |
else { | |
for (let arg of args) { | |
if (arg == null) return; | |
} | |
return fn.apply(this, args) |
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 once = (fn) => { | |
let done = false; | |
return function() { | |
return done ? void 0 : ((done = true), fn.apply(this, arguments)) | |
} | |
} |
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 barker = (state) => ({ | |
bark: () => console.log('Woof, I am ' + state.name) | |
}) | |
const driver = (state) => ({ | |
drive: () => state.position = state.position + state.speed | |
}) | |
const murderRobotDog = (name) => { |
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
// Better to use actual classes when dealing with LOTS (i.e. > 100,000) of objects | |
const dog = () => { | |
const sound = 'woof' | |
return { | |
talk: () => console.log(sound) | |
} | |
} | |
const sniffles = dog() |
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_relative 'some_file_name' | |
class Klass | |
def initialize(arg) | |
@arg = arg | |
end | |
def display | |
puts 'Hello #{@arg}' | |
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 'capybara' | |
session = Capybara::Session.new(:selenium) | |
session.driver.class.class_eval { def quit; end } | |
session.visit 'https://google.com' | |
session.fill_in 'lst-ib', :with => 'GameSparks' | |
session.find('#lst-ib').native.send_keys(:return) | |
session.find_link('GameSparks | The #1 Backend-as-a-Service platform for ...').click |
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() { | |
var s = document.createElement('script'); | |
s.type = 'text/javascript'; | |
s.async = true; | |
// has to be https to work... | |
s.src = '//cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js'; | |
document.getElementsByTagName('body')[0].appendChild(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
env X="() { :;} ; echo you might be vulnerable" /bin/bash -c "echo hello" |
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
$.fn.extensionName = function() { | |
// code goes here... | |
return this; | |
} |
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
// Makes out.pdf with page 1 of in.pdf | |
pdftk in.pdf cat 1 output out.pdf |