Skip to content

Instantly share code, notes, and snippets.

View gto76's full-sized avatar

Jure Šorn gto76

View GitHub Profile
@gto76
gto76 / bitmap-filters.scala
Created November 11, 2015 14:08
Scala bitmap filters
#!/bin/sh
exec scala "$0" "$@"
!#
import java.io.File
import java.awt.image.BufferedImage
import javax.imageio.ImageIO
import javax.imageio.ImageTypeSpecifier
import java.awt.image.DataBufferByte
import java.awt.image.DataBufferInt
@gto76
gto76 / js-tanks.html
Created November 10, 2015 19:41
Javascript game - not finished
<!DOCTYPE html>
<html>
<head>
<title>Player Movement using onkeydown/onkeyup (Enhanced version)</title>
<style type="text/css" media="screen">
canvas { border: 1px solid; }
</style>
<script type="text/javascript" charset="utf-8">
/////////////
@gto76
gto76 / src-to-pdf.sh
Last active June 5, 2019 17:03
Script that converts source code to PDF
#!/usr/bin/env bash
#
# Creates pdf file from source code.
tex_file=$(mktemp) ## Random temp file name
cat<<EOF >$tex_file ## Print the tex file header
\documentclass{article}
\usepackage{listings}
\usepackage[usenames,dvipsnames]{color} %% Allow color names
@gto76
gto76 / install-scala.sh
Last active November 10, 2015 19:43
Script that installs Scala
#!/bin/bash
#
# Installs Scala.
# Install Scala:
SCALA_VERSION="2.11.1";
wget http://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz
tar xvzf scala-$SCALA_VERSION.tgz
sudo sh -c 'echo "export SCALA_HOME=\"$PWD/scala-'$SCALA_VERSION'\"" >> /etc/profile; echo "export PATH=\"\$PATH:\$SCALA_HOME/bin\"" >> /etc/profile;'
sh /etc/profile
@gto76
gto76 / scala-examples.md
Last active November 10, 2015 16:57
Scala examples

Scala Examples

Sum two inputs:

println(io.Source.stdin.getLines().take(2).map(_.toInt).sum)

Repeat each element of list num times:

def f(num:Int,arr:List[Int]):List[Int] = arr.map(x =&gt; List.fill(num)(x)).flatten
@gto76
gto76 / js-examples.md
Last active November 10, 2015 16:57
Short javascript examples

Js Examples

short javascript examples

function testJson() {
    var aaa = '{"words":{\
    "ena": [{"id": "1","loc": "1"},{"id": "2","loc": "2"}],\
    "dva": [{"id": "4","loc": "2"},{"id": "7","loc": "3"}]\
    }}';
    var bbb = JSON.parse(aaa);