This file contains hidden or 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 isValidOrder(order, customer) { | |
const salesTaxPercentage = 0.15 | |
return | |
order.units > 1 && | |
order.state == 'complete' && | |
order.price * (1.0 + salesTaxPercentage) < customer.availableBalance | |
} |
This file contains hidden or 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
# cookbook/ingredients/schema.py | |
from graphene import relay, ObjectType | |
from graphene.contrib.django.filter import DjangoFilterConnectionField | |
from graphene.contrib.django.types import DjangoNode | |
from cookbook.ingredients.models import Category, Ingredient | |
# Graphene will automatically map the Category model's fields onto the CategoryNode. | |
# This is configured in the CategoryNode's Meta class (as you can see below) |
This file contains hidden or 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 PersonRow exposing (..) | |
import Html exposing (..) | |
import Html.App as App | |
import WeekButtons | |
-- MODEL | |
type alias Model = { |
This file contains hidden or 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
import ModelStore from './model_store' | |
class ModelEnricher { | |
constructor() { | |
this.modelStore = new ModelStore(); | |
} | |
enrichAggregateResult(result, onSuccess) { | |
const modelKeys = this.modelKeys(result.results); | |
this.modelStore.loadModels(modelKeys, (results) => { |
This file contains hidden or 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.exports = () -> | |
request = require('request').defaults( | |
headers: | |
'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0', | |
'Accept-Language': "en-US,en;q=0.5", | |
'Connection': "keep-alive" | |
) | |
cheerio = require('cheerio') | |
request.post 'https://fetlife.com/session', {jar: true, followRedirect: true, form: {nickname_or_email: 'make-you-a-man', password: 'studmuffin', utf8: '✓'}}, (error, response, body) -> |
This file contains hidden or 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 IndentManager | |
def initialize | |
@indents = [] | |
@parse_complete = false | |
end | |
def register_indent(indent) | |
@indents << indent | |
end |
This file contains hidden or 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 CreateInitialDb < ActiveRecord::Migration | |
def change | |
create_table :people do |t| | |
end | |
create_table :buckets do |t| | |
end | |
create_table :budgets do |t| | |
end |
This file contains hidden or 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 Xeroizer | |
module Http | |
private | |
def http_request(client, method, url, body, params = {}) | |
# headers = {'Accept-Encoding' => 'gzip, deflate'} |
This file contains hidden or 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 'monthify' | |
module Weekify | |
module HasWeeks | |
def to_weeks | |
(Week.containing(first_day))..(Week.containing(last_day)) | |
end | |
end | |
class DateRange < Range |
This file contains hidden or 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 MyPlugin | |
constructor: (element, options) -> | |
@elem = $(element) | |
@settings = $.extend(param: "defaultValue", options or {}) | |
# Public method | |
publicMethod: () -> | |
console.log "publicMethod() called!" | |
$.fn.myplugin = (options) -> |