我想根据第一个问题的答案向用户问第二个问题。
(defun something (a b)
(interactive
(list
(read-number "First num: ")
(read-number "Second num: ")))
(message "a is %s and b is %s" a b))
Run Code Online (Sandbox Code Playgroud)
所以我需要一种方法来测试条目值:
(defun something-else (a &optional b)
(interactive
(list
(read-number "First num: ")
(if (< a 2)
(read-number "Second num: "))))
(message "a is %s" a))
Run Code Online (Sandbox Code Playgroud)
但
if: Symbol's value as variable is void: a
Run Code Online (Sandbox Code Playgroud)
interactive问题:如何以真正互动的方式使用?
我有一堆我要检查的变量,如果它们包含值"None",那么我想清空它们.
var1=(check for some value, sometimes it returns "none")
var2=(check for some value, sometimes it returns "none")
var3=(check for some value, sometimes it returns "none")
someBizzareName=(check for some value, sometimes it returns "none")
if [[ "${var1}" == "None" ]] ; then
var1=""
fi
if [[ "${var2}" == "None" ]] ; then
var2=""
fi
Run Code Online (Sandbox Code Playgroud)
这是所有工作的罚款和花花公子,只是因为我有很多 VARN的,我将结束与一吨的if [[ "${varN}" == "None" ]] 和我都知道他们的名字; 所以我想知道,因为它在BASH非常本质上搜索和匹配所有内容,如果有变量的通配符,在for循环中,将匹配所有变量,类似的东西${*}(我试过,不起作用) ?我已经完成了各种搜索,但总能找到匹配变量内容的东西,而不是var本身..?
我有这个页面,书名和作者姓名.当用户接受谷歌提案翻译页面时,我希望这两个元素保持不变.
如何告诉谷歌翻译以避免页面的某些元素?
该Web应用程序从Web检索图像,尤其是图标图标。因此,每次刷新页面时,都会向网站发出请求,然后再次获取图标。
这是我传递URL的功能;favicon()是一个从网站/页面抓取并返回它的库。
router.get('/feedicon', function(req, res) {
favicon(req.query.url, function(err, icon) {
if (icon) {
res.send(icon);
} else {
res.status(500).send('No icon found');
}
});
});
Run Code Online (Sandbox Code Playgroud)
现在,如果icon找到有效文件,
/cache目录存在/创建目录(如果不可能,则返回错误);icon在/cache目录中;我宁愿不安装lib来做到这一点,实际上,我绊脚石的地方是“唯一时间戳”缓存图像的最佳方法,从而确保提供正确的文件。
另外,如果使用哈希将文件标识为ID,我还会担心性能。
快速缓存这样的文件的最佳实践是什么?我很难找到它,就像没有人需要在NodeJs / express中缓存动态图像一样。
我有这个单页应用程序,带有使用令牌构建的动态 URL,例如example.com/XV252GTHcss、favicon 等各种资产。
以下是我注册 Service Worker 的方法:
navigator.serviceWorker.register('sw.js');
Run Code Online (Sandbox Code Playgroud)
在所述中sw.js,我在安装时预先缓存了资源:
var cacheName = 'v1';
var cacheAssets = [
'index.html',
'app.js',
'style.css',
'favicon.ico'
];
function precache() {
return caches.open(cacheName).then(function (cache) {
return cache.addAll(cacheAssets);
});
}
self.addEventListener('install', function(event) {
event.waitUntil(precache());
});
Run Code Online (Sandbox Code Playgroud)
请注意,index.html(注册 Service Worker 的)页面只是一个模板,在发送到客户端之前会在服务器上填充;所以在这个预缓存阶段,我只缓存模板,而不缓存页面。
现在,在 fetch 事件中,任何不在缓存中的请求资源都会被复制到缓存中:
addEventListener('fetch', event => {
event.respondWith(async function() {
const cachedResponse = await caches.match(event.request);
if (cachedResponse) return cachedResponse;
return fetch(event.request).then(updateCache(event.request));
}());
});
Run Code Online (Sandbox Code Playgroud)
使用此更新功能
function updateCache(request) {
return caches.open(cacheName).then(cache => {
return …Run Code Online (Sandbox Code Playgroud) 我想要做的是,当我发现自己使用一个提示我输入值的函数时,这个值总是正确的,能够将函数绑定到一个键并自动接受答案,模拟一个RET在迷你缓冲区.
以" ido-switch-buffer " 为例.输入后,它会提示您输入缓冲区名称,并建议最后访问的名称.
(它可以做更多,这就是为什么我不想重新定义它,我只想要一个包装它)
假设我想在最后访问的两个缓冲区之间切换,我怎么说在我的.emacs中呢?
我试图找出如何使用xpath通配符来获取favicon:
$doc = new DOMDocument();
$doc->strictErrorChecking = FALSE;
$doc->loadHTML(file_get_contents($url));
$xml = simplexml_import_dom($doc);
Run Code Online (Sandbox Code Playgroud)
在这里,我正在测试“快捷方式图标”和“图标”(使用三元运算符):
$query = $xml->xpath('//link[@rel="shortcut icon"]');
$arr = (empty($query) ? $xml->xpath('//link[@rel="icon"]') : $query);
$favicon = $arr[0]['href'];
Run Code Online (Sandbox Code Playgroud)
它可以工作,但不是很优雅;是否有通配符(*)方法可一次性获得“快捷方式图标”和“图标”?
我不明白gtk.Treeview()列表模型是如何工作的:
据我所知,我必须将 lismodel 包装在 a 中,gtk.TreeModelSort()但是当我这样做时,我无法再访问 listmodel 方法了..
lm = gtk.ListStore(object)
listmodel = gtk.TreeModelSort(lm)
for f in files:
listmodel.append([f])
return listmodel
Run Code Online (Sandbox Code Playgroud)
AttributeError: 'gtk.TreeModelSort' 对象没有属性 'append'
我不认为我正在尝试做的事情是可能的。
<div class="row">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div class="row">
<div class="item"></div>
<div class="item"></div>
</div>
<div class="row">
<div class="item"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
我希望所有的.items 都占据最大的、相同的水平空间,即(大约)第一个中的 33%,第二个中的 50%,最后一个中的 100%。
这里的想法是不设置大小的的.itemS(并避免设定ids到元素)为最大的灵活性和最小误差表面; 如果使用 FlexBox 无法做到这一点,但使用其他策略可以做到,请分享。