Skip to content

Instantly share code, notes, and snippets.

View joshy's full-sized avatar

Joshy Cyriac joshy

  • Universitätsspital Basel
  • Basel
View GitHub Profile
@joshy
joshy / caesar.clj
Created September 4, 2013 07:46
Simple caesar encode/decode of strings in clojure.
(ns caesar.core)
(def secret "RVAWNUEVFGJVRQREIBEORVHAQRFUNGXHPURAORQVRAGRHPU")
(def text "EINJAHRISTWIEDERVORBEIUNDESHATKUCHENBEDIENTEUCH")
(defn encode
"Encodes the text with shifting each char shift positions"
[text shift]
(apply str (map char (map #(+ (mod (+ shift %) 26) 65) (map int text)))))
@joshy
joshy / santa.dart
Last active December 30, 2015 21:39
santa.dart A try to learn dart, solution to the "santa problem" https://plus.google.com/118397406534237711570/posts/XjgFRvqtVA4
import 'dart:io';
import 'dart:async';
import 'dart:convert';
import 'dart:collection';
void main() {
print("Please, enter 'first name' and 'last name' finish with a empty line\n");
Stream cmdLine = stdin
.transform(UTF8.decoder)
.transform(new LineSplitter());
@joshy
joshy / rotateSquare.elm
Last active August 29, 2015 14:00
Rotate a square a couple of times with elm
square : Path
square = path [ (50,50), (50,-50), (-50,-50), (-50,50), (50,50) ]
blueSquare : Form
blueSquare = traced (dashed blue) square
rotateSquareBy : Float -> Form
rotateSquareBy deg = rotate deg blueSquare
degrees : [number]
@joshy
joshy / alice-word-count
Created July 9, 2014 13:01
Apache Pig - Word count explained
-- Read the whole book and save it to input_lines
input_lines = LOAD 'alice-im-wunderland.txt' using TextLoader() as (line:chararray);
-- Extract words from each line and put them into a pig bag
-- datatype, then flatten the bag to get one word on each row
words = foreach input_lines generate flatten(TOKENIZE(line)) AS word;
-- filter out any words that are just white spaces
filtered_words = FILTER words by word MATCHES '\\w+';
@joshy
joshy / functor-example.hs
Created August 4, 2014 11:50
Functor example from FP Complete
import Safe (readMay)
display maybeAge =
case maybeAge of
Nothing -> putStrLn "Could not read input."
Just age -> putStrLn $ "In 2020, you will be: " ++ show age
yearToAge age = 2020 - age
main = do
@joshy
joshy / bezier.elm
Last active March 22, 2016 19:48
Bezier curve in Elm
import Mouse
import Window
import Signal as S
import Color exposing (..)
import List exposing (..)
import Graphics.Collage exposing (..)
main = S.map2 draws Window.dimensions stateSignal
@joshy
joshy / move-point.elm
Created August 19, 2014 11:25
Simple example of drawing a point and then make that point "moveable"
import Mouse
import Window
main : Signal Element
main = lift2 scene Window.dimensions lastClickLocation
input : Signal (Int, Int)
input = sampleOn Mouse.clicks Mouse.position
import Graphics.Element (..)
import Signal (Signal, map, map2, sampleOn)
import Mouse
import Text (asText)
import Window
main : Signal Element
main = map asText mousePos
import Signal
import Graphics.Element exposing (Element, show)
import Task exposing (Task)
main : Signal Element
main =
Signal.map show contentMailbox.signal
@joshy
joshy / HackerNewsExample.elm
Last active August 29, 2015 14:25 — forked from TheSeamau5/HackerNewsExample.elm
Hacker news requests example
--------------------------
-- CORE LIBRARY IMPORTS --
--------------------------
import Task exposing (Task, ThreadID, andThen, sequence, succeed, spawn)
import Json.Decode exposing (Decoder, list, int, string, (:=), map, object2)
import Signal exposing (Signal, Mailbox, mailbox, send)
import List
---------------------------------
-- THIRD PARTY LIBRARY IMPORTS --