我可能错过了一些简单但我无法在本地测试Jekyll的方法.
我正在使用GitHub页面来渲染Jekyll,对于初学者我只想从一个降价页面在主index.html上渲染markdown内容 .
结构是:
的index.html
---
layout: default
---
Run Code Online (Sandbox Code Playgroud)
_layouts
- default.html
//html stuff..
<section>
{{page.content}}
</section>
Run Code Online (Sandbox Code Playgroud)
在根文件夹中,我有一个名为" content.md我希望为{{page.content}}布局渲染渲染" 的页面,但液体标签部分为空白.
我该如何渲染content.md?
我正在尝试检查Phing中是否存在目录或文件,但我甚至无法使用基础知识.
例如:
<project name="test" default="help" basedir="./">
<target name="clean" description="Deletes directory">
<available file="/testy" type="dir" property="dir.Exists" />
<if>
<isset property="dir.Exists"/>
<then>
<echo>Yep</echo>
</then>
</if>
</target>
<phingcall target="clean" />
</project>
Run Code Online (Sandbox Code Playgroud)
我得到一个奇怪的错误:
Error reading project file [wrapped: \build.xml:22:18: Error initializing nested
element <echo> [wrapped: phing.tasks.system.IfTask doesn't support the 'echo'
creator/adder.]]
Run Code Online (Sandbox Code Playgroud)
最终,如果目录存在,我想添加一个条件是/否来继续.
PS.该错误与"嵌套元素回声"无关,据我所知,因为如果我删除它仍然发送相同的错误,实际上我认为这是一个默认语法相关的错误消息或其他东西.
Exmple feed:view-source:http://rss.packetstormsecurity.org/files/tags/exploit/
我只想返回xml的部分,其中父标题节点中有匹配的文本,在这个例子中,要匹配的文本是"site".
//get feed with curl
$doc = new SimpleXmlElement($xml, LIBXML_NOCDATA);
//$result = $doc->xpath('//title'); //this works returns all the <title>'s
$result = $doc->xpath('//title[site]'); //doesn't work
$result = $doc->xpath('//title[text()="site"]'); //doesn't work
$result = $doc->xpath('//title[contains(site)]'); //doesn't work
$result = $doc->xpath('//title[contains(text(),'Site')]'); //doesn't work
foreach ($result as $title)
echo "$title<br />"
Run Code Online (Sandbox Code Playgroud) 我删除了旧帖子以使其更清晰.我有2个数组,我需要比较和匹配,但只有每个数组2个值相同.
$array1 = $plugins
$array2 = $xml_dump
两个数组的样本:
$plugins
Array
(
[all] => Array
(
[ajax-category-dropdown/dhat-ajax-cat-dropdown.php] => Array
(
[Name] => Ajax Category Dropdown
[PluginURI] => http://www.example.com/ajax/
[Version] => 0.1.5
[Description] => Generates multi-level ajax.
[Author] => DyasonHat
[AuthorURI] => http://www.dyasonhat.com
[Title] => Ajax Category Dropdown
[AuthorName] => Dya
)
[akismet/akismet.php] => Array
(
[Name] => Akismet
[PluginURI] => http://akismet.com/
[Version] => 2.5.3
[Description] => Used by millions
[Author] => Automattic
[AuthorURI] => http://automattic.com/
[Title] => Akismet
[AuthorName] => Automattic …Run Code Online (Sandbox Code Playgroud) 我试图找出如何做到这一点的逻辑.
我有很多只有CSS类名的图像,它们是动态创建的.
这些图像可以使用jQuery UI进行拖动 .draggable.
我需要一个"垃圾桶",当一个元素被拖入时,它被删除.
示例:http://jsfiddle.net/KWdcU/3/(设置为删除所有元素而不是拖入其中的元素)
代码:
<div class ="box">
<div class="stack">one</div>
<div class="stack">two</div>
</div>
<div id="trash">trash</div>?
$(function() {
$( ".stack" ).draggable();
});
$('#trash').droppable({
over: function() {
//alert('working!');
$('.box').remove();
}
});
Run Code Online (Sandbox Code Playgroud)
我已经尝试了几种方法来忽略RecursiveIteratorIterator文件系统上使用的某些目录.
为了举个例子,我想忽略以下目录:/cache.
我Iterator看起来像这样:
//$dirname is root
$directory = new RecursiveDirectoryIterator($dirname);
$mega = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST);
foreach ($mega as $fileinfo) {
echo $fileinfo;
}
Run Code Online (Sandbox Code Playgroud)
我已经能够忽略某些文件扩展名pathinfo,例如使用它:
$filetypes = array("jpg", "png");
$filetype = pathinfo($fileinfo, PATHINFO_EXTENSION);
foreach ($mega as $fileinfo) {
if (!in_array(strtolower($filetype), $filetypes)) {
echo $fileinfo;
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用PATHINFO_DIRNAME(使用数组中相应的目录路径)它不起作用,没有错误,它只是不忽略目录.
我也尝试使用FilterIterator无济于事,现在我想也许我应该使用RegexIterator.
忽略目录使用的最简单,最有效的方法是RecursiveIteratorIterator什么?
实验没有用.运用PATHINFO_DIRNAME
$dirignore = array("cache", "cache2");
$directory = new RecursiveDirectoryIterator($dirname);
$mega = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST);
$dirtype …Run Code Online (Sandbox Code Playgroud) 我知道Git集成是Netbeans 7.0是新的并且正在开发中,但有没有人在推送/拉动GitHub方面取得了成功?
当我单击Git-> Push时,远程存储库url会在步骤1配置存储库中正确显示.
但只是停留在"连接到存储库".它还弹出一个框,说"使用完全相同的URL指定Git存储库位置",单击"确定"不执行任何操作.
如果我选择"指定Git存储库位置",我最终会收到一个错误,"无法通过git@github.com连接到远程存储库:username/..."
PS.我知道其他类似的堆栈问题,但它们令人困惑,一个人提到他能够做到这一点,而其他人提到还不能使用远程Git连接.
简单的目录迭代器,它是递归的并显示所有文件和目录/子目录.
我没有看到任何内置的功能,以排除某些文件类型,例如在下面的例子中,我不希望输出的任何图像相关的文件,如.jpg,.png等我知道有这样做的几种方法,寻求建议哪个是最好的.
$scan_it = new RecursiveDirectoryIterator("/example_dir");
foreach(new RecursiveIteratorIterator($scan_it) as $file) {
echo $file;
}
Run Code Online (Sandbox Code Playgroud) 我以为我已经想到了这一点,但是最近的尝试却失败了.
我需要提交一个文件,然后提交后忽略它在任何后续的repo提交.
让我们说该文件是example.txt.
我将更改提交到example.txt并将它们推送到github.
然后我touch .gitignore将example.txt添加到它并保存.
然后我使用git rm --cached example.txt
Then git add .gitignore提交 - >推送它
此步骤的问题是git status显示example.txt已删除,因此commit/push将其从远程仓库中删除.
我已经尝试了几种创建.gitignore和的变体rm --cached,它要么删除了文件,要么不忽略它并提交不需要的更改.
寻找有关忽略已提交文件而不删除它们的确切过程的见解.
使用Google Map APi v3,有一些样式选项,例如:
{
featureType: 'transit.line',
elementType: 'geometry',
stylers: [
{ hue: '#fc0101' },
{ visibility: 'on' }
]
}
Run Code Online (Sandbox Code Playgroud)
这适用于地图加载,如API示例中所示:https://developers.google.com/maps/documentation/javascript/examples/maptype-styled-simple
我需要添加一个click事件来显示或更改某个样式,例如,如果我hue在dom事件上更改上面的代码值.
示例代码:
// a link to test map changes
var testDiv = document.getElementById("test");
// add click event listener for map
google.maps.event.addDomListener(testDiv, 'click', showTest);
// the function for setZoom works
function showTest() {
map.setZoom(2);
}
Run Code Online (Sandbox Code Playgroud)
我找不到任何设置样式的文档,没有"设置",https://developers.google.com/maps/documentation/javascript/reference#StyledMapType
有setOptions一个styles属性,但我不能让它工作.
一个不起作用的例子:
// turn off transit line visibility on click
function showTest() { …Run Code Online (Sandbox Code Playgroud) 尝试使用名为get_transient的wordpress函数构建来缓存xml文件,但是我收到了一个php错误:
unserialize()[function.unserialize]:节点不再存在
//check the db to see if it exists ( get_transient is a WordPress function)
if (false === ($response_xml = get_transient('stats_from_xml_feed'))){
$request_url = "http://example.com/feed.xml";
$request_url = urlencode($request_url);
$response_xml = @simplexml_load_file($request_url);
//kill request if connection problem
if ($response_xml === FALSE){
exit ('could not connect');
} else {
// here we throw it into the WordPress temp DB using set_transient for 12 hours
set_transient('stats_from_xml_feed', $response_xml, 60*60*12);
//some output
$res = $response_xml;
$name = $res->name;
echo $name;
}
Run Code Online (Sandbox Code Playgroud) 这看起来很简单,但我无法弄清楚.我需要为2个数组返回一个数组合并,它们不完全相同,一个是全局多维数组.
global $animals;
$array1 = array('dogs' => __('Dogs'), 'cats' => __('Cats')); //localized
$array2 = $animals; //not localized
the var_dump of $array2 is:
array
'ducks' =>
array
'width' => int 350
'height' => int 350
'crop' => boolean true
'cows' =>
array
'width' => int 750
'height' => int 150
'crop' => boolean true
Run Code Online (Sandbox Code Playgroud)
我需要$merge = array_merge($array1, $array2);返回这样的数组.
array('dogs' => __('Dogs'), 'cats' => __('Cats'), 'ducks', 'cows');
Run Code Online (Sandbox Code Playgroud)
但我得到了各种奇怪的结果.