Skip to content

Instantly share code, notes, and snippets.

View Caellian's full-sized avatar

Tin Švagelj Caellian

View GitHub Profile
@Caellian
Caellian / properInput.cpp
Last active March 18, 2019 00:58
Fixed number input.
#include <iostream>
#include <string>
#include <sstream>
template <class T>
void readInto(T *var, const std::string &inputMessage, const std::string &errorMessage) {
std::string input;
while (true) {
std::cout << inputMessage;
#include <iostream>
using namespace std;
int main() {
int unos;
cout<<"Unesi broj u intervalu <2,10>: ";
cin>>unos;
while(unos<=2 || unos>=10) {
@Caellian
Caellian / nkd.cpp
Created October 27, 2018 14:43
NKD
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
std::vector<std::string> nkd;
int k, n;
int main()
{
@Caellian
Caellian / Submatrix.scala
Created September 13, 2018 13:00
Example of dense and uncommented code.
/**
* Creates a new matrix without specified rows & columns.
*
* @param deletedRows rows to exclude from submatrix.
* @param deletedColumns columns to exclude from submatrix.
* @return defined submatrix.
*/
def submatrix(deletedRows: Array[Int], deletedColumns: Array[Int]): MatrixF = {
val result = Array.ofDim[Float](rowCount - deletedRows.count(rowCount >= _), columnCount - deletedColumns.count(columnCount >= _))
data.indices.filterNot(deletedRows contains _ + 1).zipWithIndex.foreach { case (row, i) =>
@Caellian
Caellian / Transpose 2D Array.kt
Last active September 5, 2018 04:20
Kotlin code bits.
inline fun <reified T> Array<Array<T>>.transpose(): Array<Array<T>> {
return Array(this[0].size) { i -> Array (this.size) { j -> this[j][i]} }
}
@Caellian
Caellian / ModExample.java
Last active August 23, 2018 21:51
Minecraft electricity example using FlowAPI
/*
* MIT License
* Copyright 2018 Tin Svagelj (a.k.a. Caellian) <tin.svagelj.email@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
@Caellian
Caellian / core-dep-test.yml
Last active August 14, 2018 12:15
Tests for ArchInstaller.
hr.caellian:kboardfix:
name: kBoardFix
description: Small fix script for keyboard layout.
script:
pre-mount: fix/fixKeyboard.py
org.x:xorg:
name: Xorg
description: The X.Org project provides an open source implementation of the X Window System.
website: https://www.x.org/wiki/
@Caellian
Caellian / instantlyEvaluateThis.java
Created August 4, 2018 13:56
Collection of most terrible pieces of code I stumbled upon.
// This class would be understandable if the #call() method wasn't instantly called by the only method actually using it...
public interface ICrashReportDetail<V> extends Callable<V> {}
@Caellian
Caellian / backup.sh
Created August 3, 2018 04:41
Backup & Restore scripts - arch, partclone, zstd
if [ "$EUID" -ne 0 ]
then
echo -e "\033[0;33mWARNING:\033[0m This script requires root privileges!"
fi
if [ $# -ne 2 ]
then
echo -e "\033[0;31mERROR:\033[0m Image name and/or drive not given in arguments!"
echo "Usage:"
echo -e "\t\033[1;31mbackup <image name> <drive>\033[0m"
@Caellian
Caellian / caspian.css
Created July 14, 2018 16:05 — forked from tmazeika/caspian.css
JavaFX default Caspian style sheet.
/*
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*