Skip to content

Instantly share code, notes, and snippets.

View varemenos's full-sized avatar

Adonis Kakoulidis varemenos

View GitHub Profile
@varemenos
varemenos / currentLink.js
Created January 28, 2012 02:21
jQuery - find current page
@varemenos
varemenos / widgetHeight.js
Created January 28, 2012 02:23
jQuery - calculate max widget height
function maxHeight(selected){
var current = 0, max = 0;
$(selected).each(function(){
current = $(this).height();
max = Math.max(current, max);
});
$(selected).height(max);
}
@varemenos
varemenos / url_params.js
Created February 20, 2012 08:38
jQuery - get url parameters
window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
@varemenos
varemenos / optparam.js
Created February 27, 2012 03:53
jQuery - Optional parameters and typeof variable
x('4');
function x(i){
if(typeof i === 'undefined'){
console.log('i : undefined');
}else{
console.log('i : ' + i);
console.log('typeof ' + typeof i);
}
}
@varemenos
varemenos / back2top.js
Created March 1, 2012 19:11
jQuery - Back to Top
function resetFunction(){
$('html, body').animate({scrollTop:0}, 1500, 'easeOutQuint');
}
@varemenos
varemenos / opening_fade.js
Created March 1, 2012 19:14
jQuery - Opening fade
$(document).ready(function () {
$('#plane').hide().delay(500).fadeIn(1000);
});
@varemenos
varemenos / exec_time.php
Created March 11, 2012 03:30
PHP - Exec time calculation
<?
// start{
// exec time
$start_time = (float) array_sum(explode(' ', microtime()));
// }
// config file {
// developer mode on/off
define('DEV_MODE', true);
@varemenos
varemenos / title2excerpt.php
Created March 16, 2012 04:20
PHP - Title to Excerpt Convertion
<?php
// sample title
$title = "the, *t.ru/e ;h'or']ror} (2)3!@ # $ % ^ & (* )^ ) _+-0(*)*%(&!^";
// find and replace any whitespace characters with underscores
$excerpt = preg_replace('/\s/', '_', $title);
// find an replace any none alphanumeric or underscore characters with any empty string ''
$excerpt = preg_replace('/[^a-zA-Z0-9_]/', '', $excerpt);
// while there is a '__' string inside the string, keep replacing the '__' with '_'
while (strpos($excerpt, '__') !== false){
@varemenos
varemenos / sample_object.php
Created March 16, 2012 06:42
PHP - Sample Object
<?php
// CONTINUE:
// CLASSES & OBJECTS - http://php.net/manual/en/language.oop5.php
// BASICS (TUTORIAL) - http://www.php.net/manual/en/language.oop5.basic.php
// CONSTRUCTORS - http://www.php.net/manual/en/language.oop5.decon.php
// new class
class Foo{
// constructor
@varemenos
varemenos / list_function.php
Created March 17, 2012 15:39
PHP - List Function
<?php
$temp = array('one', 'two', 'three', 'four');
list($one, $two, $three, $four) = $temp;
var_dump($temp);
var_dump($one, $two, $three, $four);
// RESULTS
/*