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
\section{Programming in Octave} | |
Just like any other programming language, Octave has its loop and conditional | |
constructs. The following example demonstrates how to generate the first 10 | |
values of Fibonacci's sequence using a for loop: | |
<<Fibonacci sequence>>= | |
fib = [ 0, 1 ]; | |
for i = 3:10 | |
fib = [ fib, fib( i-2 ) + fib( i-1 ) ]; |
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
include "/usr/share/X11/locale/en_US.UTF-8/Compose" | |
# Punctuation | |
# знаки препинания, необходимые в русском, которых нет в en_US.UTF-8/Compose | |
<Multi_key> <period> <minus> : "…" U2026 # HORIZONTAL ELLIPSIS, многоточие | |
<Multi_key> <period> <space> : "…" U2026 # HORIZONTAL ELLIPSIS, многоточие | |
<Multi_key> <?> <!> : "⁈" U2048 # QUESTION EXCLAMATION, ?! | |
<Multi_key> <period> <colon> : "…" # ELLIPSIS | |
# №: набирается в русской раскладке без ухищрений, |
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 qualified Data.Array as A | |
import Control.Parallel.Strategies | |
ack 0 n = n+1 | |
ack m 0 = ack (m-1) 1 | |
ack m n = ack (m-1) (ack m (n-1)) | |
main = do | |
let arr = A.listArray (0,999) [1..] :: A.Array Int Int | |
let res = (fmap (ack 2) arr) `using` parTraversable rdeepseq |
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
%% This program is free software; you can redistribute it and/or | |
%% modify it under the terms of the GNU General Public License | |
%% as published by the Free Software Foundation; either version 2 | |
%% of the License, or (at your option) any later version. | |
%% | |
%% This program is distributed in the hope that it will be useful, | |
%% but WITHOUT ANY WARRANTY; without even the implied warranty of | |
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
%% GNU General Public License for more details. | |
%% |
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
from scipy.misc import imread, imsave | |
from scipy import mean, interp, ravel, array | |
from itertools import izip | |
import sys | |
def mkcurve(chan1,chan2): | |
"Calculate channel curve by averaging target values." | |
fst = lambda p: p[0] | |
snd = lambda p: p[1] | |
sums = {} |
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
"""Usage: python matchcolors.py good.jpg bad.jpg save-corrected-as.jpg""" | |
from scipy.misc import imread, imsave | |
from scipy import mean, interp, ravel, array | |
from itertools import izip | |
import sys | |
def mkcurve(chan1,chan2): | |
"Calculate channel curve by averaging target values." | |
fst = lambda p: p[0] |
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
#!/usr/bin/env runhaskell | |
A password generator inspired by XKCD #936: http://xkcd.com/936/ | |
Passwords which are easy for humans to remeber and hard for computers to guess. | |
> import Control.Monad (liftM, when) | |
> import Data.List (intercalate, isPrefixOf) | |
> import System.Random (getStdGen, randomRs) | |
> import System.Environment (getArgs) |
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
{-# LANGUAGE NoMonomorphismRestriction #-} | |
import Diagrams.Prelude | |
import Diagrams.Backend.Cairo.CmdLine | |
import Diagrams.TwoD.Util (width, height) | |
pentax_q = (6.16, 4.62) -- as 1/2.3" | |
oly_xz1 = (7.89, 5.81) -- http://j.mp/qfuFxT | |
nikon_cx = (13.2, 8.8) | |
four_thirds = (20.7, 13.8) |
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
#!/usr/bin/env python | |
from __future__ import with_statement | |
from cgi import escape | |
from os.path import expanduser | |
from string import Template | |
from sys import argv, version_info, exit | |
from xml.etree import ElementTree as ET | |
# import pickle | |
import warnings |
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 Data.List (intercalate) | |
data C = Wolf | Goat | Cabbage deriving (Show, Eq) |