Blog Archives

1 month, 3 weeks ago 0
Posted in: Programování
export FIREBIRD_HOME=/Library/Frameworks/Firebird.framework/Resources
export PATH=$PATH:$FIREBIRD_HOME/bin
sudo gbak -c -v -user SYSDBA -password masterkey file.fbk file.fdb
3 months, 1 week ago 0
Posted in: Programování
mysql -uroot -proot -e 'show databases' | while read dbname; do mysqldump -uroot -proot --complete-insert "$dbname" > "$dbname".sql; done
TIMESTAMP=$(date +"%F")
BACKUP_DIR="/path-to-backup-dir/"
MYSQL_USER="root"
MYSQL=mysql
MYSQL_PASSWORD="root"
MYSQLDUMP=mysqldump
 
mkdir -p "$BACKUP_DIR/mysql"
 
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"`
 
for db in $databases; do
  $MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/mysql/$db.gz"
done
1 year, 1 month ago 0
Posted in: Programování
bin/console doctrine:mapping:import "AppBundle" yml --filter=JmenoTabulky
bin/console doctrine:mapping:convert annotation ./src/AppBundle/Entity --from-database --filter="JmenoTabulky"
bin/console doctrine:generate:entities AppBundle:JmenoTabulky --no-backup
1 year, 1 month ago 0
Posted in: Programování
function clean_uploads_from_nonattachments(){
	$uploads_dir = wp_upload_dir(); 
	$search = $uploads_dir['basedir'];
	$replace = $uploads_dir['baseurl'];

	$uploads_dir = ( $uploads_dir['basedir']); 
	$root = $uploads_dir;

	$iter = new RecursiveIteratorIterator(
		new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS),
		RecursiveIteratorIterator::SELF_FIRST,
		RecursiveIteratorIterator::CATCH_GET_CHILD 
	);
	foreach ($iter as $fileinfo) {
		if ($fileinfo->isFile()) {	
			$image = $fileinfo->getPathname();
			$image_url = str_replace($search, $replace, $image);
			$attachment_id = attachment_url_to_postid($image_url);
				//Not found - then delete file 
				if (!$attachment_id){
					unlink($image);	
				}
				else {
					echo $attachment_id.': '.$image; 			   
				}	
		}
	}			
}
2 years, 6 months ago 0
Posted in: Programování
add_filter( 'wpseo_metabox_prio', 'jw_filter_yoast_seo_metabox' );
function jw_filter_yoast_seo_metabox() {
	return 'low';
}
2 years, 6 months ago 0
Posted in: Programování
php -d memory_limit=2048M /usr/local/bin/composer require ....
2 years, 6 months ago 0
Posted in: Programování
# based on http://www.commandlinefu.com/commands/view/2916/backup-all-mysql-databases-to-individual-files
# but modified for the MAMP path and to include default root/root as username and password

for I in $(/Applications/MAMP/Library/bin/mysql -u root -proot -e 'show databases' -s --skip-column-names); do /Applications/MAMP/Library/bin/mysqldump -u root -proot $I | gzip > "$I.sql.gz"; done

Source: https://gist.github.com/salcode/9142815

2 years, 8 months ago 0
Posted in: WordPress

 

// $loc obsahuje správné locale (cs_CZ, ...) - záleží na pojmenování lokalizačních souborů
$filename = realpath(dirname(__FILE__) . '/../..') . '/languages/plugins/woocommerce-' . $loc . '.mo';
unload_textdomain('woocommerce' );
load_plugin_textdomain('woocommerce', false, $filename);
5 years ago 0
Posted in: Programování
$page_id = !empty($params['page_id']) ? $params['page_id'] : null;
 $assign = !empty($params['assign']) ? $params['assign'] : null;
 
 if (!empty($page_id)) {
  $contentOps = cmsms()->getContentOperations();
  $templateOps = cmsms()->getTemplateOperations();
 if (!empty($contentOps) && !empty($templateOps)) {
   $content = $contentOps->LoadContentFromId($page_id);
      if (!empty($content)) {
    $templateID = $content->templateId();
    if (!empty($templateID)) {
     $template = $templateOps->LoadTemplateByID($templateID);
     if (!empty($template)) {
      if (!empty($assign)) $smarty->assign($assign, $template->name);
      else return $template->name;
     }
    } 
   }
  }
 }
 
 return false;
5 years ago 0
Posted in: Programování
function current_url() {
   $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"];
   }
   return $pageURL;
}

function create_url($other_qs_parsed = array()) {
  $url = current_url();
  $url_parsed = parse_url($url);
  $new_qs_parsed = array();
  
  parse_str($url_parsed['query'], $new_qs_parsed);

  $final_query_string_array = array_merge($new_qs_parsed, $other_qs_parsed);
  $final_query_string = http_build_query($final_query_string_array);

  $new_url = $url_parsed['scheme'] 
           . '://'
           . $url_parsed['host'] 
           . $url_parsed['path'] 
           . '?'      
           . $final_query_string;
  return $new_url;
}