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
Show hidden characters
{ | |
//Enforcing options | |
"bitwise" : true, // no bitwise operators | |
"camelcase" : true, // variable names camelCase or UPPER_CASE | |
"curly" : true, // curly braces around blocks | |
"eqeqeq" : true, // no == and != | |
"es3" : false, // ECMAScript 3 specification | |
"forin" : true, // for in loops must filter object's items | |
"freeze" : false, // prevent overwriting native objects | |
"immed" : true, // immediate function invocations must be wrapped in () |
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
#!/bin/bash | |
JSCSS=$'/* Copyright (C) 2014 Wesleyan University | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.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
import Data.Map (Map) | |
import qualified Data.Map as Map | |
import Data.Foldable | |
isAnagram :: [Char] -> [Char] -> Bool | |
isAnagram xs ys = f xs ys Map.empty | |
where | |
f :: [Char] -> [Char] -> Map Char Int -> Bool | |
f (x:xs) ys m = if x `Map.member` m |
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
import System.Random | |
f :: [a] -> IO a | |
f xs = f' xs [] 1 where | |
f' :: [a] -> [a] -> Int -> IO a | |
f' [] z _ = return $ head z | |
f' (x:xs) z i = do r <- randomRIO (1,i) | |
if r == 1 | |
then f' xs [x] (i + 1) | |
else f' xs z (i + 1) |
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
import time, string | |
from scrapy.spider import BaseSpider | |
from scrapy.http import FormRequest | |
from scrapy.item import Item, Field | |
from scrapy.selector import HtmlXPathSelector | |
from selenium import webdriver | |
from selenium.webdriver.support.wait import WebDriverWait | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.webdriver.common.by import By | |
from selenium.common.exceptions import NoSuchElementException |
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
{-# LANGUAGE FlexibleContexts #-} | |
{- Construct recursive descent parsers for the following grammars -} | |
import Text.Parsec | |
(<||>) :: ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a | |
p <||> q = try p <|> q | |
{- S -> + S S | - S S | a -} | |
data G1 = P1G1 G1 G1 | P2G1 G1 G1 | T1G1 deriving (Eq, Show) | |
g1 :: Stream s m Char => ParsecT s u m G1 |
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
type Point = (Float,Float) | |
type GridU = U.Vector Point | |
{- Explanation: colorPixel evaluates to the color of a pixel for a given world | |
- Antialiasing is tracing > 1 rays through each pixel and averaging the results. | |
- Soft shadows are shadows that do not have a hard edge, this requires sending multiple shadow rays to each light. | |
- Depth of field: only objects at a certain distance are in focus. To do this we send multiple rays though each antialising | |
- point with each base perturbed slightly. Objects are in focus if they are at the distance the view plane is at. | |
- | |
- Three 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
total time = 132.70 secs (132702 ticks @ 1000 us, 1 processor) | |
run.img Main 427 1 0.0 0.0 98.2 97.6 | |
render RayTracer 428 1 0.0 0.0 98.2 97.6 | |
render.cs RayTracer 585 1 98.1 97.6 98.2 97.6 | |
compare RayTracer 639 3971855 0.0 0.0 0.0 0.0 | |
== Geometry3 638 1676386 0.0 0.0 0.0 0.0 | |
wLights RayTracer 637 1871708 0.0 0.0 0.0 0.0 | |
wAmbient RayTracer 636 1871708 0.0 0.0 0.0 0.0 | |
wImgHt RayTracer 633 3840000 0.0 0.0 0.0 0.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
import org.scalacheck.Properties | |
import org.scalacheck.Prop.{forAll, BooleanOperators} | |
import scala.util.Random | |
def quickSelect[A <% Ordered[A]](seq: Seq[A], n: Int, rand: Random = new Random): A = { | |
val pivot = rand.nextInt(seq.length); | |
val (left, right) = seq.partition(_ < seq(pivot)) | |
if (left.length == n) { | |
seq(pivot) | |
} else if (left.length < n) { |
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
shuffle.partitions=200 | |
collect: 5s, 2 stages, 220 tasks | |
runJob: 8s, 6 stages, 660 tasks | |
shuffle.partitions=60 | |
collect: 5s, 2stages, 80 tasks | |
runJob: 8s, 6 stages, 240 tasks | |
collect: | |
stage 1 remains the same, 5s, 20 tasks, 1909.2MB input, 48.1MB shuffle write |
OlderNewer