Blog

4 days, 5 hours 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
10 months, 2 weeks 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
10 months, 3 weeks 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, 3 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, 3 months ago 0
Posted in: Programování
php -d memory_limit=2048M /usr/local/bin/composer require ....
2 years, 3 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, 5 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);
4 years, 9 months 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;
4 years, 9 months 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;
}
5 years, 9 months ago 0
Posted in: Internet

It is not comfortable to select all drops one by one in the web interface of My CloudApp (cl.ly). If you need to, paste in address bar following snippet and press enter. All drops get selected and you can use the Delete selected button.

javascript:jQuery(".select input").trigger("click");