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
module Pokemon | |
define_method(:attack) do |&block| | |
block.call "generic attack" | |
end | |
end | |
class Pikachu | |
prepend Pokemon | |
def attack | |
yield 'thunderbolt' |
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
'use strict'; | |
function doYouEvenLiftBro (answer) { | |
const say = function () { console.log(answer); } | |
answer = 'no'; | |
return say; | |
} | |
doYouEvenLiftBro('hell yeah!')(); |
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
"use strict"; | |
function wakeup () { | |
console.log(`${this.type} is awake!`) | |
} | |
function Pokemon () { | |
this.type = arguments[0] || 'generic'; | |
} |
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 response = new HttpResponseMessage(); | |
response.Content = new StringContent(error); | |
response.StatusCode = code; | |
return Task<HttpResponseMessage>.Factory.StartNew(() => response); |
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 'sinatra' | |
require 'net/http' | |
require 'active_support/core_ext/hash' | |
require 'json' | |
discovery_document = ActiveSupport::HashWithIndifferentAccess.new(JSON.parse(Net::HTTP.get('accounts.google.com', '/.well-known/openid-configuration'))) | |
auth_url = discovery_document[:authorization_endpoint] | |
token_endpoint = discovery_document[:token_endpoint] | |
client_id = '###' | |
client_secret = '###' |
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
"use strict"; | |
class A { | |
constructor() { | |
this.events = {}; | |
} | |
on (type, fn) { | |
this.events[type] = fn; | |
} |
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
$.getJSON(this.routes.GET_PLAYERS) | |
.then(function (response) { | |
this.setState({ | |
players: response | |
}) | |
}.bind(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
handleChange () { | |
$.getJSON(url) | |
.then( data => { | |
this.setState({ data: data.result }); | |
}); | |
} |
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
let parent = React.createClass({ | |
getInitialState() { | |
return { active: this.props.children[0] }; | |
}, | |
handleClick (id) { | |
this.setState({ active: this.children[id] }); | |
} | |
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 getJSON (url, e) { | |
if(e) e.preventDefault(); | |
superagent | |
.get(url) | |
.set('X-Requested-With', 'XMLHttpRequest') | |
.end(function(err, res) { | |
content.innerHTML = render(JSON.parse(res.text)); | |
updateAddressBar(url); |