Skip to content

Instantly share code, notes, and snippets.

View trajakovic's full-sized avatar

Tomislav trajakovic

  • Score Alarm
  • Zagreb
View GitHub Profile
@trajakovic
trajakovic / docker_1.13_manual_install_centos.sh
Created March 28, 2017 09:07
Docker 1.13 manual installation on CentOS7 for Openshfit Origin 1.5.0.rc0 (since latest docker version is 17.03, oc cluster up is not happy with version)
yum install wget
wget https://yum.dockerproject.org/repo/main/centos/7/Packages/docker-engine-1.13.1-1.el7.centos.x86_64.rpm
wget https://yum.dockerproject.org/repo/main/centos/7/Packages/docker-engine-selinux-1.13.1-1.el7.centos.noarch.rpm
#nice site with pckgs: https://pkgs.org/
#package for docker-engine-selinux
yum install -y policycoreutils-python
rpm -i docker-engine-selinux-1.13.1-1.el7.centos.noarch.rpm
@trajakovic
trajakovic / openssl_split_one_pem_to_multiple.sh
Created October 23, 2013 11:36
Split SSL PEM multiple certificates into files
wget -O - http://curl.haxx.se/ca/cacert.pem | awk 'split_after==1{n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1} {print > "cert" n ".pem"}'
@trajakovic
trajakovic / Android TimeExpiringLruCache.java
Created March 31, 2013 19:48
I've took original Android's LruCache, and implemented time expiration parameter, so when you call next time "get", and value is timed-out, you'll get null (and old entry will be removed from cache).
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import android.os.SystemClock;
public class TimeExpiringLruCache<K, V> {
private final LinkedHashMap<K, V> map;
private final HashMap<K, Long> validityTime;
@trajakovic
trajakovic / Rx.Observable.cacheWithExpiration-demo.js
Last active March 22, 2021 04:23
RxJs extension implementation for cache results with time expiration
var slowJob = Rx.Observable.defer(function () {
return Rx.Observable.return(Math.random() * 1000).delay(2000);
});
var cached = slowJob.cacheWithExpiration(5000);
var last = Date.now();
function repeat() {
last = Date.now();
cached.subscribe(function (data) {
@trajakovic
trajakovic / sysctl-conf.sh
Last active March 20, 2019 10:08
High performance sysctl.conf
#!/bin/bash
#check if this script is running in su mode
func_check_for_root() {
if [ ! $( id -u ) -eq 0 ]; then
echo "ERROR: $0 Must be run as root, Script terminating" ;exit 7
fi
}
func_check_for_root
@trajakovic
trajakovic / fedora-install-nodejs.sh
Last active February 16, 2019 16:55
Install node.js on fedora (23+).(v5.10.1)
#!/usr/bin/env bash
func_check_for_root() {
if [ ! $( id -u ) -eq 0 ]; then
echo "ERROR: $0 Must be run as root, Script terminating" ;exit 7
fi
}
func_check_for_root
#SETUP PARAMS
@trajakovic
trajakovic / BootstrapFormHelper.php
Last active December 16, 2018 18:18
This file is taken from https://github.com/CCadere/CakePHP-Forms-Bootstrap-2.3-Helper/blob/master/View/Helper/BootstrapFormHelper.php, and slightly modified/extended. Added support for has-error bs3 validation error class.
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
*
* Licensed under The MIT License
*
* Copyright (c) La Pâtisserie, Inc. (http://patisserie.keensoftware.com/)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('FormHelper', 'View/Helper');
@trajakovic
trajakovic / compile-elixir-v1.6.3.sh
Last active March 10, 2018 18:33
Compile and install Erlang 20.2 from source on Ubuntu 16.04 (Xenial Xerus or Linux Mint Sylvia 18.3). Compile and install Elixir 1.6.3 on Ubuntu 16.04
# requirement: erlang, git
ELIXIR_VERSION="1.6.3"
sudo apt-get update && sudo apt-get install -y git && \
rm -rf /tmp/code/elixir/${ELIXIR_VERSION} && mkdir -p /tmp/code/elixir/${ELIXIR_VERSION} && cd /tmp/code/elixir/${ELIXIR_VERSION} && \
git clone -b "v${ELIXIR_VERSION}" --single-branch --depth 1 https://github.com/elixir-lang/elixir.git . && \
make clean test && \
sudo make install && \
cd && rm -rf /tmp/code/elixir && \
echo "Check your elixir version by typing 'iex --version'"
@trajakovic
trajakovic / react-native-clear-all.sh
Last active March 2, 2018 10:32 — forked from EQuimper/clear.txt
React-Native clear Watchman + Cache + Temp
rm /tmp/haste-* /tmp/flow /tmp/metro-* /tmp/socketcluster/ -rf && watchman watch-del-all
yarn start -- --reset-cache
@trajakovic
trajakovic / generate_files.sh
Created April 20, 2017 06:48
Generate binary files with random content...and calculate their sha256
#!/bin/bash
#size magnitude
sizes=( "" "K" "M" )
for magnitude in "${sizes[@]}"; do
for size in `seq 1 5 51`; do
echo "Generating ${size}${magnitude}"
head -c ${size}${magnitude} </dev/urandom >file-${size}${magnitude}.bin