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 / 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 / gist:6281772
Last active December 21, 2015 08:59
AppFrog - demo1
{
"msg" : "This is gist connection test"
}
@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 / tar_folder.sh
Created October 23, 2013 11:47
Tar combinations
-z: Compress archive using gzip program
-c: Create archive
-v: Verbose i.e display progress while creating archive
-f: Archive File name
(this creates archive)
tar -zcvf archive_name.tar.gz /home/tom/and/jerry/
@trajakovic
trajakovic / default-mapping.json
Last active December 28, 2015 18:38
ElasticSearch JSON mapping configuration (place in $ELASTICSEARCH\conf\default-mapping.json)
{
"_default_": {
"properties": {
"my_hash_field": {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
@trajakovic
trajakovic / package.json
Last active December 28, 2015 18:39
NodeJs simple static HTTP server. Usage: * Fetch package.json and server.js (same folder) * static content should be placed in public/ folder * run: npm install && npm start
{
"name": "kibana-server",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "3.4.4"
}
@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 / conf-cc.patch
Created July 14, 2014 12:12
Daemontools conf-cc patch for CentOs build
--- conf-cc.old 2014-07-14 12:06:58.270692758 +0000
+++ conf-cc 2014-07-14 12:07:14.837994394 +0000
@@ -1,3 +1,3 @@
-gcc -O2 -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings
+gcc -O2 -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings -include /usr/include/errno.h
This will be used to compile .c files.
@trajakovic
trajakovic / centos-daemontools-install.sh
Last active August 29, 2015 14:03
Install daemontools on CentOS
#!/bin/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
yum install patch -y
@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