w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Create a symbolic link (or other NTFS reparse point) in Windows Driver
There isn't direct API to create reparse points. You need to use ZwFsControlFileZwFsControlFile() to send FSCTL_SET_REPARSE_POINT ioctl with appropriate input buffers and parameters. Don't have example though!

Categories : Windows

Hoare partition : is this implementation more/less efficient than the standard partition algorithm?
I always prefer the standard Hoare's implementation. If you look at it, it is not very intuitive, but it has a visible advantage: Less number of swaps. While your implementation effectively always does exactly N comparisons and N swaps, the Hoare's implementation does only N comparisons, but it does not swap anything if it is not needed. The difference is significant in some scenarios. At first in a case you use environment where swaps or assignment of variables/objects is a costy operation. For example if you use C/C++ with arrays of objects. Another typical examples where Hoare's partition implementation performs better if when many of the items in your array are of the same value or when the array is almost sorted and needs just to swap a few items. In that cases Hoare's version perfor

Categories : Matlab

After new partition gets created insert partition info in another table through trigger
You can do it with DDL Trigers. Check out this link One important note from the author you should consider adding a partition is not DDL if Oracle decides to do it internally, it’s only DDL if it’s an end-user statement Implicit partition creation is a new feature of 11g and it reffers to the interval partition option.

Categories : Oracle

how to use vars in the command "create partition" with mysql
TO_DAYS("v_fech") is not referencing a variable named v_fech at all. It's trying to convert a literal string "v_fech" to a number of days. Of course, that string is not a valid date expression, so TO_DAYS() can only return NULL. Likewise your reference to v_tab is probably not using the value of the variable v_tab, it's using the actual identifier v_tab. To do what you want to do, you'll have to use dynamic SQL with PREPARE and EXECUTE. Something like the following should work (though I have not tested it). PREPARE stmt FROM CONCAT('ALTER TABLE SystemEvents PARTITION BY RANGE(TO_DAYS(DeviceReportedTime))( PARTITION ', v_tab, ' VALUES LESS THAN (TO_DAYS(''', v_fech, ''')), PARTITION pDefault VALUES LESS THAN MAXVALUE )'); EXECUTE stmt;

Categories : Mysql

Programmatically create/delete/wipe disk partition?
Try this... Imports System.Text Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Try Dim partitionLetter As String = "Q" Dim sb As StringBuilder = New StringBuilder() sb.AppendLine("SELECT DISK=0") 'Select the first disk drive sb.AppendLine("CREATE PARTITION PRIMARY") 'create new partition sb.AppendLine("ASSIGN LETTER=" + partitionLetter) 'assign letter sb.AppendLine("FORMAT FS=FAT32 LABEL=""FD"" QUICK") 'format new partition sb.AppendLine("EXIT") System.IO.File.WriteAllText("c:part.scr", sb.ToString()) 'create diskpart script Process.Start("diskpart.exe", "/s c:part.scr") 'run the script Catch ex As Exception MessageBox.Show(ex.Messag

Categories : Dotnet

How to create a partition in remote ApacheDS, LDAP server
Please refer to http://directory.apache.org/apacheds/basic-ug/1.4.1-changing-server-port.html link to create partition on remote server. I am using ApacheDS Version: 2.0.0-M14 and Apache Directory Studio Version: 2.0.0.v20130628. Hope this will help you. Thanks Shirish

Categories : Windows

Kafka 0.8, is it possible to create topic with partition and replication using java code?
Note: My answer covers Kafka 0.8.1+, i.e. the latest stable version available as of April 2014. Yes, you can create a topic programatically via the Kafka API. And yes, you can specify the desired number of partitions as well as the replication factor for the topic. Note that the recently released Kafka 0.8.1+ provides a slightly different API than Kafka 0.8.0 (which was used by Biks in his linked reply). I added a code example to create a topic in Kafka 0.8.1+ to my reply to the question How Can we create a topic in Kafka from the IDE using API that Biks was referring to above.

Categories : Apache

IIS and COM+ Partitions: Failed to create ASP Application XXX due to invalid or missing COM Partition ID
After a lot of research on this subject I have found the solution: do not use the PartitionId from IIS and do not enable partitions from IIS either. Leave them to default values. The solution to this is the following: Each partition should be assigned as default partition for one user and each IIS Application (and each App pool) should run on the same users that the default partitions use. So basically if you have two IIS Applications named: web1 and web2, and two app pools: app1 and app2, two users user1 and user2 and two partitions: part1 and part2. web1 should run under user1 and app1 should run also under user1 (app1 is the application pool for web1). Then in Component Services user1 should have the default partition: part1. Then when the web1 will search for a COM+ component it will

Categories : Iis

How to get to last NTFS MFT record?
The MFT location isn't always fixed on the volume. You should get the starting MFT offset from the boot sector (sector 0 of the volume, you can find the structure online). The first file in the MFT is the "$MFT" file which is the file record for the entire MFT itself. You can parse the attributes of this file like any other file and get it's data run list. When you know the size of each fragment in clusters, parse the last cluster for each 1024 byte record of the last fragment (although I believe a fragmented MFT is rare). The last record in the MFT is the last record in that particular cluster marked "FILE0", if you encounter a null magic number that would be 1024 bytes too far. Or you can just get the file size from it's attributes and calculate the offset to the end of the MFT based o

Categories : Windows

MySQL table Partition with FLOOR function (partition function not allowed)?
MySQL documents the partitioning functions here. The floor() function appears to have some special considerations. In this case, I think the issue might be that the division is returning a float/double result rather than a decimal result. This is easily fixed in your case because you do not need to do the division: CREATE TABLE `fact_events` ( `event_key` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `event_type_key` tinyint(3) unsigned NOT NULL, `analytic_file_id` bigint(20) unsigned NOT NULL, `sdk_session_id` bigint(20) unsigned NOT NULL, `virtual_button_create_id` bigint(20) unsigned NOT NULL, PRIMARY KEY (`event_key`), KEY `idx_events_event_type` (`event_type_key`) ) PARTITION BY RANGE(event_key) ( PARTITION p0 VALUES LESS THAN (0), PARTITION

Categories : Mysql

Create Foreign key from a primary key
I'm not sure I fully understand the question. Would it not be sensible to have attributes B and C as Primary keys to Table 2, and 3 respectively. You could then reference them as foreign keys in the 1st table.

Categories : Mysql

NTFS vs. File Share
Short answer: No. In Windows each file and directory has an ACL controlling access to it. Each file share also has an ACL controlling access to the share. When you access a remote file through a share you are doing so using the credentials used to login to the local computer. (You can connect using different credentials by entering a username/password when connecting). The remote computer tests the supplied credentials against the ACL on the share. Once you are past that, then every file you attempt to access on the remote machine through this connection will be checked using your credentials against the ACL on the file and the share. This allows a file share to offer more restricted access to some files than if the same user were attempt to access them locally. (So you could share file

Categories : Misc

Why would you create a table with primary key but without and index
why not? PK is constraint - logical entity while index is a physical entity which is used only to speed up queries and is not required by data model/logic so we can (theoretically) use any constraint without having indexes - by price of performance. sometime it is useful. in very, VERY rare and specific cases.

Categories : SQL

i try to create composite primary key with @UniqueConstraint
you don't need @UniqueConstraint if you declare that composite key as your @EmbeddedId see this link for the example. you only need a class to become it's composite id: @Embeddable public class SomeCompositeClass { @Column(name = "SOME_ID_1") private String someId1; @Column(name = "SOME_ID_2") private String someId2; //getter, setter methods } then use it inside your entity to became its @EmbeddedId : @Entity @Table(name = "YOUR_MAIN_TABLE") public class YourMainTable { @EmbeddedId private SomeCompositeClass myCompositeId ; /*setter getter methods */ }

Categories : Hibernate

create a sequence of number in .net for primary key sql
If you have a set of data with your PK column called RecordID and you want to get the next available one you could do something like this: var nextId = table.OrderByDescending(x => x.RecordID).First().RecordID++; However its not perfect as a user could delete the newest record freeing up the RecordID to be re-used. If you have other data that refers to it then it could end up pointing at a different record. I think @David Tansey's comment was the best advice - use a GUID: var nextId = Guid.NewGuid();

Categories : Asp Net

Why do we usually create an index before dropping the primary key?
I haven't seen this pattern. But, I would expect it for a slightly different reason. The purpose is less "facilitating" queries than ensuring that the pair of keys remains unique throughout the entire set of transactions. In other words, between dropping the primary key and creating the new key, there is a short window of opportunity for someone to insert a duplicate pair of keys. Then the second operation will fail. By creating the unique index first, you prevent this from happening. If you know there are no other users/queries using the system when you are modifying the table (say you are in single user mode), then there is no need to create the additional index.

Categories : Mysql

NTFS Journal USN_REASON_HARD_LINK_CHANGE event
As always with the USN, I expect you'll need to go through a bit of trial and error to get it to work right. These observations/guesses may, I hope, be helpful: When the last hard link to a file is deleted, the file is deleted; so if the last hard link has been removed you should see USN_REASON_FILE_DELETE instead of USN_REASON_HARD_LINK_CHANGE. I believe that each reference number refers to a file (or directory, but NTFS doesn't support multiple hard links to directories AFAIK) rather than to a hard link. So immediately after the event is recorded, at least, the file reference number should still be valid, and point to another name for the file. If the file still exists, you can look it up by reference number and use FindFirstFileNameW and friends to find the current links. Comparin

Categories : Windows

NTFS - file record size
It's not actually that much of a waste. You should try to look at what happens when the number of attributes stored in the file record exceeds 1 KB. (by adding additional file names, streams, etc.) It is not clear (to me at least) for different versions of NTFS if the additional attributes are stored in the data section of the volume or in another File Record. In previous versions of NTFS the size of a MFT File Record was equal to the size of a cluster (generally 4KB) which was a waste of space since sometimes all the attributes would take less than 1 KB of space. Since NT 5.0 (I may be wrong), after some research, Microsoft decided that all MFT File Records should be 1KB. So, one reason for storing that number may be backwards compatibility. Imagine you found an old hard drive which stil

Categories : File

What is the difference between HDFS and NTFS and FAT32?
... Because NTFS and FAT aren't Distributed. The advantage of HDFS is that it is. See the HDFS Introduction.

Categories : Hadoop

How do I create a unique public id column which is not primary key
You can use a GUID (Globally Unique IDentifier) to uniquely identify a record. The number of possible GUIDs is so high the chances of duplicating one is next to nothing. Similarly, the chances of someone guessing the GUID is so low that generally they are safe to display to the user (for example www.yoursite.com?id=21EC20203AEA1069A2DD08002B30309D). If you're using php you can use the com_create_guid method. *Note: This method is only supported in PHP5. For PHP4, look at uniqueid.

Categories : SQL

Passing primary key to create action via CSV upload
I'm not 100% sure, but I think this is might work. First you'll have to adjust your table structure according to this thread to turn of the auto-increment create_table(:table_name, :id => false) do |t| t.integer :id, :options => 'PRIMARY KEY' end If this doesn't work on it's own, add the following line to your model. set_primary_key :id

Categories : Ruby On Rails

In SQL does a Primary Key in a create table enforce uniqueness?
A PRIMARY KEY has to be unique, so you only need to declare as a primary key. The underlying index is unique by definition. Creating Unique Indexes

Categories : SQL

I am trying to figure out how to create a method to set the primary key on a datatable
Public Sub setPK(ParamArray columnNames As String()) Dim primaryKeyColumns(columnNames.Count - 1) As System.Data.DataColumn For i As Integer = 0 To columnNames.Count - 1 Step 1 primaryKeyColumns(i) = dataTable.Columns(columnNames(i)) Next dataTable.PrimaryKey = primaryKeyColumns End Sub

Categories : Vb.Net

Viewing Ciphertext of Encrypted File on NTFS (EFS)
The way you open an encrypted file in order to read its raw encrypted contents (e.g. for a backup/restore application) is to use the: OpenEncryptedFileRaw, ReadEncryptedFileRaw, WriteEncryptedFileRaw, and CloseEncryptedFileRaw api functions. Writing the code on the fly, in a hypothetical hybrid language: void ExportEncryptedFileToStream(String filename, Stream targetStream) { Pointer context; res = OpenEncryptedFileRaw("C:UsersIanwallet.dat", 0, ref context); if (res <> ERROR_SUCCESS) RaiseWin32Error(res); try { res = ReadEncryptedFileRaw(exportCallback, null, context); if (res != ERROR_SUCCESS) RaiseWin32Error(res); } finally { CloseEncryptedFileRaw(context) } } function ExportCallback(pbData: PBYTE, pvCallbackCo

Categories : Windows

Error as I try to create a primary key on a field with type Long
You probably wanted bigint instead of LONG which is a long text data type. CREATE TABLE person ( id INTEGER, r_id BIGINT, p_name TEXT, p_age INTEGER, p_address TEXT, p_mobile BIGINT, PRIMARY KEY(r_id) ); See MySQL data types

Categories : Mysql

How can we create a new record with EF when the Primary Key / Identity column is null?
Change your Answer class to be like this: public class Answer { public int AnswerId { get; set; } public string Text { get; set; } } The primary key value will be automatically set by Entity Framework after the database insert. Do not modify the AnswerId yourself, just leave it be. It will be zero for not yet inserted objects.

Categories : C#

access to ntfs stream for a very long filename fails
As the very helpful page on CreateFile says referring to the lpFileName parameter which specifies the filename: In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "?" to the path. Since you are contemplating BackupRead obviously you are wanting to access this stream programatically. If so, test things programatically. Trying all these operations from the command prompt is a crap-shoot and will not establish anything more than the ability to perform such operations from the command prompt. With that in mind, let's try this simple program - boilerplate code removed: #include "stdafx.h" int APIENTRY _tWinMain(HINSTANCE, HINSTAN

Categories : Windows

How does NTFS handle the conflict of short file names?
NTFS won't create two short names like that. The first will be THISIS~1.txt and the second will be THISIS~2.txt. For example, open a command prompt and from the root of C: drive type C:>dir prog* /x /ad<Enter> On a Windows 7 64-bit system you will see output similar to this 03/28/2013 12:24 PM <DIR> PROGRA~1 Program Files 07/31/2013 11:09 AM <DIR> PROGRA~2 Program Files (x86) 12/10/2012 05:30 PM <DIR> PROGRA~3 ProgramData

Categories : Windows

NTFS sparse file data runs ($UsnJrnl)
No, it means that $UsnJrnl occupies 2576 clusters on disk. Sparse clusters don't occupy any space on disk, if you'd try to read sparse cluster, e.g. cluster 10 in your example, NTFS just returns zeros. Generally, you can't determine start and end cluster of the file, since files can be fragmented - your example says that first 1408 clusters are not allocated on disk at all, then 128 clusters of that file occupy disk clusters 510119 - 510247, then 2448 clusters of the file occupy disk clusters 256 - 2704; so in this case you can't say that file begins by cluster X (on disk) and ends by cluster Y (on disk) - it's possible only if file is not fragmented (when it uses only one cluster run).

Categories : Windows

Create a table with default values that use the primary key column in a function
You can use virtual columns for something like this. These are calculated on the fly based on the expression that defines the columns: CREATE TABLE date_dim ( Date_Key DATE NOT NULL, Day_Number AS (EXTRACT(DAY FROM Date_Key)), Day_Name AS (TO_CHAR(Date_Key, 'FMDay')) ) Some notes: I've generally found it easier to not specify the type for a virtual column. You can, but often something weird happens. Your table was no exception: Oracle complained about the VARCHAR2(36) for Day_Name, saying it should be at least VARCHAR2(75). I used the EXTRACT function to get the day number because I think it's more descriptive for this; you should use whatever you're most comfortable with. I used the format string FMDay for Day_Name because the Day format code returns a string that's the length

Categories : SQL

How to make Gradle stop trying to chmod MANIFEST.MF on an NTFS drive
Gradle is trying to set default permissions for that file, and I can't see a way to stop it from doing that. (You could make it set different permissions, but I guess that won't help.) Under Windows/NTFS this normally works just fine, so it might be a problem with you Linux NTFS driver or configuration.

Categories : Linux

django social auth , create user model with email as primary key
Well I am doing facebook login for my ios app. What I am doing is Login to facebook from my app and get the facebook access token Send the facebook email and access token to the django backend Then what I do is, instead of using the django default authenticate method which takes the username and password to authenticate a user, I overwrite my own authenticate method. Doing this is really easy just read Django Custom Authentication In my custom authentication class I verify the email-token pair sent from the front using fb sdk for python and that is it. After than I can login the user using the django in built login

Categories : Python

1-N relation with foreign key which is NOT a primary key (primary is auto_increment 'id') with doctrine2/symfony2
There is no problem making a varchar a primary key. If you really have a space or key size requirement you can set up a lookup code table, but it will make your database and code more complicated than it needs to be. I personally use auto increment keys only for input from processes I don't control: orders, tickets, events, etc. Generally the things are you are tracking from a web process.

Categories : Mysql

need to change primary key being referenced as foreign key in other table to composite primary key
Changing single PK to a composite may not be the best idea.. Composite keys mostly come up as a bad idea in legacy designs. Maybe you should instead add a column to disambiguate the ID -- or indeed (since the ambiguity appears to be AudiName) add a "pure" integer PK columns, whose sole purpose is to be unique. This would be what is known as a "surrogate key". This would guarantee uniqueness & reliable relationships, without needing to introduce multi-column keys into your child tables. Multi-column keys get ugly at deeper levels of structure.

Categories : SQL

How to create a Scala class with private field with public getter, and primary constructor taking a parameter of the same name
Whether this is indeed a design flaw is rather debatable. One would consider that complicating the syntax to allow this particular use case is not worthwhile. Also, Scala is after all a predominantly functional language, so the presence of vars in your program should not be that frequent, again raising the question if this particular use case needs to be handled in a special way. However, it seems that a simple solution to your problem would be to use an apply method in the companion object: class Foo private(private var _x: Int) { def x = _x } object Foo { def apply(x: Int): Foo = new Foo(x) } Usage: val f = Foo(x = 3) println(f.x) LATER EDIT: Here is a solution similar to what you originally requested, but that changes the naming a bit: class Foo(initialX: Int) { private

Categories : Scala

Hibernate - Fetching entity having a composite primary key using any one of the primary key
1) You can have only one primary key for entity 2) If you compare by primary key, you compare by whole primary key, so you must give complete entity 3) If you specify ID by @IdClass annotation, you have fields on entity representing each component of primary key, and you can refer them in HQL or Criteria, so maybe you should consider redeign? I've made an example in that answer: Why is my EmbeddedId in hibernate not working?

Categories : Java

How to create table in mysql database with foreign key which is primary key of another table?
You can do it like follows : CREATE TABLE person ( id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, name CHAR(60) NOT NULL, PRIMARY KEY (id) ); CREATE TABLE shirt ( id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, style ENUM('t-shirt', 'polo', 'dress') NOT NULL, color ENUM('red', 'blue', 'orange', 'white', 'black') NOT NULL, owner SMALLINT UNSIGNED NOT NULL REFERENCES person(id), PRIMARY KEY (id) ); I hope you understand the create table code. owner in the shirt table is the foreign key referencing id from the person table

Categories : Mysql

C++ primary expressions - Is it primary expression or not?
C++ expressions can be complex, which is to say they can be made up of nested expressions, combined through the use of operators, and those nested expressions may in turn be complex. If you decompose a complex expression into ever smaller units, at some point you'll be left with units that are atomic in the sense that they cannot be decomposed further. Those are primary expressions; they include identifiers, literals, the keyword this, and lambda expressions. However, it is true that there is one non-atomic construct that the C++ Standard defines as primary: Expressions enclosed in round brackets (aka parentheses). So the (variable + 10) example you give is a primary expression (and so are the sub-expressions variable (which is an identifier), and 10 (which is a literal). I believe the

Categories : C++

why closing down the primary doesn't make replica to vote a new primary in mongodb replica set
To elect a new primary in MongoDB replica set the majority of the members must vote for the new primary. That's majority of the original (or configured) members. You configured two members - one is not a majority. You need to add a third member, either a regular node or an arbiter, if you want your failover to happen automatically.

Categories : Mongodb

Twitter ActiveRecord Reputation: Counting primary reputations as non-primary reputations
Here's a simple solution that was found with the help of the gem's creator Katsuya Noguchi. There's no need to create a :voter_powervotes reputation inside of the voter model when you can just count by whom the power_votes were evaluated by. I def felt like a dolt after seeing how simple it was. Hopefully this helps someone else! voter.rb def powervotes Poll.evaluated_by(:power_votes, self).count.to_i end GitHub issue reference: #63 STI pulls wrong target_id for non-primary reputation

Categories : Ruby On Rails



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.