Skip to content

Instantly share code, notes, and snippets.

View kreamweb's full-sized avatar

Emanuela Antonina Castorina kreamweb

  • Kream di Emanuela Castorina
  • Acicatena (CT) - Italy
View GitHub Profile
@kreamweb
kreamweb / gist:870494
Created March 15, 2011 09:26
clonare un branch
mkdir $BRANCH
cd $BRANCH
git init
git remote add -t $BRANCH -f origin $REMOTE_REPO
git checkout $BRANCH
oppure
mkdir newrepo.git
cd newrepo.git
git init
@kreamweb
kreamweb / format_date_IT.js
Created December 19, 2011 11:10
Function to format javascript date like php date function
Date.prototype.format = function(format) {
var returnStr = '';
var replace = Date.replaceChars;
for (var i = 0; i < format.length; i++) { var curChar = format.charAt(i); if (i - 1 >= 0 && format.charAt(i - 1) == "\\") {
returnStr += curChar;
}
else if (replace[curChar]) {
returnStr += replace[curChar].call(this);
} else if (curChar != "\\"){
returnStr += curChar;
@kreamweb
kreamweb / format_date_IT.js
Created December 19, 2011 11:10
Function to format javascript date like php date function
Date.prototype.format = function(format) {
var returnStr = '';
var replace = Date.replaceChars;
for (var i = 0; i < format.length; i++) { var curChar = format.charAt(i); if (i - 1 >= 0 && format.charAt(i - 1) == "\\") {
returnStr += curChar;
}
else if (replace[curChar]) {
returnStr += replace[curChar].call(this);
} else if (curChar != "\\"){
returnStr += curChar;
@kreamweb
kreamweb / csvtoarray.php
Created May 14, 2012 13:21
csv to array
<?php
function csv2array($content, $delim = ';', $encl = '"', $optional = 1) {
if ($content[strlen($content)-1]!="\r" && $content[strlen($content)-1]!="\n")
$content .= "\r\n";
$reg = '/(('.$encl.')'.($optional?'?(?(2)':'(').'[^'.$encl.']*'.$encl.'|[^'.$delim.'\r\n]*))('.$delim.'|\r\n)/smi';
preg_match_all($reg, $content, $treffer);
$linecount = 0;
@kreamweb
kreamweb / wp_remove_gallery_css.php
Last active December 11, 2015 19:18
Filter to remove style from wordpress gallery shortcode
@kreamweb
kreamweb / gist:4649350
Created January 27, 2013 17:37
[wordpress] [filter] Add new Contact Fields to the User Profile
<?php
/*-----------------------------------------------------------------------------------*/
/* New Contacts Fiels
/*-----------------------------------------------------------------------------------*/
function new_contactmethods( $contactmethods ) {
$contactmethods['photo'] = 'Photo Link';
$contactmethods['position'] = 'Position';
$contactmethods['twitter'] = 'Twitter'; // Add Twitter
@kreamweb
kreamweb / complete_dynamic_menu
Last active December 12, 2015 08:38
[Wordpress] Display a list of pages from with all subchilds. A complete dynamic menu
<?php
$a=get_post_ancestors($post->ID,'page');
if(empty($a)){
//I'm in the root page
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
$title=$post->post_title;
$id=$post->ID;
}else{
//I'm in a sub page
$last=array_pop($a);
@kreamweb
kreamweb / apply_filter
Created February 22, 2013 06:07
[Wordpress] - How use a filter in wordpress, in this case add a custom content before the content of post
<?php
function theme_slug_filter_the_content( $content ) {
$custom_content = 'YOUR CONTENT GOES HERE';
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'theme_slug_filter_the_content' );
?>
@kreamweb
kreamweb / form search
Created November 22, 2013 18:24
Wordpress search form + Clear text Field
@kreamweb
kreamweb / gist:7605112
Last active December 29, 2015 03:08
twitter cycle
jQuery('document').ready(function(){
jQuery('#twitter_update_list').cycle({
fx: 'scrollHorz',
timeout: 5000,
prev: '#prev',
next: '#next',
easing: 'easeInOutBack',
cleartypeNoBg: true
});