Search Results

Search found 77 results on 4 pages for 'itay moav'.

Page 2/4 | < Previous Page | 1 2 3 4  | Next Page >

  • using group_concat in PHPMYADMIN will show the result as [BLOB - 3B]

    - by Itay Moav
    I have a query which uses the GROUP_CONCAT of mysql on an integer field. I am using PHPMYADMIN to develop this query. My problem that instead of showing 1,2 which is the result of the concatenated field, I get [BLOB - 3B]. Query is SELECT rec_id,GROUP_CONCAT(user_id) FROM t1 GROUP BY rec_id (both fields are unsigned int, both are not unique) What should I add to see the actual results?

    Read the article

  • SharePoint Groups\Roles using FBA

    - by Itay
    Hi All, I'm running an FBA web app, having 2 Site collections. Currently I have a SharePoint group in one site collection, and I would like to assign permission to that group in the other site collection. Since SharePoint groups are site scoped, I thought using FBA roles.. Any words on how to do this, or if this it the recommended way? Thanks.

    Read the article

  • Creating a process in a non-zero session from a service in windows-2008-server?

    - by Itay Levin
    Hi, I was wondering if there is a simple way for a service to create a process in user session? My service is running as a user(administrator) account and not as a LocalSystem acount, therefore i can't use the WTSQueryUserToken function. i have tried calling OpenProcessToken(GetCurrentProcess,TOKEN_ALL_ACCESS,TokenHandle); but when i use this token to run CreateProcessAsUser(TokenHandle,.....) my process is still running in session 0. how can i resolve this issue? I'm using an Ole automation so i don't really care on which session the process will be running on, as long it is not the session 0 - because the Ole from some reason doesn't create its processes (winword.exe for instance) in session 0, but rather it creates them in other user sessions. Any suggestions will be welcome. Thanks in advance.

    Read the article

  • What IDE should I use to programm CPP on linux

    - by Itay Moav
    I need to start doing CPP (after 12 years) and do it on Ubuntu. What good IDEs are out there? Properties I look for in an IDE: project managment able to build project auto completion object browser+navigation (you click on an object/function name, and the ide sends you to the declaration) Any recommendations?

    Read the article

  • Cleaning all inline events from HTML tags

    - by Itay Moav
    For HTML input, I want to neutralize all HTML elements that have inline js (onclick="..", onmouseout=".." etc). I am thinking, isn't it enough to encode the following chars? =,(,) So onclick="location.href='ggg.com'" will become onclick%3D"location.href%3D'ggg.com'" What am I missing here? Edit: I do need to accept active HTML (I can't escape it all or entities is it).

    Read the article

  • UIImagePickerController, UIImage, Memory and More!

    - by Itay
    I've noticed that there are many questions about how to handle UIImage objects, especially in conjunction with UIImagePickerController and then displaying it in a view (usually a UIImageView). Here is a collection of common questions and their answers. Feel free to edit and add your own. I obviously learnt all this information from somewhere too. Various forum posts, StackOverflow answers and my own experimenting brought me to all these solutions. Credit goes to those who posted some sample code that I've since used and modified. I don't remember who you all are - but hats off to you! How Do I Select An Image From the User's Images or From the Camera? You use UIImagePickerController. The documentation for the class gives a decent overview of how one would use it, and can be found here. Basically, you create an instance of the class, which is a modal view controller, display it, and set yourself (or some class) to be the delegate. Then you'll get notified when a user selects some form of media (movie or image in 3.0 on the 3GS), and you can do whatever you want. My Delegate Was Called - How Do I Get The Media? The delegate method signature is the following: - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info; You should put a breakpoint in the debugger to see what's in the dictionary, but you use that to extract the media. For example: UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage]; There are other keys that work as well, all in the documentation. OK, I Got The Image, But It Doesn't Have Any Geolocation Data. What gives? Unfortunately, Apple decided that we're not worthy of this information. When they load the data into the UIImage, they strip it of all the EXIF/Geolocation data. Can I Get To The Original File Representing This Image on the Disk? Nope. For security purposes, you only get the UIImage. How Can I Look At The Underlying Pixels of the UIImage? Since the UIImage is immutable, you can't look at the direct pixels. However, you can make a copy. The code to this looks something like this: UIImage* image = ...; // An image NSData* pixelData = (NSData*) CGDataProviderCopyData(CGImageGetDataProvider(image.CGImage)); unsigned char* pixelBytes = (unsigned char *)[pixelData bytes]; // Take away the red pixel, assuming 32-bit RGBA for(int i = 0; i < [pixelData length]; i += 4) { pixelBytes[i] = 0; // red pixelBytes[i+1] = pixelBytes[i+1]; // green pixelBytes[i+2] = pixelBytes[i+2]; // blue pixelBytes[i+3] = pixelBytes[i+3]; // alpha } However, note that CGDataProviderCopyData provides you with an "immutable" reference to the data - meaning you can't change it (and you may get a BAD_ACCESS error if you do). Look at the next question if you want to see how you can modify the pixels. How Do I Modify The Pixels of the UIImage? The UIImage is immutable, meaning you can't change it. Apple posted a great article on how to get a copy of the pixels and modify them, and rather than copy and paste it here, you should just go read the article. Once you have the bitmap context as they mention in the article, you can do something similar to this to get a new UIImage with the modified pixels: CGImageRef ref = CGBitmapContextCreateImage(bitmap); UIImage* newImage = [UIImage imageWithCGImage:ref]; Do remember to release your references though, otherwise you're going to be leaking quite a bit of memory. After I Select 3 Images From The Camera, I Run Out Of Memory. Help! You have to remember that even though on disk these images take up only a few hundred kilobytes at most, that's because they're compressed as a PNG or JPG. When they are loaded into the UIImage, they become uncompressed. A quick over-the-envelope calculation would be: width x height x 4 = bytes in memory That's assuming 32-bit pixels. If you have 16-bit pixels (some JPGs are stored as RGBA-5551), then you'd replace the 4 with a 2. Now, images taken with the camera are 1600 x 1200 pixels, so let's do the math: 1600 x 1200 x 4 = 7,680,000 bytes = ~8 MB 8 MB is a lot, especially when you have a limit of around 24 MB for your application. That's why you run out of memory. OK, I Understand Why I Have No Memory. What Do I Do? There is never any reason to display images at their full resolution. The iPhone has a screen of 480 x 320 pixels, so you're just wasting space. If you find yourself in this situation, ask yourself the following question: Do I need the full resolution image? If the answer is yes, then you should save it to disk for later use. If the answer is no, then read the next part. Once you've decided what to do with the full-resolution image, then you need to create a smaller image to use for displaying. Many times you might even want several sizes for your image: a thumbnail, a full-size one for displaying, and the original full-resolution image. OK, I'm Hooked. How Do I Resize the Image? Unfortunately, there is no defined way how to resize an image. Also, it's important to note that when you resize it, you'll get a new image - you're not modifying the old one. There are a couple of methods to do the resizing. I'll present them both here, and explain the pros and cons of each. Method 1: Using UIKit + (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize; { // Create a graphics image context UIGraphicsBeginImageContext(newSize); // Tell the old image to draw in this new context, with the desired // new size [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; // Get the new image from the context UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); // End the context UIGraphicsEndImageContext(); // Return the new image. return newImage; } This method is very simple, and works great. It will also deal with the UIImageOrientation for you, meaning that you don't have to care whether the camera was sideways when the picture was taken. However, this method is not thread safe, and since thumbnailing is a relatively expensive operation (approximately ~2.5s on a 3G for a 1600 x 1200 pixel image), this is very much an operation you may want to do in the background, on a separate thread. Method 2: Using CoreGraphics + (UIImage*)imageWithImage:(UIImage*)sourceImage scaledToSize:(CGSize)newSize; { CGFloat targetWidth = targetSize.width; CGFloat targetHeight = targetSize.height; CGImageRef imageRef = [sourceImage CGImage]; CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); CGColorSpaceRef colorSpaceInfo = CGImageGetColorSpace(imageRef); if (bitmapInfo == kCGImageAlphaNone) { bitmapInfo = kCGImageAlphaNoneSkipLast; } CGContextRef bitmap; if (sourceImage.imageOrientation == UIImageOrientationUp || sourceImage.imageOrientation == UIImageOrientationDown) { bitmap = CGBitmapContextCreate(NULL, targetWidth, targetHeight, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpaceInfo, bitmapInfo); } else { bitmap = CGBitmapContextCreate(NULL, targetHeight, targetWidth, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpaceInfo, bitmapInfo); } if (sourceImage.imageOrientation == UIImageOrientationLeft) { CGContextRotateCTM (bitmap, radians(90)); CGContextTranslateCTM (bitmap, 0, -targetHeight); } else if (sourceImage.imageOrientation == UIImageOrientationRight) { CGContextRotateCTM (bitmap, radians(-90)); CGContextTranslateCTM (bitmap, -targetWidth, 0); } else if (sourceImage.imageOrientation == UIImageOrientationUp) { // NOTHING } else if (sourceImage.imageOrientation == UIImageOrientationDown) { CGContextTranslateCTM (bitmap, targetWidth, targetHeight); CGContextRotateCTM (bitmap, radians(-180.)); } CGContextDrawImage(bitmap, CGRectMake(0, 0, targetWidth, targetHeight), imageRef); CGImageRef ref = CGBitmapContextCreateImage(bitmap); UIImage* newImage = [UIImage imageWithCGImage:ref]; CGContextRelease(bitmap); CGImageRelease(ref); return newImage; } The benefit of this method is that it is thread-safe, plus it takes care of all the small things (using correct color space and bitmap info, dealing with image orientation) that the UIKit version does. How Do I Resize and Maintain Aspect Ratio (like the AspectFill option)? It is very similar to the method above, and it looks like this: + (UIImage*)imageWithImage:(UIImage*)sourceImage scaledToSizeWithSameAspectRatio:(CGSize)targetSize; { CGSize imageSize = sourceImage.size; CGFloat width = imageSize.width; CGFloat height = imageSize.height; CGFloat targetWidth = targetSize.width; CGFloat targetHeight = targetSize.height; CGFloat scaleFactor = 0.0; CGFloat scaledWidth = targetWidth; CGFloat scaledHeight = targetHeight; CGPoint thumbnailPoint = CGPointMake(0.0,0.0); if (CGSizeEqualToSize(imageSize, targetSize) == NO) { CGFloat widthFactor = targetWidth / width; CGFloat heightFactor = targetHeight / height; if (widthFactor > heightFactor) { scaleFactor = widthFactor; // scale to fit height } else { scaleFactor = heightFactor; // scale to fit width } scaledWidth = width * scaleFactor; scaledHeight = height * scaleFactor; // center the image if (widthFactor > heightFactor) { thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5; } else if (widthFactor < heightFactor) { thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5; } } CGImageRef imageRef = [sourceImage CGImage]; CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); CGColorSpaceRef colorSpaceInfo = CGImageGetColorSpace(imageRef); if (bitmapInfo == kCGImageAlphaNone) { bitmapInfo = kCGImageAlphaNoneSkipLast; } CGContextRef bitmap; if (sourceImage.imageOrientation == UIImageOrientationUp || sourceImage.imageOrientation == UIImageOrientationDown) { bitmap = CGBitmapContextCreate(NULL, targetWidth, targetHeight, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpaceInfo, bitmapInfo); } else { bitmap = CGBitmapContextCreate(NULL, targetHeight, targetWidth, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpaceInfo, bitmapInfo); } // In the right or left cases, we need to switch scaledWidth and scaledHeight, // and also the thumbnail point if (sourceImage.imageOrientation == UIImageOrientationLeft) { thumbnailPoint = CGPointMake(thumbnailPoint.y, thumbnailPoint.x); CGFloat oldScaledWidth = scaledWidth; scaledWidth = scaledHeight; scaledHeight = oldScaledWidth; CGContextRotateCTM (bitmap, radians(90)); CGContextTranslateCTM (bitmap, 0, -targetHeight); } else if (sourceImage.imageOrientation == UIImageOrientationRight) { thumbnailPoint = CGPointMake(thumbnailPoint.y, thumbnailPoint.x); CGFloat oldScaledWidth = scaledWidth; scaledWidth = scaledHeight; scaledHeight = oldScaledWidth; CGContextRotateCTM (bitmap, radians(-90)); CGContextTranslateCTM (bitmap, -targetWidth, 0); } else if (sourceImage.imageOrientation == UIImageOrientationUp) { // NOTHING } else if (sourceImage.imageOrientation == UIImageOrientationDown) { CGContextTranslateCTM (bitmap, targetWidth, targetHeight); CGContextRotateCTM (bitmap, radians(-180.)); } CGContextDrawImage(bitmap, CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledWidth, scaledHeight), imageRef); CGImageRef ref = CGBitmapContextCreateImage(bitmap); UIImage* newImage = [UIImage imageWithCGImage:ref]; CGContextRelease(bitmap); CGImageRelease(ref); return newImage; } The method we employ here is to create a bitmap with the desired size, but draw an image that is actually larger, thus maintaining the aspect ratio. So We've Got Our Scaled Images - How Do I Save Them To Disk? This is pretty simple. Remember that we want to save a compressed version to disk, and not the uncompressed pixels. Apple provides two functions that help us with this (documentation is here): NSData* UIImagePNGRepresentation(UIImage *image); NSData* UIImageJPEGRepresentation (UIImage *image, CGFloat compressionQuality); And if you want to use them, you'd do something like: UIImage* myThumbnail = ...; // Get some image NSData* imageData = UIImagePNGRepresentation(myThumbnail); Now we're ready to save it to disk, which is the final step (say into the documents directory): // Give a name to the file NSString* imageName = @"MyImage.png"; // Now, we have to find the documents directory so we can save it // Note that you might want to save it elsewhere, like the cache directory, // or something similar. NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* documentsDirectory = [paths objectAtIndex:0]; // Now we get the full path to the file NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imageName]; // and then we write it out [imageData writeToFile:fullPathToFile atomically:NO]; You would repeat this for every version of the image you have. How Do I Load These Images Back Into Memory? Just look at the various UIImage initialization methods, such as +imageWithContentsOfFile: in the Apple documentation.

    Read the article

  • Dependency injection: Scoping by region (Guice, Spring, Whatever)

    - by Itay
    Here's a simplified version of my needs. I have a program where every B object has its own C and D object, injected through Guice. In addition an A object is injected into every C and D objects. What I want: that for each B object, its C and D objects will be injected with the same A object. Specifically, I want the output of the program (below) to be: Created C0 with [A0] Created D0 with [A0] Created B0 with [C0, D0] Created C1 with [A1] Created D1 with [A1] Created B1 with [C1, D1] Where it currently produces the following output: Created C0 with [A0] Created D0 with [A1] <-- Should be A0 Created B0 with [C0, D0] Created C1 with [A2] <-- Should be A1 Created D1 with [A3] <-- Should be A1 Created B1 with [C1, D1] I am expecting DI containers to allow this kind of customization but so far I had no luck in finding a solution. Below is my Guice-based code, but a Spring-based (or other DI containers-based) solution is welcome. import java.util.Arrays; import com.google.inject.*; public class Main { public static class Super { private static Map<Class<?>,Integer> map = new HashMap<Class<?>,Integer>(); private Integer value; public Super(Object... args) { value = map.get(getClass()); value = value == null ? 0 : ++value; map.put(getClass(), value); if(args.length > 0) System.out.println("Created " + this + " with " + Arrays.toString(args)); } @Override public final String toString() { return "" + getClass().getSimpleName().charAt(0) + value; } } public interface A { } public static class AImpl extends Super implements A { } public interface B { } public static class BImpl extends Super implements B { @Inject public BImpl(C c, D d) { super(c,d); } } public interface C { } public static class CImpl extends Super implements C { @Inject public CImpl(A a) { super(a); } } public interface D { } public static class DImpl extends Super implements D { @Inject public DImpl(A a) { super(a); } } public static class MyModule extends AbstractModule { @Override protected void configure() { bind(A.class).to(AImpl.class); bind(B.class).to(BImpl.class); bind(C.class).to(CImpl.class); bind(D.class).to(DImpl.class); } } public static void main(String[] args) { Injector inj = Guice.createInjector(new MyModule()); inj.getInstance(B.class); inj.getInstance(B.class); } }

    Read the article

  • Is there a simple way to emulate friendship in php 5.3

    - by Itay Moav
    I need some classes to befriend other classes in my system. Lack of this feature made me publicize some methods which shouldn't be public. The consequences of that are that members of my team implement code in a bad and ugly way which causes a mess. Is there a way to define a friendship in php 5.3? (I am aware of http://bugs.php.net/bug.php?id=34044 You might want to vote there if there is no simple solution).

    Read the article

  • I get 2014 Cannot execute queries while other unbuffered queries are active when doing exec with PDO

    - by Itay Moav
    I am doing a PDO::exec command on multiple updates: $MyPdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true); $MyPdo->exec("update t1 set f1=1;update t2 set f1=2"); I am doing it inside a transaction, and I keep getting: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. those are the only query/ies

    Read the article

  • Parsing external XML file with C#, what's the most aesthetic way?

    - by Itay
    Hi, say there is an xml file, which not created by me, with a known schema (for example, rss). how would you parse it with C#? would you do that manually by XDocument etc, or would you use XMLSerializer and create a correspond class? or would you use Visual Studio tools to generate classes using a dtd file (that you'll write). what do you think the most aesthetic, easy, not error-prone way?

    Read the article

  • How to remove JQuery from the Window/make the GC take it.

    - by Itay Moav
    I have a page, when loaded it does some stuff with JQ. In the next phase I want to load mootools and remove all JQ stuff, to avoid collisions and to avoid memory leaking. I am not giving you the all picture (to simplify the question), but assume I am not doing something stupid here, and it needs to be done how I am asking it.

    Read the article

  • Tomcat: Cache-Control

    - by Itay
    Jetty has a CacheControl parameter (can be specified webdefault.xml) that determines the caching behavior of clients (by affecting headers sent to clients). Does Tomcat has a similar option? In short, I want to turn off caching of all pages delivered by a tomcat server and/or by a specific webapp?

    Read the article

  • A good approach to db planing for reporting service

    - by Itay Moav
    The scenario: Big system (~200 tables). 60,000 users. Complex reports that will require me to do multiple queries for each report and even those will be complex queries with inner queries all over the place + some processing in PHP. I have seen an approach, which I am not sure about: Having one centralized, de-normalized, table that registers any activity in the system which is reportable. This table will hold mostly foreign keys, so she should be fairly compact and fast. So, for example (My system is a virtual learning management system), A user enrolls to course, the table stores the user id, date, course id, organization id, activity type (enrollment). Of course I also store this data in a normalized DB, which the actual application uses. Pros I see: easy, maintainable queries and code to process data and fast retrieval. Cons: there is a danger of the de-normalized table to be out of sync with the real DB. Is this approach worth considering, or (preferably from experience) is total $#%#%t?

    Read the article

  • Eclipse Plugin: Enablement of an Action based on the current selection

    - by Itay
    I am using the org.eclipse.ui.popupMenus extension point for adding a sub-menu whose Action that is bounded to the following class: public class MyAction implements IObjectActionDelegate { private Logic logic = Logic.getInstance(); // Singleton public void setActivePart(IAction a, IWorkbenchPart targetPart) { // Nothing here } public void run(IAction a) { // Do something... } public void selectionChanged(IAction a, ISelection s) { a.setEnabled(logic.isEnabled(s)); } } This action is working correctly in most cases (including the call a.setEnabled() in selectionChanged()). My problem at the very first time my action is being invoked. The selectionChanged method is called only after the menu item has been displayed (and not when the user has made the selection) which means that the call to a.setEnabled() will have no affect. Any ideas on how to make my action receive selectionChanged() notifications even before the fist time it is being invoked?

    Read the article

  • How should I architect JasperReports with a PHP front+backend system

    - by Itay Moav
    Our system is written completely in PHP. For various business reasons (which are a given) I need to build the reports of the system using JasperReports. What architecture should I use? Should I put the Jasper as a stand alone server (if possible) and let the php query against it, should I have it generate the reports with a cron, and then let the PHP scoop up the files and send them to the web client/browser...

    Read the article

  • Algorithm to suggest a list of tags to users

    - by Itay Moav
    Given a free text, I need to analyse this this text and suggest a list of tags from a pre existing list. What algorithms are out there in the market? Can they handle a case where, for example, the text have a word like high cholesterol and I would like it so suggest heart disease although "high cholesterol" might not exists (initially) in the pre defined list.

    Read the article

  • Mysql's LIKE is missbehaving with Hebrew and backslashes, why?

    - by Itay Moav
    I have the following SQL query which returns the correct results: SELECT * FROM `tags` WHERE tag_name = '???\\\"?-???????' If I change it to SELECT * FROM `tags` WHERE tag_name LIKE '???\\\"?-???????' or to SELECT * FROM `tags` WHERE tag_name LIKE '???\\\"?-???????%' It doesn't work. It will work if I remove all the backslashes and " from the query.

    Read the article

< Previous Page | 1 2 3 4  | Next Page >