Skip to content

Instantly share code, notes, and snippets.

View kreativan's full-sized avatar

Ivan Milincic kreativan

View GitHub Profile
@kreativan
kreativan / php_calendar.php
Created January 27, 2018 14:00
PHP Calendar Table
<?php
/* draws a calendar */
function renderCalendar($timestamp){
$month = date("m", $timestamp);
$year = date("Y", $timestamp);
/* draw table */
$calendar = '<table cellpadding="0" cellspacing="0" class="calendar">';
@kreativan
kreativan / Mustache.js
Created January 27, 2018 14:20
jQuery Mustache.js
/**
* Basic Template
*/
var person = {
firstName: "Ivan",
lastName: "Milincic",
blogURL: "http://kreativan.net"
};
var template = "<h1>{{firstName}} {{lastName}}</h1>Website: {{blogURL}}";
var html = Mustache.to_html(template, person);
@kreativan
kreativan / spintax.php
Created November 3, 2018 17:03
PHP: Text Spinner Class - Nested spinning supported.
<?PHP
/**
* Spintax - A helper class to process Spintax strings.
* @name Spintax
* @author Jason Davis
*
*/
class Spintax
{
public function process($text)
<?php
function getUserIP() {
// Get real visitor IP behind CloudFlare network
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
$_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
<?php
/*
* REST Helper.
*
* Copyright (c) 2014 Camilo Castro <camilo@cervezapps.cl>
*
* Some portions of code are based on the Lime Project
* https://github.com/aheinze/Lime/
* Copyright (c) 2014 Artur Heinze
*
@kreativan
kreativan / animate-numbers.js
Last active August 22, 2019 16:37
Animate numbers, when they enter viewport using uikit scrollspy componenet
function animateNumbers() {
var elements = document.querySelectorAll(".tm-animate-number");
elements.forEach(e => {
let current = 0;
let end = e.getAttribute("data-number");
let end_2 = (end > 200) ? end - 50 : end;
let increase_by = (end > 200) ? 23 : 1;
/**
* Gradient color mixin
* Works great with text & icons fonts
*/
.gradient-color-mixin(@color, @color-2, @deg: 90deg) {
color: transparent;
background-image: -webkit-linear-gradient(@deg, @color-2 0%, @color 100%);
background-image: -moz-linear-gradient(@deg, @color-2 0%, @color 100%);
background-image: linear-gradient(@deg, @color-2 0%, @color 100%);
-webkit-background-clip: text;
@kreativan
kreativan / fs-video.html
Created August 26, 2019 10:46
Open video on click in fullscreen, trigger event on fullscreen exit/change
<script>
/**
* @param {string} id video element css ID
*
*/
function openFullscreen(id) {
event.preventDefault();
elem = document.getElementById(id);
@kreativan
kreativan / repeater.js
Last active June 13, 2020 19:51
JavaScript Repeater. Dynamically add input fields... optimized for uikit. To init, add click event listener to the `add` button, specify container 'id='lngs'' element and array of fields... You just need html container and add button: ```
function createInput(name, placeholder = "") {
let input = document.createElement("INPUT");
input.setAttribute("type", "text");
input.setAttribute("name", name);
input.setAttribute("placeholder", placeholder)
input.classList.add("uk-input");
return input;
@kreativan
kreativan / uikit-gallery.html
Last active August 4, 2020 16:22
Crreate gallery using uikit lightbox.