Skip to content

Instantly share code, notes, and snippets.

View alogic0's full-sized avatar

Oleg Tsybulskyi alogic0

  • Odessa, Ukraine
View GitHub Profile
@alogic0
alogic0 / Astro.hs
Created January 27, 2015 08:24
Constants and formulae for IntroAstro on Coursera
import Data.Ratio
mS=19891*10^26 % 1 --in kg Sun mass
mE=597219*10^19 % 1 --in kg Earth mass
rE=6371000 % 1 --in m Earth radius
tE=3652564 % 10000 --in days Earth siderial year
mM=73477*10^18 % 1 --in kg Moon mass
rM=1737500 % 1 --in m Moon radius
aU=149597870691 % 1 --in m distance to Sun
gN=6673 % (10^14) --in m3/(kg*s2) gravitational constant G
@alogic0
alogic0 / less.hs
Last active August 29, 2015 14:16
For ghci, pager of defined names in Haskell modules like *less*
-- author [Roman Cheplyaka](http://www.reddit.com/r/haskell/comments/2y2f1p/pager_in_ghci_like_less/cp5w8a9)
import System.Process
import System.Posix.IO
import System.Posix.Types
import Data.IORef
import Data.List (intersperse)
import System.IO.Unsafe
{-# NOINLINE pid_ref #-}
pid_ref :: IORef (ProcessHandle, Fd)
// To auto-click the big cookie at a set interval, use:
var autoClicker = setInterval(Game.ClickCookie, 50);
// To end this effect, use:
clearInterval(autoClicker);
//This will spawn a golden cookie
Game.shimmerTypes.golden.time = Game.shimmerTypes.golden.maxTime;
// If you just want to set the amount of golden cookies clicked, use:
@alogic0
alogic0 / Pong.elm
Last active August 29, 2015 14:19
Pong game for 1 player, run on http://elm-lang.org/try
-- See this document for more information on making Pong:
-- http://elm-lang.org/blog/Pong.elm
-- Compile this code on http://elm-lang.org/try
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Keyboard
import Mouse
import Text
@alogic0
alogic0 / tickets.hs
Last active August 29, 2015 14:24
tickets cost
lst = [206.51]
++ replicate 5 135.93
++ replicate 15 160.4
++ replicate 2 190.25
++ [1586.42]
debt = sum lst
-- m
m = [-3000]
@alogic0
alogic0 / fib999.hs
Last active August 29, 2015 14:24
Fibonacci numbers in chunks of decimal part of division 1 by 9999...899...
num48 = 999999999999999999999998999999999999999999999999
strNum24 = replicate 47 '0' ++ show (10 ^ (58*48) `div` num48)
chunks _ [] = []
chunks n xs = let (h, t) = splitAt n xs in h : chunks n t
result24 = putStr $ unlines $ map (unwords . chunks 24) $ chunks 48 strNum24
--------
fibs :: [Integer]
fibs = 0:1: zipWith (+) fibs (tail fibs)
@alogic0
alogic0 / Nptel_ass2_test_hunit.hs
Last active August 29, 2015 14:27
NPTEL Haskell 2015, HUnit test for Assignment 2
module Nptel_ass2_test_hunit
where
import Test.HUnit
import Test.Hspec
import Test.Hspec.Contrib.HUnit
-- Name of your file with the assignment
-- without trailing .hs
import Nptel_ass2
@alogic0
alogic0 / Nptel_ass2_test_hspec.hs
Created August 19, 2015 15:16
NPTEL Haskell 2015, HSpec test for Assignment 2
module Nptel_ass2_test_hspec where
import Nptel_ass2
import Test.Hspec
main :: IO ()
main = hspec $ do
describe "Assignment 2" $ do
describe "ramanujan" $ do
it "Test Case 1" $ do
@alogic0
alogic0 / Families.hs
Last active October 4, 2015 22:21
Changing fmaily-names diversity over generations
module Families where
import System.Random
import Control.Monad
import Data.List
numPop = 20
num = numPop `div` 2
type Generation = [Pair]
data Pair = Pair {husband::Person, wife::Person, idFamily::Int}
@alogic0
alogic0 / hmatrix-building-win7.md
Last active December 14, 2015 03:53
How to build hmatrix, Haskell package, on Win7