我的控制台启用了透明度,当我运行其他ncurses应用程序时,我看到背景保持透明.我试图让我的应用程序保持透明度,而不是应用深黑色不透明背景.
这就是我到目前为止所做的
start_color();
init_pair(1, COLOR_GREEN, COLOR_BLACK);
attron(COLOR_PAIR(1));
mvprintw(10,10, "Hello");
refresh();
attroff(COLOR_PAIR(1));
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
谢谢
我需要将碳方法转换为可可,我无法找到有关碳方法getPtrSize真正做什么的任何文档.从我正在翻译的代码来看,它似乎返回了图像的字节表示,但这与名称并不完全匹配.有人可以给我一个很好的解释这个方法或链接我描述它的一些文档.我正在翻译的代码是一个名为MCL的常见lisp实现,它具有碳桥(我正在转换为CCL,这是一个带有Cocoa桥的常见lisp实现).这是MCL代码(#_before方法调用意味着它是碳方法):
(defmethod COPY-CONTENT-INTO ((Source inflatable-icon)
(Destination inflatable-icon))
;; check for size compatibility to avoid disaster
(unless (and (= (rows Source) (rows Destination))
(= (columns Source) (columns Destination))
(= (#_getPtrSize (image Source))
(#_getPtrSize (image Destination))))
(error "cannot copy content of source into destination
inflatable icon: incompatible sizes"))
;; given that they are the same size only copy content
(setf (is-upright Destination) (is-upright Source))
(setf (height Destination) (height Source))
(setf (dz Destination) (dz Source))
(setf (surfaces Destination) (surfaces Source))
(setf (distance Destination) …Run Code Online (Sandbox Code Playgroud) 我正在使用jQuery $ .ajax()函数.我把它放到一个父函数中,它将一些值传递给ajax函数.我想做的是,有一个用户定义的回调函数,它获取从ajax成功函数传入的数据参数.
这是我的想法会起作用,但它不是:
testFunc = function(str, callback) {
// Send our params
var data = 'some data to send';
$.ajax({
type: 'POST',
url: 'http://www.myurl.com',
data: data,
success: callback
});
}
Run Code Online (Sandbox Code Playgroud)
然后我希望能够调用该函数,并传入我的自定义函数,以便我可以使用该函数内部的成功函数数据:
testFunc('my string data', function(data){
alert(data);
});
Run Code Online (Sandbox Code Playgroud)
我希望这与以下相同:
testFunc = function(str, callback) {
// Send our params
var data = 'some data to send';
$.ajax({
type: 'POST',
url: 'http://www.myurl.com',
data: data,
success: function(data) {
alert(data);
}
});
}
Run Code Online (Sandbox Code Playgroud) public abstract class Master
{
public void printForAllMethodsInSubClass()
{
System.out.println ("Printing before subclass method executes");
System.out.println ("Parameters for subclass method were: ....");
}
}
public class Owner extends Master {
public void printSomething () {
System.out.println ("This printed from Owner");
}
public int returnSomeCals ()
{
return 5+5;
}
}
Run Code Online (Sandbox Code Playgroud)
不搞乱子类的方法......是否可以printForAllMethodsInSubClass()在子类的方法执行之前执行?
更新:
使用AspectJ/Ruby/Python ......等是否也可以打印参数?以上代码格式如下:
public abstract class Master
{
public void printForAllMethodsInSubClass()
{
System.out.println ("Printing before subclass method executes");
}
}
public class Owner extends Master {
public …Run Code Online (Sandbox Code Playgroud) 我试图覆盖一些ggplot条带中的文本以包含希腊字符.这是一些示例数据,以及绘图的基础.
dfr <- data.frame(
x = rep(1:10, times = 6),
y = runif(60),
fx = rep(c("foo", "bar"), each = 30),
fy = rep(c("alpha", "beta", "gamma"), each = 10, times = 2)
)
p <- ggplot(dfr, aes(x, y)) + geom_point()
Run Code Online (Sandbox Code Playgroud)
我对情节的第一次尝试在条形标签上没有希腊语.
p + facet_grid(fy ~ fx)
Run Code Online (Sandbox Code Playgroud)
我认为我应该添加一个贴标签参数facet_grid来覆盖文本.我假设这应该吐出一个表达式来处理希腊字符,但是我的代码只是在打印图形时抛出一个错误.
lbl <- function(variable, value)
{
if(variable == "fy") parse(text=as.character(value)) else value
}
p + facet_grid(fy ~ fx, labeller = lbl)
Error in aperm(X, c(s.call, s.ans)) :
unimplemented type 'expression' in 'aperm'
Run Code Online (Sandbox Code Playgroud)
我应该如何创建条带标签?
我正在尝试编写一个Java程序,该程序读取由URL组成的输入文件,从这些文件中提取令牌,并跟踪每个令牌在文件中出现的次数.我写了以下代码:
import java.io.*;
import java.net.*;
public class Main {
static class Tokens
{
String name;
int count;
}
public static void main(String[] args) {
String url_str,host;
String htokens[];
URL url;
boolean found=false;
Tokens t[];
int i,j,k;
try
{
File f=new File("urlfile.txt");
FileReader fr=new FileReader(f);
BufferedReader br=new BufferedReader(fr);
while((url_str=br.readLine())!=null)
{
url=new URL(url_str);
host=url.getHost();
htokens=host.split("\\.|\\-|\\_|\\~|[0-9]");
for(i=0;i<htokens.length;i++)
{
if(!htokens[i].isEmpty())
{
for(j=0;j<t.length;j++)
{
if(htokens[i].equals(t[j].name))
{ t[j].count++; found=true; }
}
if(!found)
{
k=t.length;
t[k].name=htokens[i];
t[k].count=1;
}
}
}
System.out.println(t.length + "class tokens :");
for(i=0;i<t.length;i++)
{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用MediaElement让视频永远重复.我在http://msdn.microsoft.com/en-us/library/ms741866.aspx上找到了以下代码,它运行正常.
<!-- The MediaElement control plays the sound. -->
<MediaElement Name="myMediaElement" >
<MediaElement.Triggers>
<EventTrigger RoutedEvent="MediaElement.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<!-- The MediaTimeline has a RepeatBehavior="Forever" which makes the media play
over and over indefinitely.-->
<MediaTimeline Source="C:\MyVideo1.wmv" Storyboard.TargetName="myMediaElement"
RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</MediaElement.Triggers>
</MediaElement>
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是当我尝试将MediaTimeLine绑定到xml源时,我收到错误 - "必须指定URI".
<MediaTimeline Source="{Binding XPath=MyVideos}"
Storyboard.TargetName="myMediaElement" RepeatBehavior="Forever" />
Run Code Online (Sandbox Code Playgroud)
是否有可以取代xaml的C#解决方案?
我想知道是否有关于在Lisp中使用标签的标准做法.我一直在讨论第一个答案中描述的算法的Lisp实现这里懒惰地生成排列 我当前版本使用标签来突破部分功能.
(defun next-permutation (pmute)
(declare (vector pmute))
(let ((len (length pmute)))
(if (> len 2)
(labels ((get-pivot ()
(do ((pivot (1- len) (1- pivot)))
((or (= pivot 0)
(< (aref pmute (1- pivot))
(aref pmute pivot)))
pivot)))
(get-swap (pivot)
(let ((swp (1- len)))
(loop for i from (1- len) downto pivot do
(if (or (and (> (aref pmute i)
(aref pmute (1- pivot)))
(< (aref pmute i) (aref pmute swp)))
(< (aref pmute swp) (aref pmute (1- pivot)))) …Run Code Online (Sandbox Code Playgroud) 假设我在https://www.mysvn.com/svn/上有一个svn存储库.如何使用SharpSVN确定服务器上是否存在远程文件夹https://www.mysvn.com/svn/a/b/c?
我需要这样做,这样我就能告诉失败的连接(即服务器关闭)和尚未创建的文件夹之间的区别.
在完整的https://www.mysvn.com/svn/a/b/c路径上调用信息似乎没有给出异常,这使我能够区分完全没有存储库和只缺少文件夹.
我可以列出https://www.mysvn.com/svn/的所有文件,但是存储库很容易变得太大,以至于这可能需要很长时间.
现在我首先在根网址上执行信息,然后在完整网址上执行信息.如果根URL失败我将其视为服务器问题,但如果它成功并且完整URL失败,我会假设它,因为部分路径尚未在服务器上创建.但是,如果两次检查之间的互联网连接丢失,则可能会给出错误的答案.
java ×3
common-lisp ×2
lisp ×2
ajax ×1
c ×1
c# ×1
callback ×1
cocoa ×1
coding-style ×1
console ×1
ggplot2 ×1
javascript ×1
jquery ×1
macos-carbon ×1
mediaelement ×1
ncurses ×1
r ×1
sharpsvn ×1
svn ×1
wpf ×1