Skip to content

Instantly share code, notes, and snippets.

module Pokemon
define_method(:attack) do |&block|
block.call "generic attack"
end
end
class Pikachu
prepend Pokemon
def attack
yield 'thunderbolt'
'use strict';
function doYouEvenLiftBro (answer) {
const say = function () { console.log(answer); }
answer = 'no';
return say;
}
doYouEvenLiftBro('hell yeah!')();
"use strict";
function wakeup () {
console.log(`${this.type} is awake!`)
}
function Pokemon () {
this.type = arguments[0] || 'generic';
}
var response = new HttpResponseMessage();
response.Content = new StringContent(error);
response.StatusCode = code;
return Task<HttpResponseMessage>.Factory.StartNew(() => response);
@nicohvi
nicohvi / oauth.rb
Last active December 2, 2015 15:50
Simple google oauth example
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 = '###'
"use strict";
class A {
constructor() {
this.events = {};
}
on (type, fn) {
this.events[type] = fn;
}
$.getJSON(this.routes.GET_PLAYERS)
.then(function (response) {
this.setState({
players: response
})
}.bind(this));
handleChange () {
$.getJSON(url)
.then( data => {
this.setState({ data: data.result });
});
}
let parent = React.createClass({
getInitialState() {
return { active: this.props.children[0] };
},
handleClick (id) {
this.setState({ active: this.children[id] });
}
@nicohvi
nicohvi / app-address.js
Last active October 10, 2015 16:12
Werewolf-final
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);