Skip to content

Instantly share code, notes, and snippets.

View SPY's full-sized avatar

Ilya Rezvov SPY

  • Google
  • Denver, USA
View GitHub Profile
import Control.Applicative ((<$>))
import Data.List (partition)
readNumList :: String -> [Int]
readNumList = map read . words
segmentsCount :: [Int] -> [[Int]] -> Int
segmentsCount [] _ = 0
segmentsCount (v:vs) edges = let (vs', es') = mark v vs edges in 1 + segmentsCount vs' es'
/// <reference path="../../defs/_references.d.ts" />
import {createFactory} from 'react';
import Rx from 'rx';
import RxComponent = require('src/utils/RxComponent');
const div = createFactory('div');
interface CounterProps {
signal: Rx.Observable<number>;
import Control.Applicative ((<$>))
import Text.Printf (printf)
type Solution = Maybe [Double]
gauss :: [[Double]] -> Solution
gauss [[a, b]] = return [b / a]
gauss (h@(x : xs) : t) = do
let minor = transform h t
if any isNull minor
import Control.Applicative ((<$>))
import Text.Printf (printf)
type Solution = Maybe [Double]
solve :: [[Double]] -> Solution
solve [[a, b]] = return [b / a]
solve (h@(x : xs) : t) = do
let minor = transform h t
if any isNull minor
var React = require('react');
var {Chart, Line, Axis, Layout} = require('react-chart');
var LineChart = React.createClass({
propTypes: {
data: React.propTypes.arrayOf(React.propTypes.shape({
x: React.propTypes.number.isRequired,
y: React.propTypes.number.isRequired
})).isRequired,
color: React.propTypes.string.isRequired
var good = [
[1,2,3,4,5,6,7,8],
[1,2,8,4,5,6,7,3],
[1,5,8,4,2,6,7,3]
];
var bad = [
[1,2,3,6,5,6,7,6],
[1,2,3,4,5,6,8],
[1,2,3,4,5,6,7,8,10]
];
@SPY
SPY / index.html
Last active August 29, 2015 14:14
Minimal webpack for ReactJS with ES6
<!DOCTYPE html>
<html>
<head><title>Example</title></head>
<body>
<script type="text/javascript" src="http://localhost:8090/webpack-dev-server.js"></script>
<script type="text/javascript" src="http://localhost:8090/assets/bundle.js"></script>
</body>
</html>
@SPY
SPY / andb_eq_orb.v
Last active January 1, 2016 22:38
(** **** Exercise: 2 stars (andb_eq_orb) *)
(** Prove the following theorem. (You may want to first prove a
subsidiary lemma or two.) *)
Lemma orb_always_true :
forall b,
orb true b = true.
Proof. reflexivity. Qed.
Lemma andb_always_false :
@SPY
SPY / gen_server.hs
Last active December 30, 2015 06:19
instance GenServerState Command Int CounterState where
handle_call Get = gets counter
handle_cast Inc =
modify $ \st -> st { counter = counter st + 1 }
-- another instance for CounterState
instance GenServerState Command Float CounterState where
handle_call Get = gets (fromIntegral . counter)
@SPY
SPY / Hello.hs
Last active December 29, 2015 00:48
{-# LANGUAGE BangPatterns, DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses #-}
module Proto.King.Hello (Hello(..)) where
import Prelude ((+), (/))
import qualified Prelude as Prelude'
import qualified Data.Typeable as Prelude'
import qualified Data.Data as Prelude'
import qualified Text.ProtocolBuffers.Header as P'
import qualified Proto.King.NodeDescription as King (NodeDescription)
data Hello = Hello{hNodeDesc :: !King.NodeDescription}