Skip to content

Instantly share code, notes, and snippets.

@najlepsiwebdesigner
najlepsiwebdesigner / html5-canvas-image-effects.js
Last active December 11, 2015 11:58
My project from subject Visual systems at Faculty of electrical engineering of Slovak technical university in Bratislava. http://www.fei.stuba.sk/english http://effects.peterbeno.com
// creates basic object structure, wraps routines together - can be compared to OOP class definition
var imageEffects = function () {}
imageEffects.prototype.loadImage = function (url, callback) {
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.onreadystatechange = function () {
// Makes sure the document is ready to parse.
var result = false;
if (request.readyState == 4) {
@najlepsiwebdesigner
najlepsiwebdesigner / String.prototype.insert.js
Last active December 13, 2015 19:58
javascript insert([index],[string]) method (String.prototype.insert)
// String insert method
String.prototype.insert = function (index, string) {
if (index > 0) {
// necessary fix
if (string.charCodeAt(0) == 13){
string = "\n";
}
var ret = this.substring(0, index) + string + this.substring(index, this.length);
return ret;
} else if (index == this.length) {
@najlepsiwebdesigner
najlepsiwebdesigner / foundation-datepicker-disabled.js
Last active October 9, 2018 14:18
Implementation of disabled elements for foundation datepicker project https://github.com/najlepsiwebdesigner/foundation-datepicker/
// implementation of disabled form fields
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
var checkin = $('#dpd1').fdatepicker({
onRender: function (date) {
return date.valueOf() < now.valueOf() ? 'disabled' : '';
}
}).on('changeDate', function (ev) {
if (ev.date.valueOf() > checkout.date.valueOf()) {
var newDate = new Date(ev.date)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HTML5 boilerplate – all you really need…</title>
<link rel="stylesheet" href="css/style.css">
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
@najlepsiwebdesigner
najlepsiwebdesigner / jquery.plugin.blank.template.js
Created February 19, 2013 10:36
great blank jquery plugin template!
/*!
* jQuery lightweight plugin boilerplate
* Original author: @ajpiano
* Further changes, comments: @addyosmani
* Licensed under the MIT license
*/
// the semi-colon before the function invocation is a safety
// net against concatenated scripts and/or other plugins
@najlepsiwebdesigner
najlepsiwebdesigner / curPageURL.php
Last active December 13, 2015 22:39
current page url in PHP scripts, only parts after hash sign are misssing
<?php
function curPageURL() {
$pageURL = "http";
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
...
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
<script>
// configuration structure
var config = {
pagenumber : 1,
activeclassname : 'active', // class used to mark active paging link
initialpage : 1,
sourceurl : '', // url to your data source
@najlepsiwebdesigner
najlepsiwebdesigner / bruteforce.html
Created February 24, 2013 13:08
Javascript bruteforce password attack
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bruteforce!</title>
</head>
<body>
<script>
var password = '89p8zk',
passwordLength = 4,
@najlepsiwebdesigner
najlepsiwebdesigner / validateSkId.js
Created April 18, 2013 14:53
Validates slovak ID identifiers
/*
* validates slovak ID numbers
*
* @param string skIdNumber slovak ID number
*
* @return bool
*/
function validateSkId (skIdNumber) {
if (skIdNumber == undefined ||
skIdNumber.length < 1 ||
/* return pluralized form of input type, with respect to amount
*
* @param string type - defines type, possible values are: "hodina", "kus", "mesiac"
* @return string pluralized type in slovak language
*/
function pluralizeAmountSlovak(type, amount){
var dictionary = {
hodina : ['hodina', 'hodiny','hodín'],
kus : ['kus', 'kusy', 'kusov'],
mesiac : ['mesiac', 'mesiace', 'mesiacov']