i have a hashmap where every key has many values(stored in a arraylist). How to display the arraylist i.e the values for a particular key in a hashmap in java??
I'm storing several versions of a file based on a digest of the original filename and its version, like this:
$filename = sha1($original . ':' . $version);
Would it be worth it to cache the digest ($filename) in memcache as a key/value pair (the key being the original + version and value the sha1 hash), or is generating the digest quick enough (for a high traffic php web app)?
Thanks,
Johnathan
What is the difference between INSTEAD OF and AFTER trigger in MS-SQL?
INSTEAD OF trigger invoked before unique key constraint, will the AFTER trigger invoke after unique key constraint?
Need help. I am trying to automate error notifications to be sent in mailers. For that I am querying the sysssislog table. I have pasted an "Execute SQl task" on the package event handler "On error". For testing purpose, I am deliberately trying to load duplicate keys in a table which consists of a Primary key column(so as to get an error).
But instead of having just one error, "Violation of primary key constraint", SSIS records 3 in the table. PFA the screenshot as well. How can i restrict the tool to log only one error and not multiple ???
Package Structure.
Package ("On error Event handler") - DFT -
Oledb Source - Oledb Destination
SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "The statement has been terminated.". An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Violation of PRIMARY KEY constraint 'PK_SalesPerson_SalesPersonID'. Cannot insert duplicate key in object 'dbo.SalesPerson'.".
SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "input "OLE DB Destination Input" (56)" failed because error code 0xC020907B occurred, and the error row disposition on "input "OLE DB Destination Input" (56)" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.
SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "OLE DB Destination" (43) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (56). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.
Please guide me. Your help is very much appreciated.
Thanks
This is how I define the find object:
Range rngDoc = m_oDocument.GetContent();
nEnd = rngDoc.GetEnd();
rngDoc.SetRange(nStart,nEnd);//do not search entire document -> faster
Find fn = rngDoc.GetFind();
However, when I execute the Find, it finds objects that lay before the given start.
Any idea how do I define where the find should search?
Thanks!
I'm getting "The 'charCode' property of a keydown event should not be used. The value is meaningless" error in firefox using jQuery. My code looks like this:
$("div#center-box div#empid-textbox input.id").keydown(function(e){
key = e.which;
if(key===13){
//do something;
};
});
does anyone know how to remedy this error?
Hello, I can't login to github with generated ssh-keys. I've followed this manual: http://help.github.com/linux-key-setup but at step:
ssh [email protected]
I get:
Agent admitted failure to sign using
the key. Permission denied
(publickey).
What's wroing? And, of course, I'm adding my own user email.
In ASP.NET, binding a DataGrid to a list of objects is super-easy.
I end up with a row for each object in the list, and any cell in a given row is bound to a property of the corresponding object.
However, suppose one of the properties of my object is a dictionary, and each is expected to contain a specific key. Is there any way to bind one of my DataGridColumns to that dictionary key?
Thanks.
I'm wondering how other developers are handling source code conflicts for config files when system admins modify them in production. For example, if a system admin updates a appsettings key on the production server and then my team publishes out a project, it will overwrite that key.
How do you handle config file updates in your organization?
In my iPhone project I have used this solution to encrypt data with DER encoded certificate, which was generated by openssl commands like this:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.pem -out cert.pem
openssl x509 -outform der -in cert.pem -out cert.der
openssl rsa -in privateKey.pem -outform DER -out privateKey.der
And now I want to decrypt data using private key file. How can I get the private SecKeyRef instance from DER encoded private key file?
Need some help regarding array sorting....
I have two arrays. The main one (where the key is the user id) :
$user[31] = 'Tom'
$user[43] = 'Jane'
and another array with the order they should be displayed (where key is the order and value is the user id) :
$order[1] = 43
$order[2] = 31
How can I apply the ordering to the main array using the ordering one?
Thanks guys!
I logged into my MSDN subscription (Premium) today to download the new expression studio, and I noticed that unlike Expression 3, it requires you to enter a key, and they only provide 1.
Previously I installed Expression 3 on 2 computer, my home and my work computer. So my question is, is this no longer allowed? or is it a key that can be used multiple times?
Okay.. i got the offline access session key
Can some please tell me how can i get a user's status updates using the offline access session key i have ?
Looked in the Graph API and PHP SDK but nothing helps
I'm doing a INSERT INTO query in order to initialize a new table.
The primary key is RFQ_ID and Action_Time
How could add 1 milisecond to each Action_Time on new record in order to avoid "Violation of PRIMARY KEY constraint"
INSERT INTO QSW_RFQ_Log
(RFQ_ID, Action_Time, Quote_ID)
SELECT
RFQ_ID
, GETDATE() AS Action_Time
, Quote_ID
, 'Added to RFQ on Initialization' AS Note
FROM QSW_Quote
I'm trying to figure out how to parse a VCard to a Python dictionary using VObject.
vobj=vobject.readOne(string)
print vobj.behavior.knownChildren
This is all I get:
{'CATEGORIES': (0, None, None), 'ADR': (0, None, None), 'UID': (0, None, None), 'PHOTO': (0, None, None), 'LABEL': (0, None, None), 'VERSION': (1, 1, None), 'FN': (1, 1, None), 'ORG': (0, None, None), 'N': (1, 1, None), 'PRODID': (0, 1, None)}
How can I populate the dictionary with my VCard data?
I have the ciphertext and an encrypting program (with the key hardcoded in). How would I go about finding the key? Surely the availability of the encryptor must open up possibilities beyond brute-forcing it.
Trying to solve this problem.
I would like to learn how the bootstrapper detects if prerequisites (specifically .NET 3.5) are installed.
According to this reference, a way to detect if .NET is installed is to check the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5
Using process monitor, I have inspected registry queries done by the bootstrapper (setup.exe) and it did not show any access to this registry key.
Does anybody know how the bootstrapper determines whether the prerequisites are installed on the target system?
From the docs:
When Core Data turns an object into a
fault, key-value observing (KVO)
change notifications (see Key-Value
Observing Programming Guide) are sent
for the object’s properties. If you
are observing properties of an object
that is turned into a fault and the
fault is subsequently realized, you
receive change notifications for
properties whose values have not in
fact changed.
So if an object turns into a fault, Core Data does send KVO notifications for changed properties? So I must always check for isFault == NO before beeing happy about the notification?
I have a table of data with survey results, and I want to do certain calculations on this data. The datastructure is somewhat like this:
____________________________________________________________________________________
| group |individual | key | key | key |
| | |subkey|subkey|subkey|subkey|subkey|subkey|subkey|subkey|subkey|
| | |q|q|q |q |q |q|q|q |q|q|q |q |q |q|q|q |q|q|q |q |q |q|q|q |
|-------|-----------|-|-|--|--|---|-|-|--|-|-|--|--|---|-|-|--|-|-|--|--|---|-|-|--|
| 1 | 0001 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |
| 1 | 0002 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |
| 1 | 0003 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |
| 2 | 0004 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |
| 2 | 0005 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |
| 3 | 0006 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |
| 4 | 0007 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |1|7|5 |1 |3 |1|4|1 |
------------------------------------------------------------------------------------
Excuse my poor ascii skills...
So, every individual belongs to a group, and has answered some questions. These questions are always grouped in keys and subkeys.
Is there any simple method to calculate averages, deviations and similar based on the groupings.
Something like
public float getAverage(int key, int individual);
float avg = getAverage(5,7);
I think what I'm asking is what would be the best way to structure the data in C# to make it as easy as possible to work with?
I have started making classes for every entity, but I got confused somewhere and something stopped working. So before I continue along this path, I was wondering if there are any other, better, ways of doing this?
(Every individual can also have describing variables, like agegroup and such, but that's not important for the base functionality.)
Our current solution does all calculations inline in the queries when requesting the data from the database. This works, but it's slow and the number of queries equals questions * individuals + keys * individuals, which could be alot if individual queries.
Any suggestions?
I need to have my edit box work the same for both tab and the enter key.
I have found lots of problems doing this in the application. Is there some way that I can send a tab key to the form/edit box.
(Note that this has to be in the Compact Framework.)
I created a method to have multilingual text on different objects without creating field for each languages or tables for each objects types.
Now the only problem I've got is N+1 select queries when doing a simple loading.
Tables schema :
CREATE TABLE `testentities` (
`keyTestEntity` int(11) NOT NULL,
`keyMultilingualText` int(11) NOT NULL,
PRIMARY KEY (`keyTestEntity`)
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
CREATE TABLE `common_multilingualtexts` (
`keyMultilingualText` int(11) NOT NULL auto_increment,
PRIMARY KEY (`keyMultilingualText`)
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
CREATE TABLE `common_multilingualtexts_values` (
`languageCode` varchar(5) NOT NULL,
`keyMultilingualText` int(11) NOT NULL,
`value` text,
PRIMARY KEY (`languageCode`,`keyMultilingualText`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
MultilingualText.java
@Entity
@Table(name = "common_multilingualtexts")
public class MultilingualText implements Serializable
{
private Integer m_iKeyMultilingualText;
private Map<String, String> m_lValues = new HashMap<String, String>();
public void setKeyMultilingualText(Integer p_iKeyMultilingualText)
{
m_iKeyMultilingualText = p_iKeyMultilingualText;
}
@Id
@GeneratedValue
@Column(name = "keyMultilingualText")
public Integer getKeyMultilingualText()
{
return m_iKeyMultilingualText;
}
public void setValues(Map<String, String> p_lValues)
{
m_lValues = p_lValues;
}
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "common_multilingualtexts_values", joinColumns = @JoinColumn(name = "keyMultilingualText"))
@MapKeyColumn(name = "languageCode")
@Column(name = "value")
public Map<String, String> getValues()
{
return m_lValues;
}
public void put(String p_sLanguageCode, String p_sValue)
{
m_lValues.put(p_sLanguageCode,p_sValue);
}
public String get(String p_sLanguageCode)
{
if(m_lValues.containsKey(p_sLanguageCode))
{
return m_lValues.get(p_sLanguageCode);
}
return null;
}
}
And it is used like this on a object (having a foreign key to the multilingual text) :
@Entity
@Table(name = "testentities")
public class TestEntity implements Serializable
{
private Integer m_iKeyEntity;
private MultilingualText m_oText;
public void setKeyEntity(Integer p_iKeyEntity)
{
m_iKeyEntity = p_iKeyEntity;
}
@Id
@GeneratedValue
@Column(name = "keyEntity")
public Integer getKeyEntity()
{
return m_iKeyEntity;
}
public void setText(MultilingualText p_oText)
{
m_oText = p_oText;
}
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "keyText")
public MultilingualText getText()
{
return m_oText;
}
}
Now, when doing a simple HQL query : from TestEntity, I get a query selecting TestEntity's and one query for each MultilingualText that need to be loaded on each TestEntity. I've searched a lot and found absolutely no solutions. I have tested :
@Fetch(FetchType.JOIN)
optional = false
@ManyToOne instead of @OneToOne
Now I am out of idea!
What is the difference between INSTEAD OF and AFTER trigger in SQL Server?
INSTEAD OF trigger invoked before unique key constraint, will the AFTER trigger invoke after unique key constraint?
A couple of times I've been in the situation where I've wanted to refactor the design of some model and have ended up putting update logic in migrations. However, as far as I've understood, this is not good practice (especially since you are encouraged to use your schema file for deployment, and not your migrations). How do you deal with these kind of problems?
To clearify what I mean, say I have a User model. Since I thought there would only be two kinds of users, namely a "normal" user and an administrator, I chose to use a simple boolean field telling whether the user was an adminstrator or not.
However, after I while I figured I needed some third kind of user, perhaps a moderator or something similar. In this case I add a UserType model (and the corresponding migration), and a second migration for removing the "admin" flag from the user table. And here comes the problem. In the "add_user_type_to_users" migration I have to map the admin flag value to a user type. Additionally, in order to do this, the user types have to exist, meaning I can not use the seeds file, but rather create the user types in the migration (also considered bad practice). Here comes some fictional code representing the situation:
class CreateUserTypes < ActiveRecord::Migration
def self.up
create_table :user_types do |t|
t.string :name, :nil => false, :unique => true
end
#Create basic types (can not put in seed, because of future migration dependency)
UserType.create!(:name => "BASIC")
UserType.create!(:name => "MODERATOR")
UserType.create!(:name => "ADMINISTRATOR")
end
def self.down
drop_table :user_types
end
end
class AddTypeIdToUsers < ActiveRecord::Migration
def self.up
add_column :users, :type_id, :integer
#Determine type via the admin flag
basic = UserType.find_by_name("BASIC")
admin = UserType.find_by_name("ADMINISTRATOR")
User.all.each {|u| u.update_attribute(:type_id, (u.admin?) ? admin.id : basic.id)}
#Remove the admin flag
remove_column :users, :admin
#Add foreign key
execute "alter table users add constraint fk_user_type_id
foreign key (type_id) references user_types (id)"
end
def self.down
#Re-add the admin flag
add_column :users, :admin, :boolean, :default => false
#Reset the admin flag (this is the problematic update code)
admin = UserType.find_by_name("ADMINISTRATOR")
execute "update users set admin=true where type_id=#{admin.id}"
#Remove foreign key constraint
execute "alter table users drop foreign key fk_user_type_id"
#Drop the type_id column
remove_column :users, :type_id
end
end
As you can see there are two problematic parts. First the row creation part in the first model, which is necessary if I would like to run all migrations in a row, then the "update" part in the second migration that maps the "admin" column to the "type_id" column.
Any advice?