我在玩PEG.js
start = keyword
keyword = a:[a-z]? {return a.join("");}
Run Code Online (Sandbox Code Playgroud)
为什么我会在这里出现错误:
a.join 不是函数
当我输入一个有效的字符串时abc?
我想查询过去5年内销售的所有产品.
有可能这样做:
select * from products
where time between sysdate-1826 and sysdate
Run Code Online (Sandbox Code Playgroud)
但它还有一个更好的方式,而不是计算所有的日子,并从中减去它sysdate?
我是软件测试的新手。在一个教程中,我读到我可以测试一些这样的方法:
@Test
public void testMultiply() {
MyClass tester = new MyClass();
assertEquals("10 x 5 must be 50", 50, tester.multiply(10, 5));
}
Run Code Online (Sandbox Code Playgroud)
所以我必须将一些参数传递给一个方法并获得一个返回值。
但就我而言,我有一些没有任何参数和返回值的类:
ArrayList al = new ArrayList();
public void Main(){
methodA();
methodB();
}
public void methodA(){
// connect to URL
// get some data
for(int i=0; i<someThing; i++){
al.add(data);
}
}
public void methodB(){
// do something with al
}
Run Code Online (Sandbox Code Playgroud)
是否也可以测试它们?例如,正确的值是否来自methodA().
我正在制作一个网站,访问者在地图上显示其位置,并且在选定的半径(例如 10 公里)内,访问者可以看到一些 POI(例如餐馆、酒吧)。
到目前为止我有这个代码:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?key=[MY_KEY]&sensor=false">
</script>
<script type="text/javascript">
function init()
{
if(navigator.geolocation)
{
navigator.geolocation.getCurrentPosition (processPosition, handleError);
}
else
{
alert("Geolocation not supported in this browser");
}
}
function processPosition(pos)
{
var latlng = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
var myOptions = {
center: latlng,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP …Run Code Online (Sandbox Code Playgroud) 是否可以获取 GitHub 上存储库中所有提交的所有文件的数量?
我自己不使用Git,我只需要知道其他一些大存储库的数量。
我们以JQuery为例
更新
有如下文件:
当然还有像这样的文件夹:
甚至更多的文件。
我需要知道这些文件的总数。
而且,作为奖励,我想知道此存储库中曾经存在的文件总数。
可以在 GitHub 上找到这些数字吗?
我正在尝试使用 Selenium Webdriver 从本地存储中获取一个项目。
我关注了这个网站,但是当我运行我的代码时,我得到了NullPointerException.
当我调试代码时,我看到了函数:getItemFromLocalStorage 由于某种原因返回 NULL。
这是我的代码:
public class storage
{
public static WebDriver driver;
public static JavascriptExecutor js;
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver", "D://chromedriver.exe");
driver = new ChromeDriver();
driver.get("http://html5demos.com/storage");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.id("local")).sendKeys("myLocal");
driver.findElement(By.id("session")).sendKeys("mySession");
driver.findElement(By.tagName("code")).click(); // just to escape textbox
String sItem = getItemFromLocalStorage("value");
System.out.println(sItem);
}
public static String getItemFromLocalStorage(String key)
{
return (String) js.executeScript(String.format(
"return window.localStorage.getItem('%s');", key));
}
}
Run Code Online (Sandbox Code Playgroud) 我将一些隐藏数据加载到数据列表中,并将其与数据属性绑定。
如果选择了一个值,我想获取相应数据属性的值。这是我的代码:
<input list="browser" id="number">
<datalist id="browser">
<option data-customValue="Abc" value="Firefox">1</option>
<option data-customValue="Def" value="Chrome">2</option>
<option data-customValue="Ghi" value="Explorer">3</option>
</datalist>
Run Code Online (Sandbox Code Playgroud)
<input list="browser" id="number">
<datalist id="browser">
<option data-customValue="Abc" value="Firefox">1</option>
<option data-customValue="Def" value="Chrome">2</option>
<option data-customValue="Ghi" value="Explorer">3</option>
</datalist>
Run Code Online (Sandbox Code Playgroud)
就我而言,我只得到undefined作为回应。
这是小提琴:https : //jsfiddle.net/bd4rpztk/1/
我有一个 HTML 字符串,我需要将其转换为 pdf,但我需要的 pdf 必须具有特定的大小和边距。我按照示例显示,现在我有宽度和高度设置的 pdf,但我无法更改或删除边距,所以请帮助我。
using (FileStream fs = new FileStream(somePDFFile, FileMode.OpenOrCreate, FileAccess.Write))
{
iText.Kernel.Pdf.PdfWriter pdfWriter = new iText.Kernel.Pdf.PdfWriter(fs);
iText.Kernel.Pdf.PdfDocument pdfDoc = new iText.Kernel.Pdf.PdfDocument(pdfWriter);
var v = pdfDoc.GetDefaultPageSize().ApplyMargins<iText.Kernel.Geom.Rectangle>(1, 1, 1, 1, true);
pdfDoc.GetDefaultPageSize().SetWidth(250f);
pdfDoc.GetDefaultPageSize().SetHeight(200f);
pdfDoc.GetCatalog().SetLang(new iText.Kernel.Pdf.PdfString("en-US"));
//Set the document to be tagged
pdfDoc.SetTagged();
iText.Html2pdf.ConverterProperties props = new iText.Html2pdf.ConverterProperties();
iText.Html2pdf.HtmlConverter.ConvertToPdf(htmlString, pdfDoc, props);
pdfDoc.Close();
}
Run Code Online (Sandbox Code Playgroud) 是否可以定义与JComboBox中的实际内容不同的值?
在HTML中,它看起来如下:
<select>
<option value="value1">Content1</option>
<option value="value2">Content2</option>
<option value="value3">Content3</option>
</select>
Run Code Online (Sandbox Code Playgroud)
无论内容有多长,这里都可以获得一个简短的值.
在Java中我只知道以下解决方案:
// Creating new JComboBox with predefined values
String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };
private JComboBox combo = new JComboBox(petStrings);
// Retrieving selected value
System.out.println(combo.getSelectedItem());
Run Code Online (Sandbox Code Playgroud)
但在这里我只会得到"Cat","Dog"等
.问题是,我想将数据库中的所有客户名称加载到JComboBox中,然后从所选客户中检索ID.它应该如下所示:
<select>
<option value="104">Peter Smith</option>
<option value="121">Jake Moore</option>
<option value="143">Adam Leonard</option>
</select>
Run Code Online (Sandbox Code Playgroud)