Skip to content

Instantly share code, notes, and snippets.

View gustinmi's full-sized avatar

Mitja Guštin gustinmi

View GitHub Profile
@gustinmi
gustinmi / jsmicrotmpl.js
Created November 23, 2014 18:59
JavaScript Templating Framework Easy 1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>templator</title>
<style type="text/css">
#content {
padding: 5px;
@gustinmi
gustinmi / storage.js
Last active December 13, 2015 17:08
Shorten your boilerplate JavaScript code
//Boiler plate code is usually consisted of simple patterns. Once you master them, there is no need for readability. It should be as compact as possible, to preserve space for the real implementation code. For example:
// adding interface "storage" to namespace "AppHtml5"
if (window.AppHtml5)
window.AppHtml5.storage = { "save" : {}, "load" : {}};
else {
window.AppHtml5 = {};
window.AppHtml5.storage = {};
window.AppHtml5.storage = { "save" : {}, "load" : {}};
@gustinmi
gustinmi / tests.html
Created February 13, 2013 16:15
Simple JavaScript UnitTester.No frameworks. Very simple
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Tests </title>
<style type="text/css">
div.results b {
color: green;
}
div.results b[class='err'] {
@gustinmi
gustinmi / logger.js
Created February 13, 2013 16:41
Simple JavaScript logging framework.
/**
* Simple logging framwork
* Supports Chrome or Firefox
* Usage:
*
* AppHtml5.log.info('Dropdown value changed to something new!');
*
*/
//create logging functions
@gustinmi
gustinmi / gist:4952465
Last active December 13, 2015 17:59
jQuery Tables plugin. Below is the code that triggers the update ajax source via your own custom event handler, possibly passing http paramaters.
//This is the extension function for table plugin (My params are array of key value pairs). Make this script available to your //web page which is utilizing the table plugin
$.fn.dataTableExt.oApi.fnReloadAjax = function (oSettings, sNewSource, myParams ) {
if ( oSettings.oFeatures.bServerSide ) {
oSettings.aoServerParams = [];
oSettings.aoServerParams.push({"sName": "user",
"fn": function (aoData) {
for (var i=0;i<myParams.length;i++){
aoData.push( {"name" : myParams[i][0], "value" : myParams[i][1]});
@gustinmi
gustinmi / timeline.html
Created February 15, 2013 13:02
Creating simple mobile-style page navigation, where pages slide-in.
<!DOCTYPE html>
<html>
<head>
<title>Creating simple page navigator with remote pages</title>
<style type="text/css">
div.viewport {
position: relative;
border-collapse: collapse;
width: 800px;
height: 200px;
@gustinmi
gustinmi / html5template.html
Created April 16, 2013 10:35
HTML5 View Template Features: responsive layout, header, footer, content. Footer is always at bottom. Content occupies all available and remaining viewport. Preview: https://googledrive.com/host/0B-KXuLdFNBwiWG5TYzBmUjRzeVk/html5template.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>HTML5Template</title>
<style type="text/css">
html, body { height: 100%; width: 100%; } /* occupy whole viewport. */
body,div,p {
/* css reset techique; We are resetting the UserAgent (browser) style */
var myStyle = function getStyle(className_) {
var styleSheets = window.document.styleSheets;
var styleSheetsLength = styleSheets.length;
for(var i = 0; i < styleSheetsLength; i++){
var classes = styleSheets[i].rules || styleSheets[i].cssRules;
if (!classes)
continue;
var classesLength = classes.length;
for (var x = 0; x < classesLength; x++) {
@gustinmi
gustinmi / storage.js
Last active November 3, 2017 11:08
Simple JavaScript storage (webstorage or cookie based)
/**
*
* Component for utilizing local storage. It provides backup plan, if no WebStorage is available on client
*
*We support html5 storage, and cookie store if webStorage is not available.
*
*Cookies
* Are for older browsers only. A "session" cookie (one without expiration data) is available in all windows
* that have access to that domain until the browser is shut down. This is bad.
* 4096 chars limit
@gustinmi
gustinmi / HttpClient.java
Last active August 21, 2019 08:55
Java Http client simple
package http;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import moped.common.Utils;