我有一个12列UNIQUE索引的表.\d sales节目sales_uq UNIQUE, btree (a1, a2, a3, ... a12).
我做以下查询:
SELECT a1, a2, a3, ... a12 FROM sales GROUP BY a1, a2, a3, ... a12 HAVING count(1) > 1;
Run Code Online (Sandbox Code Playgroud)
我得到了一堆结果.怎么可能?!索引是否可能存在,但某种程度上是禁用的?或者是否存在NULL问题?或者使用浮点数(索引中的两列是类型double precision)?
我正在尝试创建一个ListView,它将填充数组中的条目.
所以这是我的项目布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="60dip" >
<ImageView android:id="@+id/list_item_image"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_width="50dip"/>
<TextView android:id="@+id/list_item"
android:layout_height="fill_parent"
android:textSize="25sp"
android:layout_width="fill_parent"
android:ellipsize="marquee"
android:gravity="center_vertical"
android:padding="5dip" >
</TextView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我试图改变layout_height的LinearLayout,但我遇到了一些问题.如果我保持高度wrap_content,我的列表将显示正确的条目 - 项目1,项目2,项目3,依此类推,直到项目12.但是如果我将高度更改为60dip,则条目在第六个条目后重复(I得到第1项,第2项,第3项,第4项,第5项,第6项,第1项,第2项,第3项......).如果我继续增大,则条目会更频繁地重复.
这是ListAdapter我设置列表条目的片段:
public View getView(int position, View convertView, ViewGroup parent) {
LinearLayout layout;
if (convertView == null){
layout = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.items_list_item, parent, false);
TextView title = (TextView) layout.findViewById(R.id.list_item);
title.setText(menuItems[position]);
ImageView icon = (ImageView) layout.findViewById(R.id.list_item_image);
int logo = getResources().getIdentifier(menuIcons[position], "drawable", getPackageName());
icon.setImageResource(logo); …Run Code Online (Sandbox Code Playgroud) 我有一个网站,用户可以从Flash播放器流式传输音乐或下载单个歌曲(如mp3).现在,如果您点击下载链接,他们只需在浏览器中播放.我可以这样做,以便默认情况下弹出下载框,而不会压缩创建用户rt的文件.点击?
我有我的index.php页面,链接看起来像这样(从mySQL动态提取文件名:
<table>
.
.
.
<td>
<?php include 'Media/' . $row['type'] . '/' . $row['folder_name'] . '/download.php' ?>
</td>
Run Code Online (Sandbox Code Playgroud)
然后download.php有这个:
<div class="downloadCell">
<h3>Downloads:</h3>
<ul>
<li>
<a href="auto_download.php?path=Media/<?php echo $row['type'] . '/' . $row['folder_name'] ?>/Chemtengure.mp3">Chemtengure</a>
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
我把auto_download.php放在与index.php相同的目录中:
auto_download.php:
$path = $_GET['path'];
header('Content-Disposition: attachment; filename=' . basename($path));
readfile($path);
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我想在新用户注册时在某些表中创建条目.例如,我想创建一个userprofile,然后引用他们的公司和其他一些记录.我用post_save信号实现了这个:
def callback_create_profile(sender, **kwargs):
# check if we are creating a new User
if kwargs.get('created', True):
user = kwargs.get('instance')
company = Company.objects.create(name="My Company")
employee = Employee.objects.create(company=company, name_first=user.first_name, name_last=user.last_name)
profile = UserProfile.objects.create(user=user, employee=employee, partner=partner)
# Register the callback
post_save.connect(callback_create_profile, sender=User, dispatch_uid="core.models")
Run Code Online (Sandbox Code Playgroud)
运行时效果很好.我可以使用admin创建一个新用户,其他三个表也可以获得合理的条目.(除此之外,员工因为user.first_name和user.last_name在保存时未在管理员表单中填写.我仍然不明白为什么这样做)
当我运行我的测试套件时出现问题.在此之前,我创建了一堆灯具来在表格中创建这些条目.现在我收到一条错误,指出:
IntegrityError: duplicate key value violates unique constraint "core_userprofile_user_id_key"
Run Code Online (Sandbox Code Playgroud)
我想这是因为我已经在id为"1"的灯具中创建了公司,员工和个人资料记录,现在post_save信号正在尝试重新创建它.
我的问题是:我可以在运行灯具时禁用此post_save信号吗?我可以检测到我作为测试套件的一部分运行而不是创建这些记录吗?我现在应该从灯具中删除这些记录吗(虽然信号只设置默认值而不是我想要测试的值)?为什么夹具加载代码不会覆盖创建的记录?
人们如何做到这一点?
我尝试在基于 WPF 的项目(VS2010、Net4.0)上使用 ILMerge,但无法运行合并的可执行文件。所以我创建了两个非常简单的项目
编译每个项目后,我得到一个可执行文件(所以合并,并没有真正合并任何东西,它只是为了测试)。每个可执行文件当然都有效。
然后我以这种方式“合并”每个可执行文件:
"C:\Program Files\Microsoft\ILMerge\ilmerge"
/targetplatform:v4,c:\Windows\Microsoft.NET\Framework\v4.0.30319
/lib:c:\Windows\Microsoft.NET\Framework\v4.0.30319\wpf
/out:Merged.exe MyApplication.exe
Run Code Online (Sandbox Code Playgroud)
(我只是为了可读性而调用了多行)。好的,现在控制台应用程序合并并像以前一样运行,wpf 应用程序合并没有任何错误,但我无法运行它。我的意思是,我打字
Merged.exe
Run Code Online (Sandbox Code Playgroud)
任务栏闪烁,但什么也没有显示——没有窗口,没有错误,什么也没有。
那么我应该如何合并 WPF 应用程序?
感谢bit Twiddling的一些非常有用的stackOverflow用户:设置了哪个位?,我已经构建了我的函数(在问题的最后发布).
任何建议 - 即使是小建议 - 将不胜感激.希望它能使我的代码更好,但至少它应该教会我一些东西.:)
此函数将被调用至少10 13次,并且可能经常被调用10 15次.也就是说,此代码很可能会运行数月,因此任何性能提示都会有所帮助.
该功能占计划时间的72-77%,基于分析和不同配置中的大约十二次运行(优化这里不相关的某些参数).
此功能目前平均运行50个时钟.我不确定这可以改进多少,但我很高兴看到它在30岁时运行.
如果在计算的某个时刻你可以告诉你将返回的值很小(准确值可协商 - 比如说,低于一百万)你可以提前中止.我只对大价值感兴趣.
这就是我希望节省大部分时间的方式,而不是通过进一步的微观优化(尽管这些当然也是受欢迎的!).
添加以响应请求.您无需阅读此部分.
输入是奇数n,1 <n <4282250400097.其他输入提供了这个特定意义上的数字因子分解:
如果数字可被3整除,则设置smallprimes&1;如果数字可被5整除,则设置smallprimes&2;如果数字可被7整除,则设置smallprimes&4;如果数字可被11整除,则设置smallprimes和8,等等.表示313的有效位.可以用素数的平方整除的数字与仅被该数字整除的数字表示不同.(实际上,可以丢弃多个正方形;在另一个函数的预处理阶段,素数的多个正方形<= lim具有小的primes而q设置为0因此它们将被丢弃,其中lim的最佳值通过实验确定. )
q,r和s代表数字的较大因子.任何剩余因子(可能大于数字的平方根,或者如果s非零甚至可能更小)可以通过将因子除以n来找到.
一旦以这种方式恢复所有因子,使用由代码最佳解释的数学公式计算n为强伪荧光的碱基数1 <= b <n .
__attribute__ ((inline))什么都不做.奇怪的是,标记主要功能bases和一些助手__attribute ((hot))伤害性能几乎2%,我无法弄清楚为什么(但它可以重现超过20次测试).所以我没有做出改变.同样, …我正在使用这两行来使用codeigninter活动记录来更新我的表
$this->db->where('reference_number', $reference);
$this->db->update('patient', $data);
Run Code Online (Sandbox Code Playgroud)
我想要的是检查天气它成功更新表格,并根据我想要通知用户,我如何检查成功更新是否发生在这一行?用户指南中没有任何线索告诉通过放线
if($this->db->update('patient', $data));
Run Code Online (Sandbox Code Playgroud)
会给我们一个真或假的价值,我们可以这样做吗?还是有其他解决方案吗?
问候,Rangana
Jus检查这个程序.从逻辑上看它看起来很好,但它为所有东西提供了000000000000000000000
#include<stdio.h>
void main()
{
int n=25,k=32;
printf("binary equivalent\n");
while(k!=0)
{
if((n>>1&0x01)!=0)
printf("1");
else
printf("0");
k--;
}
}
Run Code Online (Sandbox Code Playgroud) 我下载了selenium-java-2.0a5.zip
http://code.google.com/p/selenium/downloads/list
并运行以下代码:
package org.openqa.selenium.example;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class Example {
public static void main(String[] args) {
// Create a new instance of the html unit driver
// Notice that the remainder of the code relies on the interface,
// not the implementation.
WebDriver driver = new HtmlUnitDriver();
// And now use this to visit Google
driver.get("http://www.google.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
// Enter something to …Run Code Online (Sandbox Code Playgroud) c ×2
activerecord ×1
android ×1
apache ×1
browser ×1
c# ×1
codeigniter ×1
django ×1
download ×1
fixtures ×1
ilmerge ×1
java ×1
listadapter ×1
listview ×1
math ×1
optimization ×1
performance ×1
php ×1
postgresql ×1
python ×1
selenium ×1
signals ×1
webdriver ×1
wpf ×1