Skip to content

Instantly share code, notes, and snippets.

View varemenos's full-sized avatar

Adonis Kakoulidis varemenos

View GitHub Profile
@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 / opening_fade.js
Created March 1, 2012 19:14
jQuery - Opening fade
$(document).ready(function () {
$('#plane').hide().delay(500).fadeIn(1000);
});
@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 / 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
/*
@varemenos
varemenos / array_map.php
Created March 17, 2012 15:57
PHP - Array Map Function
<?php
$a = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$new_a = array_map('square', $a);
var_dump($a, $new_a);
function square($temp){
return ($temp * $temp);
}
@varemenos
varemenos / stack.php
Created March 17, 2012 16:05
PHP - Array as Stack
<?php
$a = array();
for ($i=0; $i < 3; $i++) {
array_push($a, $i);
var_dump($a);
}
for ($i=0; $i < 3; $i++) {
array_pop($a);