Search Results

Search found 138 results on 6 pages for 'amir rezaei'.

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

  • How to show that the double-checked-lock pattern with Dictionary's TryGetValue is not threadsafe in

    - by Amir
    Recently I've seen some C# projects that use a double-checked-lock pattern on a Dictionary. Something like this: private static readonly object _lock = new object(); private static volatile IDictionary<string, object> _cache = new Dictionary<string, object>(); public static object Create(string key) { object val; if (!_cache.TryGetValue(key, out val)) { lock (_lock) { if (!_cache.TryGetValue(key, out val)) { val = new object(); // factory construction based on key here. _cache.Add(key, val); } } } return val; } This code is incorrect, since the Dictionary can be "growing" the collection in _cache.Add() while _cache.TryGetValue (outside the lock) is iterating over the collection. It might be extremely unlikely in many situations, but is still wrong. Is there a simple program to demonstrate that this code fails? Does it make sense to incorporate this into a unit test? And if so, how?

    Read the article

  • objective c and NSDate

    - by Amir
    hello all, I am looking for component that can handle a spesific date. what i am trying to do is to get Astring fron sever that represent date(for example 04-08-2012) in my iphone i want to be able to "work" with this date. such to compare it to another date , check if the date in the past or future and to print it to the app GUI i tried work with NSDate but i didnt found how can i set a spesific date? thanks

    Read the article

  • objective c - memory managment

    - by Amir
    lets say I have aclass @interface Foo :NSobject { NSstring *a; NSDate *b; } Foo *temp; my question is: when i use [temp retain] does the counter of the members also retain? lets say that i got ref of the class from some method and i want to retain the class do i need to retain each member?

    Read the article

  • subscript for a join (\bowtie) operation in LyX/LaTeX

    - by Amir Rachum
    I'm using LyX to write some Relational Algebra queries. I'm using the \bowtie symbol for the join operation but when I try to put a text in subscript directly under the symbol, I get the following error: ...a_{\t{pId}}\t{person}\right)\bowtie\limits {\t{pId}{1}=\t{pId}_{2}... I'm ignoring this misplaced \limits or \nolimits command. Anyone knows how to do what I want? Preferably in LyX, but ERT code snippets will also be appreciated. Thanks! Edit: \t is a macro for \text.

    Read the article

  • Design for a Debate club assignment application

    - by Amir Rachum
    Hi all, For my university's debate club, I was asked to create an application to assign debate sessions and I'm having some difficulties as to come up with a good design for it. I will do it in Java. Here's what's needed: What you need to know about BP debates: There are four teams of 2 debaters each and a judge. The four groups are assigned a specific position: gov1, gov2, op1, op2. There is no significance to the order within a team. The goal of the application is to get as input the debaters who are present (for example, if there are 20 people, we will hold 2 debates) and assign them to teams and roles with regards to the history of each debater so that: Each debater should debate with (be on the same team) as many people as possible. Each debater should uniformly debate in different positions. The debate should be fair - debaters have different levels of experience and this should be as even as possible - i.e., there shouldn't be a team of two very experienced debaters and a team of junior debaters. There should be an option for the user to restrict the assignment in various ways, such as: Specifying that two people should debate together, in a specific position or not. Specifying that a single debater should be in a specific position, regardless of the partner. etc... If anyone can try to give me some pointers for a design for this application, I'll be so thankful! Also, I've never implemented a GUI before, so I'd appreciate some pointers on that as well, but it's not the major issue right now.

    Read the article

  • Proxy Issues with Javascript Cross Domain RSS Feed Parsing

    - by Amir
    This is my Javascript function which grabs an rss feed via the proxy script and then spits out the 5 latest rss items from the feed along with a link to my stylesheet: function getWidget (feed,limit) { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest() } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP") } xhttp.open("GET","http://MYSITE/proxy.php?url="+feed,false); xhttp.send(""); xmlDoc=xhttp.responseXML; var x = 1; var div = document.getElementById("div"); srdiv.innerHTML = '<link type="text/css" href="http://MYSITE/css/widget.css" rel="stylesheet" /><div id="rss-title"></div></h3><div id="items"></div><br /><br /><a href="http://MYSITE">Powered by MYSITE</a>'; document.body.appendChild(div); content=xmlDoc.getElementsByTagName("title"); thelink=xmlDoc.getElementsByTagName("link"); document.getElementByTagName("rss-title").innerHTML += content[0].childNodes[0].nodeValue; for (x=1;x<=limit;srx++) { y=x; y--; var shout = '<div class="item"><a href="'+thelink[y].childNodes[0].nodeValue+'">'+content[x].childNodes[0].nodeValue+'</a></div>'; document.getElementById("items").innerHTML += shout; } } Here is the the code from proxy.php: $session = curl_init($_GET['url']); // Open the Curl session curl_setopt($session, CURLOPT_HEADER, false); // Don't return HTTP headers curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // Do return the contents of the call $xml = curl_exec($session); // Make the call header("Content-Type: text/xml"); // Set the content type appropriately echo $xml; // Spit out the xml curl_close($session); // And close the session Now when I try to load this on any domain that's not my site nothing loads. I get no JS errors, but I in the Console tab in firebug I get "407 Proxy Authentication Required" So I'm not really sure how to make this work. The goal is to be able to grab the RSS feed, parse it to grab the titles and links and spit it out into some HTML on any website on the web. I"m basically making a simple RSS widget for my site's various RSS feeds. My Javascript is wack Also, I'm really a beginner with Javascript. I know jQuery pretty well, but I wasn't able to use it in this case, because this script will be embeded on any site and I can't really rely on the jQuery library. So I was decided to write some basic Javascript relying on the default XML parsing options available. Any suggestions here would be cool. Thanks! What's with the x and y They way my site creates RSS feeds is that the first title is actually the RSS feed title. The second title is the title of the first item. The first link is the link to the first item. So when using the javascript to get the title, I had to first grab the first title (which is the RSS title) and then start with the second title that being the first title of the item. Sorry for the confusion, but I don't think this is related to my issue. Just wanted to clarify my code.

    Read the article

  • Is a sharepoint developer technically "equipped" to do custom app dev and vise-versa?

    - by Amir
    This may be an opinion based question, but it's something that I wanted to ask (even if it does end up getting closed or deleted). I do custom app dev (asp.net/aspMVC) and have absolutely no knowledge about sharepoint and was wondering: If you have a "rock solid" custom app dev, asp.net/aspMVC web developer can he jump into sharepoint development fairly easily? What about the other way around? Does a seasoned sharepoint developer have the "chops" to do custom app dev using asp.net/aspMVC? By no means do I want to offend any sharepoint developers or any custom app dev developers. I'm merely trying to see how much knowledge you can take with you when going from one type of development to another.

    Read the article

  • Home_path issue with RoR testing locally on mobile device

    - by Amir
    When I use <%= link_to image_tag("foo.png"), home_path %> and display it on my localhost on my iPhone, it's broken. When I inspect on with firebug, the src of the image is http://localhost:3000/images/foo.png thus causing it to break on my iPhone. When I use <img src="/images/foo.png" /> it displays fine on my iPhone. I am pointing to the IP address of my PC running the server of my rails app in Safari. It's loading the text but all the css, JavaScript, and images are missing unless the path is absolute with using the rails default helpers. Is there a way to correct this path issue locally so it's absolute like /images/foo.png instead of http://localhost:3000/images/foo.png. Update CSS file paths are also affected. Instead of just making the path /stylesheets/foo.css, it's http://localhost:3000/stylesheets/foo.css. Update: Solution It's the Facebook plugin changing the asset host to the callback url of my facebook app settings which is currently set to http://localhost:3000/

    Read the article

  • Flash: Using mouse wheel events in full screen mode (Windows and Mac)

    - by Amir
    Although Flash has a mouse wheel event (MouseEvent.MOUSE_WHEEL), it comes with quite a few problems. The first is that the event is not yet supported on the Mac. So there are a bunch of solutions, all of which (basically) capture the mousewheel (or DOMMouseScroll) event in javascript and pass it into the flash app. Luckily, under all the Mac browsers I tested, this also works when flash is in fullscreen mode. Problem 2 is that flash ignores mouse wheel events with small "deltas". For example, Microsoft's IntelliPoint Mice with "Smooth Scroll" causes this problem. A solution to this is the same as the solution for the mac... i.e. capture the javascript mouse wheel event in the browser and pass it to the app. The issue is that of the browsers in windows that I tested (firefox, ie, safari, and chrome), they don't seem to capture this event when flash is in full screen mode. Does anyone know why or how to fix that? I currently have a hybrid solution that always takes events from javascript (in non-fullscreen or fullscreen mode) except when it's in fullscreen mode on Windows (at which point it takes them from the flash mousewheel event). So the only times it fails is in full screen mode on Windows with a mouse that has small deltas. Anyone have a full solution? Or just a better one?

    Read the article

  • How to make a report with count of type of cases in each month in Acess 2010

    - by amir shadaab
    I have a database is access with each record having a date and yes/no type columns for each record which shows which category the record comes under. I want to create a report which shows the types of cases in each month by taking a date range as a parameter through prompts. I have done the prompt part but I'm not sure how the query should be to show values for each month in that date range. Can someone please help me with this?

    Read the article

  • Standard Interfaces

    - by Amir Rachum
    I've used Java for some time and I keep hearing about interfaces such as Cloneable, Iterable and other X-ables. I was wondering if there is a list somewhere of all of these and more importantly - which ones do you regularly use day-to-day? For example, I've read that Cloneable is considered badly written and isn't widely used.

    Read the article

  • Smart search/replace in Vim

    - by Amir Rachum
    I have a file with the following expressions: something[0] Where instead of 0 there could be different numbers. I want to replace all these occurances with somethingElse0 Where the number should be the same as in the expression I replaced. How do I do that?

    Read the article

  • Is reverse engineering evil?

    - by Amir Arad
    Lately I've been pondering on how a specific beloved old game actually works. I had some mild progress, but then a friend pointed out that if I really loved the game and appreciate it, I wouldn't try to reverse-engineer it. Note that the game is long considered an abandonware and is offerd for download publicly in lawful game sites, and I have no commercial / other large scale intentions - just to learn and "mess around" with it. Did I miss something? Is there an ethical taboo regarding reverse-engeneering? Alternatively, is there a legal issue?

    Read the article

  • Pet project ideas in Java

    - by Amir Rachum
    I'm looking for a pet project idea in Java. I'm a Software Engineering undergraduate finishing my 3rd year. I have also been working for the past 1.5-2 years programming in C++, and I get enough of that at work. I recently learned Java and I like it very much. Already done some project assignments and some really small console applications, but I'm looking for something to invest my time in. I would like a project that is complex enough to "brag about" (have it open sourced and get people interested, added to resume) and learn while doing it, but also simple enough to be able to at least have a working version in a few months. I know the most common advice is something that I need, but I admit I simply couldn't think of anything like that. Any ideas?

    Read the article

  • Java Interfaces/Implementation naming convention

    - by Amir Rachum
    How do you name different classes / interfaces you create? Sometimes I don't have implementation information to add to the implementation name - like interface FileHandler and class SqlFileHandler. hen this happens I usually name the interface in the "normal" name, like Truck and name the actual class TruckClass. How do you name interfaces and classes in this regard?

    Read the article

  • Array of pointers in Objective-C using NSArray

    - by Amir
    Hello, I am writting program for my iphone and have a qestion. lets say i have class named my_obj class my_obj { NSString *name; NSinteger *id; NSinteger *foo; NSString *boo; } now i allocate 100 objects from type my_obj and insert them to array from type NSArray. then i want to sort the Array in two different ways. one by the name and the second by the id. i want to allocate another two arrays from type NSArray *arraySortByName *arraySortById what i need to do if i just want the sorted arrays to be referenced to the original array so i will get two sorted arrays that point to the original array (that didnt changed!) i other word i dont want to allocate another 100 objects to each sorted array.

    Read the article

  • objective c - release problem

    - by amir
    Hello, I have the following code: NSNumber *number = [NSNumber numberWithInt:5]; int i = [number retainCount]; [number release]; i = [number retainCount]; [number release]; i = [number retainCount]; the problem is that in line 2 , the value of parameter i is 2 and in line 4 the value is 1. then in line 6 the value is still 1.???????? first i dont understand why after init *number the retaincount is 2 and not 1?? second i dont understand why after release it 2 times retaincount is not 0? it doesnt matter how many times i release the object the retaincount stay 1.

    Read the article

  • Logger vs. System.out.println

    - by Amir Rachum
    Hi all, I'm using the PMD plugin for eclipse and it gives me an error when using System.out.println() with the explanation: System.(out|err).print is used, consider using a logger. My question is - What is a Logger? How is it used to print to the screen? Why is it better? Thanks.

    Read the article

  • How do Java mocking frameworks work?

    - by Amir Rachum
    This is NOT a question about which is the best framework, etc. I have never used a mocking framework and I'm a bit puzzled by the idea. How does it know how to create the mock object? Is it done in runtime or generates a file? How do you know its behavior? And most importantly - what is the work flow of using such a framework (what is the step-by-step for creating a test). Can anyone explain? You can choose whichever framework you like for example, just say what it is.

    Read the article

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