Skip to content

Instantly share code, notes, and snippets.

View n1chre's full-sized avatar
💯

Filip Hrenić n1chre

💯
View GitHub Profile
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Replacer {
public static void main(String[] args) {
Replacer replacer = new Replacer();
@n1chre
n1chre / .htaccess
Created May 1, 2017 17:04 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@n1chre
n1chre / binary_palindrome.c
Last active April 19, 2017 19:22
Check if a number is its own binary palindrome
int is_binary_palindrome(int x){
int b = 0, _x = x;
while (_x) {
b <<= 1;
b |= _x&1;
_x >>= 1;
}
return x==b;
}
@n1chre
n1chre / rbtree.erl
Last active March 30, 2017 07:45
Implementation of a red black tree in Erlang, guided by Sedgewick's paper
%%%-------------------------------------------------------------------
%%% @author fhrenic
%%% @copyright (C) 2017, FER
%%% @doc
%%%
%%% @end
%%% Created : 27. Mar 2017 00:01
%%%-------------------------------------------------------------------
-module(rbtree).
-author("fhrenic").
@n1chre
n1chre / fer-mail.conf
Created March 12, 2017 14:23
Scripts for sending emails to FER students
[user]
username: fhxxxxx@fer.hr
password: **********
[smtp]
server: smtp.office365.com
port: 587
tls: true
@n1chre
n1chre / UnionFind.java
Created January 31, 2017 18:20
Union find with path compression and weighted union
package hruntek;
/**
* Union find with path compression and weighted union
* O(log*N) operations
*/
class UnionFind {
/**
* Node's id
@n1chre
n1chre / iTerm2 Here.applescript
Last active May 26, 2022 13:23 — forked from jonschlinkert/open-iterm-from-finder.md
Add an icon to your finder toolbar to open iTerm2 in the current folder.
(*
Open Terminal Here
Written by Brian Schlining
source: http://hohonuuli.blogspot.hr/2016/02/iterm2-version-3-open-iterm-here-script.html
*)
property debug : false
-- when the toolbar script icon is clicked
--
@n1chre
n1chre / diglog-task.php
Last active January 8, 2017 23:16
Assignment for lab exercise, students had to solve it
<?php
function _die($msg)
{
echo "<html><body><h1>$msg</h1><a href='/'>Početna stranica</a></body></html>";
die;
}
if (!isset($_SERVER['REQUEST_METHOD'])) {
_die('Nece ici');
@n1chre
n1chre / Parallel.java
Last active January 8, 2017 16:46
Running of parallel tasks that can be terminated if an acceptable value is produced.
package parallel;
import java.util.Collection;
import java.util.Observable;
import java.util.Observer;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
/**
* This class is used to execute tasks in parallel.
@n1chre
n1chre / provision.sh
Created January 7, 2017 15:20
Vagrant provision script: set up Derby database and Tomcat server
#! /usr/bin/env bash
APPNAME=
# tomcat conf
TADM_USER=admin
TADM_PASS=admin
# derby conf
DERBY_DB=/home/vagrant/database