i have this querystring that shall open up my page.
http://www.a1-one.com/[email protected]&stuid=123456
Now when this page loads, on page_load, I want to pick up email and stuid in two different variables. So I can use them to insert into my database (sql server)
how can this be done in vb.net
Hello,
I have a question related to correct handling of returns of the DAO library I'm writing for one project. This library probably is going to be used by another people and I want to do it correctly. So I would like to know, how I should deal with return statements of the functions of my DAO.
Example 1
I have function to getCustomer which should return String. In case query doesn't return any result should I return null, empty string or throw some kind of Exception?
Example 2
I have function getCutomerList which return ArrayList. In case query doesn't return any result should I return null, empty ArrayList or throw some Exception?
Example 3
Some sql exception was detected, what should I do: throw exception or do try..catch of the block where it can occur?
What is the "good" practice or "best" practice to apply in my case?
Thanks on advance,
Serhiy.
Hi folks, I want to duplicate a very large table, but I do not want to copy it row by row. Is there a way to duplicate it?
For example, you can TRUNCATE w/o deleting row/row, so i was wondering if there is something similar for copying entire tables
Hi,
Just wondering what the best way to build a NSPredicate is if some filters are optional?
This is basically for a filter, so if some options aren't selected I don't to filter by them
eg. If I have option1 and option2 set for the filter.
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"option1 = %@ AND option2 = %@] ....
otherwise if just option1
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"option1 = %@] ....
The key being there are 10 different options to filter, so I don't want to have to code for the 10x10 possible combinations.
Thanks
Im using DataServices and OData protocol, i need to generate Get, Post, Delete, and Update from a c++ aplication. how i can do this? the easiest way ??
I can't for the life of me figure out why this function is causing multiple entries into my database table...
When I run the function I end up with two records stacked on top of each one second apart
here is the function:
function generate_signup_token(){
$connection = new DB_Connect(); // <--- my database connection class
$ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);
$sign_up_token = uniqid(mt_rand(), true);
$_SESSION['signup_token'] = $sign_up_token;
$sign_up_token = mysql_real_escape_string($sign_up_token);
$query = "INSERT INTO `token_manager` (`ip_address`, `signup_token`) VALUES ('$ip', '$sign_up_token')";
mysql_query($query);
}
generate_signup_token();
I have a model that looks like this:
class Client(models.Model):
name = models.CharField(max_length=100, primary_key=True)
user = models.ForeignKey(User)
class Contract(models.Model):
title = models.CharField(max_length=100, primary_key=True)
start_date = models.DateField()
end_date = models.DateField()
description = models.TextField()
client = models.ForeignKey(Client)
user = models.ForeignKey(User)
How can i configure a django form so that only clients associated with that user show in the field in the form?
My initial thought was this in my forms.py:
client = forms.ModelChoiceField(queryset=Client.objects.filter(user__username = User.username))
But it didn't work. So how else would I go about it?
hi all,
I am looking some help in php+MySQL+jquery
I have 2 tables
table1
table 1 have 4 colume
(id, title, desc, thumb_img)
tabel2
table 2 have 3 colume(id, table1id, img)
I just want to compare 2 table with the value of $_get['QS'];
and show the records from both (title, desc, img)
Looking forward for the help.:)
If an attacker has several distinct items (for example: e-mail addresses) and knows the encrypted value of each item, can the attacker more easily determine the secret passphrase used to encrypt those items? Meaning, can they determine the passphrase without resorting to brute force?
This question may sound strange, so let me provide a use-case:
User signs up to a site with their e-mail address
Server sends that e-mail address a confirmation URL (for example: https://my.app.com/confirmEmailAddress/bill%40yahoo.com)
Attacker can guess the confirmation URL and therefore can sign up with someone else's e-mail address, and 'confirm' it without ever having to sign in to that person's e-mail account and see the confirmation URL. This is a problem.
Instead of sending the e-mail address plain text in the URL, we'll send it encrypted by a secret passphrase.
(I know the attacker could still intercept the e-mail sent by the server, since e-mail are plain text, but bear with me here.)
If an attacker then signs up with multiple free e-mail accounts and sees multiple URLs, each with the corresponding encrypted e-mail address, could the attacker more easily determine the passphrase used for encryption?
Alternative Solution
I could instead send a random number or one-way hash of their e-mail address (plus random salt). This eliminates storing the secret passphrase, but it means I need to store that random number/hash in the database. The original approach above does not require this extra table.
I'm leaning towards the the one-way hash + extra table solution, but I still would like to know the answer: does having multiple unencrypted e-mail addresses and their encrypted counterparts make it easier to determine the passphrase used?
I am trying to round up cases when it makes sense to use a map (set of key-value entries). So far I have two categories (see below). Assuming more exist, what are they?
Please limit each answer to one unique category and put up an example.
Property values (like a bean)
age -> 30
sex -> male
loc -> calgary
Presence, with O(1) performance
peter -> 1
john -> 1
paul -> 1
Hi everyone,
I would like to use my custom NSManagedObject like a normal object (as well as its regular functions). Is it possible to modify the class in order to be able to initialize it like a normal object?
[[myManagedObject alloc] init];
Thanks
edit: to clarify the question, will it screw everything up if I change the @dynamic with @synthesize in the implementation?
I am developing a search dialog in my eclipse-rcp application.
In the search dialog I have a combobox as follows:
comboImp = new CCombo(grpColSpet, SWT.BORDER | SWT.READ_ONLY);
comboImp.setBounds(556, 46, 184, 27);
comboImpViewer = new ComboViewer(comboImp);
comboImpViewer.setContentProvider(new ArrayContentProvider());
comboImpViewer.setInput(ImpContentProvider.getInstance().getImps());
comboImpViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((Imp)element).getImpName();
}
});
Imp is a database entity, ManyToOne to the main entity which is searched, and ImpContentProvider is the model class which speaks to embedded sqlite database via jpa/hibernate.
This combobox is supposed to contain all instances of Imp, but to also let empty selection; it's value is bound to a service bean as follows:
IObservableValue comboImpSelectionObserveWidget =
ViewersObservables.observeSingleSelection(comboImpViewer);
IObservableValue filterByImpObserveValue =
BeansObservables.observeValue(searchPrep, "imp");
bindingContext.bindValue(comboImpSelectionObserveWidget, filterByImpObserveValue
, null, null);
As soon as the user clicks on the combo, a selection (first element) is made: I can see the call to a selectionlistener i added on the viewer. My question is:
after a selection has been made, how do I let the user change his mind and have an empty selection in the combobox? should I add a "fake" empty instance of Imp to the List returned by the ImpContentProvider? or should I implement an alternative to ArrayContentProvider?
and one additional related question is:
why calling deselectAll() and clearSelection() on the combo does NOT set a null value to the bound bean?
So, I'm working on implementing the answer to my previous question.
Here's my model:
class Talk(models.Model):
title = models.CharField(max_length=200)
mp3 = models.FileField(upload_to = u'talks/', max_length=200)
Here's my form:
class TalkForm(forms.ModelForm):
def clean(self):
super(TalkForm, self).clean()
cleaned_data = self.cleaned_data
if u'mp3' in self.files:
from mutagen.mp3 import MP3
if hasattr(self.files['mp3'], 'temporary_file_path'):
audio = MP3(self.files['mp3'].temporary_file_path())
else:
# What goes here?
audio = None # setting to None for now
...
return cleaned_data
class Meta:
model = Talk
Mutagen needs file-like objects - the first case (where the uploaded file is larger than the size of file handled in memory) works fine, but I don't know how to handle InMemoryUploadedFile that I get otherwise. I've tried:
# TypeError (coercing to Unicode: need string or buffer, InMemoryUploadedFile found)
audio = MP3(self.files['mp3'])
# TypeError (coercing to Unicode: need string or buffer, cStringIO.StringO found)
audio = MP3(self.files['mp3'].file)
# Hangs seemingly indefinitely
audio = MP3(self.files['mp3'].file.read())
Is there something wrong with mutagen, or am I doing it wrong?
I have chart that plots values of Y-axis less than 1 (0.1, 0.24, etc).
When the chart is built, Y-axis label just shows 0 at the origin and no other values along the axis.
I often browse freely-available art on the web. Actually, I can't think of a better use for the internet than to turn it into a gigantic art gallery. When I encounter a set of pieces I quite like, I download them all to my hard drive. wget makes that easy, especially in combination with Python's print function, and I use this all the time to make a list of URLs that I then wget. Say I need to download a list of jpegs that run from art0 to art100 in the directory 'art,' I just tell python
for i in range(0,101):
print "http://somegallery/somedirectory/art", i
So, this is probably a fairly simple operation in Python, and after a find-and-replace to remove whitespace, it's just a matter of using wget -i, but in days before I knew any Python I'd slavishly right-click and save.
Now I've got a bunch of files from Fredericks & Freiser gallery in New York that all go a(1-14), b(1-14), c(1-14), etc., up to the letter g. I could do that in 7 goes, and it would take me less time than it took to write this SO question.
That said, I want to deepen my knowledge of Python. So, given the letters a-g, how do I print a mapping of each letter to the integers 1-14?
My web application deals with strings that need to be converted to numbers alot - users often put commas, currency symbols etc. in these fields so what I want to do is create a string extension method that cleans the field up and converts it to a decimal.
For example:
decimal myNumber = "$1,250.85".ToDecimal();
Can anyone help with this? Thanks!
I'm trying to compile a binary file into a MACH_O object file so that it can be linked it into a dylib. The dylib is written in c/c++.
On linux the following command is used:
ld -r -b binary -o foo.o foo.bin
I have tried various option on OSX but to no avail:
ld -r foo.bin -o foo.o
gives:
ld: warning: -arch not specified
ld: warning: ignoring file foo.bin, file was built for unsupported file format which is not the architecture being linked (x86_64)
An empty .o file is created
ld -arch x86_64 -r foo.bin -o foo.o
ld: warning: ignoring file foo.bin, file was built for unsupported file format which is not the architecture being linked (x86_64)
Again and empty .o file is created. Checking the files with nm gives:
nm foo.o
nm: no name list
The binary file is actually, firmware that will be downloaded to an external device.
Thanks for looking
I am trying to save a .txt file to the documents directory in order to read and write to it. Is the documents directory the same as resource? If so, what is working code that will let me read and write a NSString to that .txt file?
I have a test django app.
In one page the test show the same question to all users.
I'd like that when a user answers correctly, send a signal to other active user's browser to refresh to the next question.
I have been learning about signals in django I learning work with them but I don't now how send the "refresh signal" to client browser.
I think that it can do with a javascript code that check if a certain value (actual question) change and if change reload the page but I don't know this language and the information that I find was confused.
Can anybody help me?
Many Thanks.
I allow the user to record a video within my app, then later play it again. When a user records a video, I save the URL of the video, then play the video later from the saved URL. I save the video both in the Photos app and in my app. If I delete the video within the photos app, it still plays. After about 7 days, the video gets deleted. I think I am saving in my tmp directory, but i'm not sure. Here is what I am doing:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
[self dismissViewControllerAnimated:YES completion:nil];
// Handle a movie capture
if (CFStringCompare ((__bridge_retained CFStringRef) mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo) {
NSString *moviePath = [NSString stringWithFormat:@"%@",[[info objectForKey:UIImagePickerControllerMediaURL] path]];
NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
NSData *videoData = [NSData dataWithContentsOfURL:videoURL];
_justRecordedVideoURL = [NSString stringWithFormat:@"%@",videoURL];
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
_managedObjectContext = [appDelegate managedObjectContext];
Video *video = [NSEntityDescription insertNewObjectForEntityForName:@"Video" inManagedObjectContext:_managedObjectContext];
[video setVideoData:videoData];
[video setVideoURL:[NSString stringWithFormat:@"%@",videoURL]];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateStyle = NSDateFormatterLongStyle;
[dateFormatter setDateStyle:NSDateFormatterLongStyle];
NSDate *date = [dateFormatter dateFromString:[dateFormatter stringFromDate:[NSDate date]]];
NSString *dateAdded = [dateFormatter stringFromDate:date];
[video setDate_recorded:dateAdded];
if(_currentAthlete != nil){
[video setWhosVideo:_currentAthlete];
}
NSError *error = nil;
if(![_managedObjectContext save:&error]){
//handle dat error
}
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *tempPath = [documentsDirectory stringByAppendingFormat:@"/vid1.mp4"];
BOOL success = [videoData writeToFile:tempPath atomically:NO];
if(success == FALSE){
NSLog(@"Video was not successfully saved.");
}
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath)) {
UISaveVideoAtPathToSavedPhotosAlbum(moviePath, self,
@selector(video:didFinishSavingWithError:contextInfo:), nil);
}
}
}
Am I saving it incorrectly? When I go to play the video, it works fine, after a couple days the video will play without audio, then eventually it will be gone. Any ideas why?
Hello! I try to use amazon API using PHP. If I use
print_r($parsed_xml->Items->Item->ItemAttributes)
it show me some result like
SimpleXMLElement Object ( [Binding] = Electronics [Brand] = Canon [DisplaySize] = 2.5 [EAN] = 0013803113662 [Feature] = Array ( [0] = High-powered 20x wide-angle optical zoom with Optical Image Stabilizer [1] = Capture 720p HD movies with stereo sound; HDMI output connector for easy playback on your HDTV [2] = 2.5-inch Vari-Angle System LCD; improved Smart AUTO intelligently selects from 22 predefined shooting situations [3] = DIGIC 4 Image Processor; 12.1-megapixel resolution for poster-size, photo-quality prints [4] = Powered by AA batteries (included); capture images to SD/SDHC memory cards (not included) ) [FloppyDiskDriveDescription] = None [FormFactor] = Rotating [HasRedEyeReduction] = 1 [IsAutographed] = 0 [IsMemorabilia] = 0 [ItemDimensions] = SimpleXMLElement Object ( [Height] = 340 [Length] = 490 [Weight] = 124 [Width] = 350 ) [Label] = Canon [LensType] = Zoom lens [ListPrice] = SimpleXMLElement Object ( [Amount] = 60103 [CurrencyCode] = USD [FormattedPrice] = $601.03 ) [Manufacturer] = Canon [MaximumFocalLength] = 100 [MaximumResolution] = 12.1 [MinimumFocalLength] = 5 [Model] = SX20IS [MPN] = SX20IS [OpticalSensorResolution] = 12.1 [OpticalZoom] = 20 [PackageDimensions] = SimpleXMLElement Object ( [Height] = 460 [Length] = 900 [Weight] = 242 [Width] = 630 ) [PackageQuantity] = 1 [ProductGroup] = Photography [ProductTypeName] = CAMERA_DIGITAL [ProductTypeSubcategory] = point-and-shoot [Publisher] = Canon [Studio] = Canon [Title] = Canon PowerShot SX20IS 12.1MP Digital Camera with 20x Wide Angle Optical Image Stabilized Zoom and 2.5-inch Articulating LCD [UPC] = 013803113662 )
my goal is to get only Feature infomation and I try to use
$feature = $parsed_xml->Items->Item->ItemAttributes->Feature
it does'not work for me because it just show me the first feature only. How do i get all feature information? please help
Hope I can explain this correctly.
I have a process, that outputs step by step messages (i.e., Processing item 1... Error in item 2 etc etc).
I want this to be outputted to the user during the process, and not at the end.
I pretty sure i need to do this with threading, but can't find a decent example.
Thanks in advanced.
Is it possible to pull the information on someone viewing someone else's profile? Would that app be leagal on Facebook? There are lot of "fake" apps like that exist now on Facebook. But can that be done really?