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
/** Instructions: | |
* | |
* This script is meant to make it easy to test out various transparent | |
* textures from transparenttextures.com. I used Python + Requests + | |
* BeautifulSoup to generate the list of textures. A similar method could be | |
* used to try out backgrounds from a site such as subtlepatterns.com (in | |
* fact, these names probably work with that site, if you change the source | |
* variable). | |
* | |
* In order to see the currect texture's name, include this snippet directly |
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 Control.Applicative | |
import System.Environment | |
main :: IO () | |
main = do | |
n <- (read :: String -> Int) . (!!0) <$> getArgs | |
putStrLn $ dragon n | |
dragon :: Int -> String | |
dragon 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
<!doctype html> | |
<html> | |
<head> | |
<title>Empty Canvas</title> | |
<style type="text/css"> | |
html, body{ | |
overflow:hidden; | |
margin: 0px; | |
} | |
canvas{ |
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 java.util.ArrayList; | |
/** | |
* A demonstration of the lack of multiple dispatch in Java | |
* Notice how there is late dispatch on the object which owns "multi" | |
* | |
* (i.e the 'c' in `c.multi(o)`) | |
* But there is only static dispatch on method arguments | |
* (i.e the 'o' in `c.multi(o)`) | |
* |
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.IO | |
import Data.List.Split (chunksOf) | |
import Data.List (foldl') | |
import Control.Monad (forever) | |
import Data.Set (Set) | |
import qualified Data.Set as Set | |
import Data.Map (Map) | |
import qualified Data.Map as Map | |
type State = String |
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
class SymbolException(Exception): | |
pass | |
def make_dfa(symbols, states, start, finals, transitions): | |
def dfa(input): | |
cur_state = start | |
for cur_input in input: | |
if cur_input not in symbols: | |
raise SymbolException | |
cur_state = transitions[cur_state][cur_input] |
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
def make_state(name, states, transitions, is_final): | |
def state(string, index): | |
if index >= len(string): | |
return is_final | |
cur_input = string[index] | |
next_state = transitions[cur_input] | |
return states[next_state](string, index + 1) | |
states[name] = state |
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
class DFA(object): | |
def __init__(self, states=None, initial=None, finals=None, transitions=None): | |
""" states: set(state) | |
initial: state (string) | |
finals: set(state) | |
transitions: {state: {symbol: state}} | |
""" | |
self.states = {} | |
self.finals = set() | |
if initial: |
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.Environment | |
import Control.Applicative | |
import Data.Maybe | |
import Data.List | |
import Data.List.Split | |
import Data.Map.Strict ((!), Map, fromList) | |
type Class = String | |
type Mean = Double | |
type StdDevSquared = Double |
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
Predicting class g for instance [1.0,0.0,0.99539,-5.889e-2,0.85243,2.306e-2,0.83398,-0.37708,1.0,3.76e-2,0.85243,-0.17755,0.59755,-0.44945,0.60536,-0.38223,0.84356,-0.38542,0.58212,-0.32192,0.56971,-0.29674,0.36946,-0.47357,0.56811,-0.51171,0.41078,-0.46168,0.21266,-0.3409,0.42267,-0.54487,0.18641,-0.453], class: g -- Correct! | |
Predicting class b for instance [1.0,0.0,1.0,-0.18829,0.93035,-0.36156,-0.10868,-0.93597,1.0,-4.549e-2,0.50874,-0.67743,0.34432,-0.69707,-0.51685,-0.97515,5.499e-2,-0.62237,0.33109,-1.0,-0.13151,-0.453,-0.18056,-0.35734,-0.20332,-0.26569,-0.20468,-0.18401,-0.1904,-0.11593,-0.16626,-6.288e-2,-0.13738,-2.447e-2], class: b -- Correct! | |
Predicting class g for instance [1.0,0.0,1.0,-3.365e-2,1.0,4.85e-3,1.0,-0.12062,0.88965,1.198e-2,0.73082,5.346e-2,0.85443,8.27e-3,0.54591,2.99e-3,0.83775,-0.13644,0.75535,-8.54e-2,0.70887,-0.27502,0.43385,-0.12062,0.57528,-0.4022,0.58984,-0.22145,0.431,-0.17365,0.60436,-0.2418,0.56045,-0.38238], class: g -- Correct! | |
Predicting class b for instance [1.0,0.0,1. |