我想在styles.xml中默认应用按钮文本颜色
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme">
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">@color/black</item>
<item name="android:textColor">@color/green</item>
</style>
Run Code Online (Sandbox Code Playgroud)
如何制作样式更改按钮颜色,并应用于整个应用程序?我的主要节日包括:
<application
android:icon="@drawable/ic_launcher"
android:label="Hack the World"
android:theme="@style/AppTheme">
Run Code Online (Sandbox Code Playgroud)
这会更改所有文本(例如TextView),但不会更改按钮中的文本.如果我使用上面的ColorThemes样式并将其放在按钮的xml中,如下所示:
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:onClick="loadSavedgame"
android:text="Load Saved Game"
android:textColor="@color/green" />"
Run Code Online (Sandbox Code Playgroud)
然后它完美地运作.为什么这种风格不适用于普遍?styles.xml的所有不同版本都具有相同的代码.
我正在尝试删除NaN值并按row.names进行排序。我尝试使用dplyr进行此操作,但我的尝试没有成功。有人可以提出解决办法吗?
require(markovchain)
data1<-data.frame(dv=rep(c("low","high"),3),iv1=sample(c("A","B","C"),replace=T,6))
markov<-markovchainFit(data1)
markovDF<-as(markov, "data.frame")
library(dplyr)
markovDF%>%filter(rowSums>0)%>%arrange(desc(markovDF[,1]))
> markov
$estimate
A B C high low
A NaN NaN NaN NaN NaN
B NaN NaN NaN NaN NaN
C NaN NaN NaN NaN NaN
high 0.3333333 0.0000000 0.6666667 0 0
low 0.6666667 0.3333333 0.0000000 0 0
Run Code Online (Sandbox Code Playgroud)
目标:
A B C high low
high .33 .00 .67 0 0
low .67 .33 .00 0 0
Run Code Online (Sandbox Code Playgroud) 有没有一种简单的方法来获取向量的最后一个匹配的索引?
lastInflectionRow(c(TRUE,FALSE,TRUE,FALSE,FALSE))
lastInflectionRow<-function(temp){
m<-match(TRUE,temp,nomatch=NA)
m
}
Run Code Online (Sandbox Code Playgroud)
目标:3
我正在尝试创建一个简单的forceNetwork,但该图不会呈现。我不断收到以下警告:
Warning message: It looks like Source/Target is not zero-indexed. This is required in JavaScript and so your plot may not render.
我该如何解决?请注意,这simpleNetwork很好用,所以问题似乎出在我如何指定我的数据上。
library(igraph)
library(networkD3)
set.seed(42)
temp<-data.frame(source=c(1,2,3,4),target=c(2,3,4,4))#csv[1:500,]
links<-data.frame(source=temp$source,target=temp$target)
g<-graph.data.frame(cbind(temp$source,temp$target), directed=T)
nodes<-data.frame(name=1:length(V(g)),group=1)
forceNetwork(Links=links,Nodes = nodes,
Source = 'source', Target = 'target',
NodeID = 'name', Group = 'group')
simpleNetwork(temp)
Run Code Online (Sandbox Code Playgroud) 我有一个散列的Wordpress密码数据库.我试图根据数据库存储密码检查用户的密码,但哈希值不正确.我正在使用这个github代码和一些登录isMatch().有什么想法为什么这些密码不匹配?明文密码是alberta10
public boolean isMatch(String password, String storedHash) {
// The first 12 digits of the hash is used to modify the encryption.
String setting = storedHash.substring(0, 12);
logger.log(Level.INFO, "----Hashed pwd from db is: "+storedHash);
logger.log(Level.INFO, "----Hashed pwd using php-pass: "+encrypt(password, setting));
return storedHash.equals(encrypt(password, setting));
}
Run Code Online (Sandbox Code Playgroud)
这是我的authenticate()方法
private void authenticate(String username, String password) throws Exception {
// Throw an Exception if the credentials are invalid
PasswordHasher pwdHasher=new PasswordHasher();
_logger.log(Level.INFO, "----Authenticating user: "+username);
try{
Connection …Run Code Online (Sandbox Code Playgroud) 我正在尝试重新格式化 DataFrame,将行中的值转换为列。我尝试使用 Melt 但出现错误。Transpose 似乎让我完成了其中的一部分,但给出了奇怪的输出(因为我认为输入是分组的 DataFrame)
d = {'name':['bil','bil','bil','jim'],
'col2': ['acct','law', 'acct2','law'],
'col3': [1,2,3,55]
}
df2 = pd.DataFrame(data=d)
df2.groupby(['name','col2']).agg({'col3':'first'})
Run Code Online (Sandbox Code Playgroud)
输出:
name col2 col3
bil acct 1
acct2 3
law 2
jim law 55
Run Code Online (Sandbox Code Playgroud)
目标:
acct acct2 law
bill 1 3 2
jim 55
Run Code Online (Sandbox Code Playgroud) 当我今天早上醒来并启动 VSCode 时,我的默认终端在启动时运行,现在运行任务时是 powershell,而不是 Git Bash。我在窗户上。我曾尝试更改 settings.json 无济于事。有什么我想念的吗?
{
"workbench.startupEditor": "newUntitledFile",
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"[javascript]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"aws.samcli.location": "C:\\Users\\king\\AppData\\Roaming\\npm\\sam.exe",
"typescript.updateImportsOnFileMove.enabled": "always",
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"explorer.confirmDragAndDrop": false,
"diffEditor.maxComputationTime": 0,
"extensions.ignoreRecommendations": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.renderControlCharacters": true,
"[jsonc]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace"
},
"window.zoomLevel": 0,
"editor.accessibilitySupport": "off",
"workbench.editor.untitled.hint": "hidden",
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.external.windowsExec": "C:\\Program Files\\Git\\bin\\bash.exe",
"terminal.explorerKind": "external",
"terminal.integrated.automationShell.linux": ""
}
Run Code Online (Sandbox Code Playgroud)
我发现这个相关的 SO 帖子制作了默认的 powershell,但我没有看到我的设置有任何不正确的地方......特别是因为我的目标是相反的 …
我正在尝试从PDF中提取引文。我确认我的正则表达式在这里适用于Rubular ,但是当我在真实的PDF上测试代码时,它会吐出一些奇怪的空格和错误的信息。如何修复此正则表达式,使其仅提取APA论文引文(参考文献部分中的引文,而不是文本引文)。APA 示例可能有用。我正在尝试从研究论文中获得参考。如果您需要更多详细信息,请告诉我。这个答案可以使用多个正则表达式,但是我确实需要能够提取作者,标题,日期和期刊。如果有帮助,我的尝试在下面:
require 'pdf-reader'
io = open('https://vhil.stanford.edu/pubs/2007/yee-proteus-effect.pdf')
out=open('dump.txt',"w")
reader = PDF::Reader.new(io)
reader.pages.each do |page|
/([a-zA-Z.,&\s]+?)(\(\d+\)).([\sa-zA-Z,:\n\t]+).([\sa-zA-Z,]+).([\sa-zA-Z,]+)/.match(page.text){|m|
puts "===CITATION===="
puts "author: "+m[0].to_str.gsub(/\n\r\t/,'')
puts "title: "+m[2].to_str.gsub(/\n\r\t/,'')
puts "date: "+m[1].to_str.gsub(/\n\r\t/,'')
puts "journal: "+m[3].to_str.gsub(/\n\r\t/,'')
}
#puts page.raw_content
end
puts"\n\n\n=======\n\n\n======"
puts reader.pages.last
Run Code Online (Sandbox Code Playgroud)
为了获得这些示例,我out.puts page.text在foreach循环中运行了。然后,我将大量文本复制到Rubular中,并使用我原来的正则表达式进行测试(上述)。
更改列表的正确方法是什么?在这种情况下,列表由split
library(dplyr)
csv<-data.frame(participant_number=c(1,1,1,2,2),SelfEsteem=c(3,4,2,1,3))
csv<-csv%>%split(.,.$participant_number)%>%mutate(.,var(.$SelfEsteem))
Run Code Online (Sandbox Code Playgroud)
错误:
Error in UseMethod("mutate_") :
no applicable method for 'mutate_' applied to an object of class "list"
Run Code Online (Sandbox Code Playgroud)
更新为了回答评论:我打算计算SelfEsteem每个组的方差(分组var为participant_number)。如果尝试group_by,将无法获得预期的结果。
library(dplyr)
#Please note I changed the dataframe to make my point about variance differences more obvious
csv<-data.frame(participant_number=c(1,1,1,2,2),SelfEsteem=c(3,4,2,1,3))
csv<-csv%>%group_by(participant_number)%>%mutate(.,SE_variance=var(.$SelfEsteem))
#var(c(3,4,2)) #1
#var(c(1,3)) #2
Run Code Online (Sandbox Code Playgroud)
预期:
participant_number SelfEsteem SE_variance
(dbl) (dbl) (dbl)
1 1 3 1
2 1 4 1
3 1 2 1
4 2 1 2
5 2 3 2
Run Code Online (Sandbox Code Playgroud) 我不知道为什么Startup.cs引发此错误。我尝试了这里建议的解决方案(包括重新启动计算机和运行dotnet restore),但没有运气。有任何想法吗?
CS1061'IServiceCollection'不包含'AddSpaStaticFiles'的定义,并且找不到可以接受的扩展方法'AddSpaStaticFiles'接受类型为'IServiceCollection'的第一个参数(是否缺少using指令或程序集引用?)
在startup.cs顶部使用语句:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Myproject.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using System.Text;
//Install-Package Microsoft.AspNetCore.Session
//Install-Package AutoMapper.Extensions.Microsoft.DependencyInjection
Run Code Online (Sandbox Code Playgroud)
我的.csproj文件包含:
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="2.1.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.2.4" />
<PackageReference Include="Flurl.Http" Version="2.2.1" />
<PackageReference Include="jQuery" Version="3.3.1" />
<PackageReference Include="jQuery.Validation" Version="1.17.0" />
<PackageReference Include="LeanKit.API.Client" Version="1.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" …Run Code Online (Sandbox Code Playgroud) r ×4
dplyr ×2
android ×1
asp.net ×1
background ×1
button ×1
c# ×1
dataframe ×1
git-bash ×1
hash ×1
htmlwidgets ×1
igraph ×1
java ×1
javascript ×1
multi-index ×1
networkd3 ×1
pandas ×1
pdf ×1
powershell ×1
python ×1
regex ×1
ruby-2.0 ×1
wordpress ×1
xml ×1