16 декабря 2019 Нет комментариев

Просмотр всех установленных сертификатов:

certbot certificates

Удаление:

certbot delete --cert-name site.ru
Categories: Unix Tags:
15 октября 2019 Нет комментариев

Когда нужно совместить Chosen (https://harvesthq.github.io/chosen/) и Autocomplete Widget (https://api.jqueryui.com/autocomplete/), например, при очень большом списке.

$("select.chosen").chosen({width:"100%"});
$('.accessories .search-field input').each(function(i,el){
	el=$(el);
	el.autocomplete({
		minLength:3,
		delay:2000,
		source:function(request,response){
			var select=el.closest('.accessories').find('select');
			$.ajax({
				url:"/?sc="+request.term,
				dataType:"json",
				success:function(data){
					select.find('option').not(':selected').remove();
					response($.map(data,function(item){
						if(!(select.find('option[value='+item.id+']').length>0)){
							select.append('<option value="'+item.id+'">'+item.name+' ['+item.part+']</option>');
						}
					}));
					select.trigger("chosen:updated");
				}
			});
		},
	});
});

Пример php для ajax:

if(isset($_GET['sc'])){
	header("Content-Type: application/json");
	$result=get_from_base('`id`,`part`,`name`','catalog',"`part` LIKE '%".$_GET['sc']."%'",'`parent`,`pos`');
	echo json_encode($result);
	exit();
}

Сам select:

<div class="accessories">
	<select name="accessories[]" multiple="multiple" class="chosen" data-placeholder="Выбрать позиции">
		<?if(count($catalog_accessories)>0){?>
			<?foreach($catalog_accessories as $v){?>
				<option value="<?=$v['id']?>"<?if(in_array($v['id'],$change_catalog_accessories)){?> selected="selected"<?}?>><?=$v['name']?> [<?=$v['part']?>]</option>
			<?}?>
		<?}?>
	</select>
</div>

Другие данные:

$change_catalog_accessories=array();
$change_catalog=get_by_id($_GET["uid"],'catalog');
if($change_catalog['accessories']!=''){
	$change_catalog_accessories=explode(',',str_replace("'","",$change_catalog['accessories']));
	$catalog_accessories=get_from_base('`id`,`name`,`part`','catalog',"`shown`=1 and `id`!='".$change_catalog['id']."' and `id` in (".$change_catalog['accessories'].")",'`parent`,`pos`');
}
Categories: Javascript Tags:
7 октября 2019 Нет комментариев
function simplexml_load_file_from_url($url,$timeout=60){
	$opts=array('http'=>array('timeout'=>(int)$timeout));
	$context=stream_context_create($opts);
	$data=file_get_contents($url,false,$context);
	if(!$data){
		return false;
	}
	return simplexml_load_string($data);
}

использовать вместо simplexml_load_file

Categories: PHP Tags:
27 сентября 2019 Нет комментариев
rm -f *

Но, если файлов больше, чем

getconf ARG_MAX

и видим ошибку Argument list too long, то удалять циклом:

for f in ./*; do rm -f "$f"; done

или find, что более быстро:

find . -delete
Categories: Unix Tags:
20 сентября 2019 Нет комментариев
n=parseFloat(n.toFixed(1));
Categories: Javascript Tags:
9 сентября 2019 Нет комментариев

Добавить в nginx.conf в блок http

fastcgi_buffering off;
proxy_buffering off;
Categories: Unix Tags:
5 сентября 2019 Нет комментариев

Создать:

tar -cvzf archive.tar.gz ./dir/

Распаковать:

tar -xvzf archive.tar.gz
Categories: Unix Tags: