instruction_seed
stringlengths
1
35.8k
_source
stringclasses
1 value
There are helpers in Ruby on Rails to convert numbers to human terms, like 1024KB can be converted to 1MB. Is there a method to reverse it? I want to convert 6.3K to 6300, 6.3L 6300000, etc.
stackexchange/codereview
I want to make two different headers for my WordPress project, so the frontpage will display differently than the rest of the pages. I would do it with an if/else statement, but it seems that the last part of the string is being ignored. What could trigger this? The code looks like this and links to two id's in a separ...
stackexchange/codereview
I am currently evaluating if a c/c++ library may be used for a specific iPhone project of mine. The original library makes heavy use of windows specific code (for example it includes windows.h and winsock.h). I am aware that I will have to rewrite the parts that use windows specific code and replace winsocks with for e...
stackexchange/codereview
I am having problem printing a particular variable from my cgi file. I receive this variable, called totalCost from my webpage and then try to print it, but nothing happens. All the other variables can be received successfully from the webpage and printed out on another webpage via my cgi file, except for this one..i'v...
stackexchange/codereview
I am using "loadDataWithBaseUrl(...)" to load a html file, stored in assets, to Webview. that contains a string "Loading..." and a rotating GIF. String "Loading..." is hard coded, and it'll not be localized. How to replace that string dynamically, so that it can be localized? Please help me to resolve this.
stackexchange/codereview
I would like to be able to do this: X<int> type_0; X<int> type_1; and I would like for type_0 and type_1 to be two different types. How can I do it?
stackexchange/codereview
It seems encodeURIComponent is only allowed in AS 3, but because I'm using Flash Lite 3.1 I have to use AS 2. Any ideas for an alternative?
stackexchange/codereview
After OAuth with facebook , how do I get the graph of the pages created by user? I search over the documentation and event search inside the callback that facebook send me after the OAuth , I still can't get the pages that the user create , I have to use FQL for this? And how do I use FQL in rails?
stackexchange/codereview
I am using part of boost for a project (only the message_queue). If I use native code, the hpp file is fine. But I need the message queue in a LLVM bitcode file (I'm executing the bitcode in my program) and get the following error: LLVM ERROR: Program used external function 'shm_unlink' which could not be resolved! ...
stackexchange/codereview
We have an application which is multi-tenant (lots of users all accessing their own data, similar to something like Basecamp). Question is, what is the simplest and easiest way in Rails to ensure that users can only see their own accounts data? Is it a case of going and checking every single query?
stackexchange/codereview
I'm writing my own syntax highlighter in javascript for fun and see a couple of approaches but they both have pros and some pretty serious cons that I can't get around. What do you guys think about these approaches and are there better methods that I'm missing? Assumption Code to highlight exists in a single string. ...
stackexchange/codereview
Hi I have a MySQL database table where a user inputs messages (via a form) and I was wondering if there is a way to automatically delete a message after say 1 minute has passed? The code i'm using is PHP. Thanks very, very much for any replies :)
stackexchange/codereview
I basically want to keep a track of old filenames and each file's new filename. I could use a Dictionary I suppose, but I want to keep it really lightweight. Would a multidimensional string array work just as well?
stackexchange/codereview
Hi I know its algorithm ,is there any code in java for it?there is a code for quick hull in java but there is not any code for this one ,is there? thanks
stackexchange/codereview
I have got a JFrame A und 2 JInternalFrame B und C. I want to show these two Frames B and C in a JPanel, rather than a JInternalFrame. Then i will put the jpanel to another Frame. So B and C both will be shown as own JFrame. So my question is: How can i move JInternalFrame components to JPanel? Thanks
stackexchange/codereview
it is possible to set the orientation of an activity in the manifest file. but is it also possible to do it from code? if so, how? thanks!
stackexchange/codereview
i have a start point and a end point. I want to work out the angle i have this formula that seems to work double dx = end.X - start.X; double dy = end.Y - start.Y; double degrees = Math.Acos((-Math.Pow(dy, 2) + Math.Pow(dx, 2) + Math.Pow(dx, 2)) / (2 * Math.Pow(dx, 2))); degrees = degrees * 180 / Math.PI; Then i want...
stackexchange/codereview
I'm using Devise 1.0.8 on a Rails 2.3.8 project. In my controller test I have: context "when current_user is admin" do should "render" do sign_in Factory(:admin) get :index assert_response :success end end And in the controller itself, there's the following before_filter: def redirect_if_not_admin p...
stackexchange/codereview
I would like to use PortAudio library to play audio data. This audio data comes from UDP paquets. I saw there is Pa_OpenDefaultStream() (and Pa_OpenStream() which is pretty similar) function to open a stream : PaStream *stream; PaError err; /* Open an audio I/O stream. */ err = Pa_OpenDefaultStream( &stream, ...
stackexchange/codereview
I have 3 image resources in my app. Loading and displaying any one of them in an ImageView goes smoothly. But when I remove the displayed ImageView from the layout, null it and add a new image, things get weird. Either the process crashes completely (signal 11) when I try calling .recycle() on the old bitmap or I get a...
stackexchange/codereview
For business purpose, I need to get in touch with CRM 2011 (cf. 5.0) and TFS 2010 then try to see whether they can be integrated together or not. I've read something about TFS 2008 and CRM 2009 but couldn't find input related to CRM 2011 and TFS 2010. Any suggestion, tip, pointer, trick, highlight... is welcome :)
stackexchange/codereview
I want to test a method that calls the pylons.url object. However calling this in the tests leads to an error: TypeError: No object (name: url) has been registered for this thread So I'd like to replace the pylons.url object with a Mock from the mock library. @patch('pylons.url') def my_test(self, url_mock): ... ...
stackexchange/codereview
In winforms I usually do Parent.Controls.Remove(this); to have a UserControl remove itself. This isn't working for wpf. My control has button on it to remove the whole UserControl, any ideas how to accomplish this in wpf? Thanks in advance
stackexchange/codereview
Myself shweta dodiya.I am having an problem related to sensor and logic in j2me which i had implemented for achieving the result in my project.The logic which i had implemented is as follows:- sensor= (SensorConnection) Connector.open("sensor:acceleration"); try { data = sensor.getData(1); ...
stackexchange/codereview
I want to use data structure that serves like .Net HashSet, I tried to use unordered_set with the default hashing method and custom comparer as follows: struct comparer { bool operator()( const TCHAR* first,const TCHAR* second) const { return _tcscmp((TCHAR*)first,(TCHAR*)second) == 0...
stackexchange/codereview
I'm currently working on an application with a lot of javascript code. I'm writing inline javascript code on every of the pages/partials, however most of the code is re-utilized somewhere else. I'm trying to figure a way to refactor these little scripts into something more convenient and maintainable. I'm using jQuery,...
stackexchange/codereview
i am using this code to know how to get google images from my site..actually the problem is i am not getting google images to array from my server. i am getting an empty array. i was run this code in my localhost. it is working fine. but not in my server. getting 403forbidden error. in this page downloadimagesfromgoogl...
stackexchange/codereview
I am try to write a php script that return the device from the user agent in the header. the problem that i see that is not simple to do a regular expression, because the different between the device (am i wrong?) so i want an updated list of mobile device according to the user agent I found this list : List of user...
stackexchange/codereview
I'm solving the coding problems on codingbat in Python. The make_bricks problem is defined as: We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return True if it is possible to make the goal by choosing from the g...
stackexchange/codereview
say i have a column defined as Address. also, I have a record, let's call it Rudy's. now Rudy's has multiple addresses, so I need to include multiple address so that they are all searchable. what is the best way to approach a solution in SQL?
stackexchange/codereview
I just opened a webpage in safari and what did I see? The whole text was green? But I only make the captions green, so the regular text should be black? Then I thought: Well I programmed this site in Firefox. At first I thought it was a bad interpretation by Safari but I reviewed my code again and I saw this: <h3>Capti...
stackexchange/codereview
I am using VB6 DLL in ASP.Net web site, when I add the reference of VB6 DLL it got added as a Interop.X.DLL and it compiled and executed properly. But when I published the website on Windows Server 2003 with IIS 6.0 and executed it gives the error "Retrieving the COM class factory for component with CLSID {82EA3A98-AD...
stackexchange/codereview
I'm trying to merge 2 PDF, one on my server (not dynamically generated) and one generated just before the merge and not saved anywhere on the server (I just want my client to download it). So I only have the pdf's content. Both PDF have the same format (A4). The merged file will have 2 pages and won't be saved on serve...
stackexchange/codereview
I've built a few minor projects using PHP on the backend, but I'm worried about applying for PHP jobs because I don't know if I've really got a good feel for the language. The projects I've built have been mostly just CRUD - manipulating records in a database and dumping info on screen. I'm sure there's more to PHP tha...
stackexchange/codereview
Do you know of an official list of supported countries that thare allowed to sell paid applications via Apple AppStore, please? I am interested in Slovakia (Slovak Republic) Yesterday, I tried to join Standard iOS Developer program, but in the middle of the registration process, I received a message saying that there a...
stackexchange/codereview
am I correct assuming that if a different process updates the DB then my NHibernate powered application will be out-of-sync? I'm almost using non-lazy update. My target DB is mysql 5.0, if it makes any difference.
stackexchange/codereview
Неllо. I develop system that works with stock exchange(system, below). And there is a lot of information my program need to interact with this system. This system has formal declared interface, but different details beside this declaration and requirements to my system is often changed. So how can I organize availabl...
stackexchange/codereview
string NewsFillter = string.Empty; List<string> PublishDatePostMeta = (from post in postrepository.GetAllPosts() join pstmt in postrepository.GetAllPostMetas() on post.int_PostId equals pstmt.int_PostId where (post....
stackexchange/codereview
I have an ASMX web service which has a method - void DoSomething(List<string> list); I have implemented this service, compiled and hosted in IIS. I used wsewsdl3.exe to generate the proxy. In the generated proxy the method definition is changed to - DoSomething(string[] list) { .. Is it not possible to have List as...
stackexchange/codereview
I have some entries that are inconstant, they should be prepended by the same string. some have numbers and other have the dollar sign and the number so I have a syntax that finds all the entries which do not have the dollar sign WHERE [mydata] not like '$%' how do I add the string before each entry?
stackexchange/codereview
I'm trying to change the color of the dropdown arrow in the Sharepoint 2010 Welcome control, that looks like this: <wssuc:Welcome id="IdWelcome" runat="server" EnableViewState="false"> I've found the classes to color everything else, but can't change the little down arrow. How do I do this?
stackexchange/codereview
I created a DatePickerPreference, i.e. I extended DialogPreference and created a DatePicker object inside and had it working almost perfectly. It changes values when you click the arrows up and down and saves the value you select. However, if you click inside the field and types the new value there, it doesn't save the...
stackexchange/codereview
what is other difference than performance ? cheers, /Marcin
stackexchange/codereview
How can I exclude all the svn metadata while synchronizing with unison?
stackexchange/codereview
Here is the problem. I want to open a file from local drives, then make it into a WritableBitmap so i can edit it. But the problem is, i cannot create a WritableBitmap from Uri or something like that. Also i know how to open a file into BitmapImage but i cannot figure out how to open a file as WritableBitmap. Is there ...
stackexchange/codereview
Is this possible? I can't work out how to do it.
stackexchange/codereview
i am new at openlayers and i want to learn how can i add pan zoom bar like http://maps.cloudmade.com/ zoombar. it shows some tag as building , country etc. when you on this pan...
stackexchange/codereview
I have an application which involves building rich text character by character in order to undo it all at once. In order to retain that character's formatting, I select it and then can add the SelectedRtf property to my StringBuilder, however I want to be able to build each Rich Text character into one Rich Text string...
stackexchange/codereview
Imagine you wanted to serialize and deserialize stackoverflow posts including their tags as space efficiently as possible (in binary), but also for performance when doing tag lookups. Is there a good datastructure for that kind of scenario? Stackoverflow has about 28532 different tags, you could create a table with al...
stackexchange/codereview
If you go to newegg.com (just one example) you'll notice while browsing products you can see the number of items next to each product attribute in the left hand sidebar. With so many attributes on some items and so many different configurations of product filters how do they calculate all of those totals so fast?
stackexchange/codereview
I am extending TextField to create my own implementation of it, and there are some properties & methods I would like to simply remove from use, eg: override public function setTextFormat(format:TextFormat,[...]):void{} I would like now to hide setTextFormat from code hinting, so when, in some other class, I type: var...
stackexchange/codereview
I'm new to Cassandra. I'm not getting how to update a particular column in Cassandra related to a particular user. For example I want to update the location of a user in a user column family.
stackexchange/codereview
Need help to implement Accelerometer Sensor to an Image. How to move an image according to the device moving(rotation)?
stackexchange/codereview
Is it possible to retrieve the contacts without using Activity class? I'm using LWUIT for developing android application. I need to retrieve the contacts from android phonebook. How its possible? Because normally retrieve contacts process achieved in inside of extend Activity class. ( I seen some examples). In LWUIT, T...
stackexchange/codereview
I have written a script that takes an XML feed of some news, and inserts each news story as a post into WordPress using wp_insert_post(). Each of these news stories has a category that I would like to add to WordPress also. My question is, how can I create NEW categories on the fly and assign the post to that category ...
stackexchange/codereview
I am parsing an XML file, ion which data is in "Portugese" language. data is getting parsed successfully but its not returnong the data as expected, Example=> I am parsing string "Próximo GP" and it is returning me "óximo GP". Its is trimming the first two letters. same problem I am having in other strings. What should...
stackexchange/codereview
I have a mysql table like that and i need to run a query which will output the following result what will be mysql query for that?any suggestions please?
stackexchange/codereview
What do you think brings more value to the product, Unit Test or Exploratory Test? I understand that both tests serve different general purposes, but what test would you prioritize, i.e. what would you do first and what second, Unit or Exploratory? Also, which one pays more benefits in the short term? and in the long t...
stackexchange/codereview
I have to target Windows, MacOS, iOS and Android. My plan was to create separate applications for each platform. However, I am now considering making an HTML5 website (that has different presentations based upon the device being used). I can create a wrapper for each platform. Windows can include a Webkit control, iOS ...
stackexchange/codereview
i try to make a kind of "sql distinct" request with core data, so i set up my NSFetchrequest like this NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; [fetchRequest setEntity:[NSEntityDescription entityForName:@"my_table" inManagedObjectContext:managedObjectContext]]; [fetchRequest setResultType:NSDict...
stackexchange/codereview
I need a method that searches in listbox and highlight all the words that equal the searched word. Can someone help me?
stackexchange/codereview
im getting the following exception for use into a master page the helper html.renderpartial(). This works on mvc views that uses this master page, but im trying to execute an old aspx webform page that uses the same masterpage. And here comes following exception: A ViewMasterPage can be used only with content pages tha...
stackexchange/codereview
Is there a good free printer driver for printing something to PNG (or maybe even SVG) for Windows (I use 7 64bit)? I've got this site with some statistics and it displays this cool graph. It's got an embed feature, but that's using flash. I want to put this graph on my blog, but I don't want to use flash for mobile bro...
stackexchange/codereview
I'm just curious how they make apps like Fat Booth for the iPhone? I've been learning/developing iphone apps for the last couple of months but have never ventured into anything image/photo/game based, how on earth do you do image manipulation within objective c? Is it with similar libraries to Cocos 2D or something?
stackexchange/codereview
I have a class library and I would like to have some of the configurations stored in an App.config, which would be placed in the same project. I tried reading the configuration using: ConfigurationManager.AppSettings["ABC"]; and it doesnt fetch me any value. It would be great if you can let me know how I can read my Ap...
stackexchange/codereview
How to insert Page Break in RichTextBox? Thanks!
stackexchange/codereview
In my application, I used a library that displays ads in my app. When a user clicks on the ad, it launches the Browser app, and the onClick events are handled by the library itself. I also have a placed code in onPause() and onStart() methods that detects whether any of my Activities are sent to background (user presse...
stackexchange/codereview
This might not be exactly what you're thinking. I have a UITabBar app, with three tabs, all of which are linked to separate UIViews. On the first UIView (the default launch view) I have a search form. This view does not have a UINavigationController (as it's not wanted on this page). When the user clicks search, I want...
stackexchange/codereview
i try to make a post request, witch contains a file, the problem is, i have to use ssl and the BasicCredentialprovider. The following code works for me with normal POST requests: (url is the url, nvps is the nameValuePair) DefaultHttpClient http = new DefaultHttpClient(); SSLSocketFactory ssl = (SSLSocketFacto...
stackexchange/codereview
I want to iterate through all vertices of a CGAL::Delaunay_triangulation_2, but am unable to find documentation about getting all the vertex handles. The documentation I found for this explained how to iterate through the triangulation. typedef CGAL::Delaunay_triangulation_2<K> T; typedef T::Vertex_handle Vh; typedef T...
stackexchange/codereview
Given var re = new Regex(@"(?<name>\w+)(x)\1\2"); Console.WriteLine(re.IsMatch("yxxy")); Prints True, it appears unnamed capturing groups are numbered starting with 1, and then named capturing groups are assigned numbers afterwords. Is this correct/intended behaviour?
stackexchange/codereview
i am getting this error while executing below code @crc=0xFFFFFFFF @index=0 7.times { |n| @index+=@crc**@a[n] @crc=@crc >> 8 puts @crc **@crc=@crc**@reverse_crc[@index]** - this is the line i am getting above error while execute puts @crc } any one have solution for this problem?
stackexchange/codereview
Is it possible to launch (redirect the user to) the native photo gallery application of iphone from my app, similar to emails? Is this now possible in 4.2 sdk?
stackexchange/codereview
I'm working on some ftl templates and email addresses are coming through as links, specifically on mobile browsers and in Outlook. Anyone know how to block this from happening? Thanks in advance! Note: I am not adding them as links, just the email itself.
stackexchange/codereview
I write the following code on my main form to show the help file when i click on F1. This works fine but i am getting it as maximized i don't want this and also only after selecting the contents on the opened one i am able to see the contents by default i am unable to view My code is as follows private void frmMain...
stackexchange/codereview
How can I configure logging for maven build? The log which maven generates is not providing enought information like time stamp with each log statement. Where/what log config file maven uses?
stackexchange/codereview
The MSDN Docs says If the operation raises an exception that your code does not handle, the BackgroundWorker catches the exception and passes it into the RunWorkerCompleted event handler, where it is exposed as the Error property of System.ComponentModel.RunWorkerCompletedEventArgs But when I tried _workers[i].DoWo...
stackexchange/codereview
I have a SQLite database for my Qt application. I assume that it would be logical to add the database as a resource. I can't get my app to compile with the embedded resource. connection.h #ifndef CONNECTION_H #define CONNECTION_H #include <QMessageBox> #include <QSqlDatabase> #include <QSqlError> #include <QSqlQuery...
stackexchange/codereview
I'm trying to create a wrapper to a maven plugin that I found in the internet. My wrapper should do some work than call the execute on the original plugin's goal. The examples I saw so far instantiate the other plugin, set all the variables, than call the execute method. I don't want to do this (if I can avoid it) beca...
stackexchange/codereview
Lets say I have a script, "myscript.sh", with contents being simply echo $PWD. I'd like to bind somehow this script to a key combo in bash (gnome-terminal) - so that when I press this key combination, the output of "myscript.sh" is inserted ("pasted") at the cursor position in the terminal. Apparently, bash history an...
stackexchange/codereview
Considering these structures on 64 bits : struct base { long a; }; struct derived : public base { long b; char c; }; I get a size of 24 and a padding warning but I don't understand why. For me, data with this kind of inheritance are aligned like that a b c So a is aligned on 8, b too and c is a char and is ali...
stackexchange/codereview
I need to build a simple desktop app, my experience is with vb6 but it's time to move on, so i need some help. My app is relatively simple, a db table that holds events by date. The app should display the events on a full screen in the following structure: first line - todays events, a single event every time, rotatin...
stackexchange/codereview
I have the following code in my template: <form action="" method="post">{% csrf_token %} {%for category, category_votes in votes%} <p>{{category}}: {{category_votes}} <!-- displays as expected --> <input type="hidden" name="votedCat" value="{{category}}" id={{forloop.counter}}> ...
stackexchange/codereview
http://jsfiddle.net/JeaffreyGilbert/VkghS/ Currently sorting between rows can be done by dragging barWrap (grey). To move gantt bar can be done by dragging the bar. What I want is sorting and moving can be done at once by dragging the bar. How to achieve this? Any helps would be appreciated, thank you.
stackexchange/codereview
Given concrete classes and interfaces having names that don't match Harvester_JohnDeere_Parsley : AbstractMachine, IParsleyHarvester Harvester_NewHolland_Sage : AbstractMachine, ISageHarvester Harvester_Kubota_Rosemary : AbstractMachine, IRosemaryHarvester where the interfaces have a common parent IParsleyHarvester : ...
stackexchange/codereview
I have the following javascript variable: <script> var theme="Videocameras"; </script> And the following html code: <div> <span>Tecnology</span> <ul id="menu"> <li> <a href="#">Multimedia</a> <ul> <li> <a href="#">Videocameras</a> ...
stackexchange/codereview
i have a scrollview ,it include one textView, the textView have many lines,in other word the textView entire screen size, if i want to see all strings in the textView,i need scroll the scrollbar,but i donot want to so,i want the textView or the screen automatic moving upwards interval for a period of time ,so that d...
stackexchange/codereview
Maybe it's just me, but i've encountered strange bug developing some swing UI in NetBeans. Here is the situation - i've made all needed GUI classes (mostly as designer forms) in some separate sandbox project and now i want to attach them to main sources. When i try to copy those classes (really, a whole package) to my ...
stackexchange/codereview
I have been doing some reading lately about Exception Handling and the .Net Framework and this seems to have left me more confused then when I started. In CLR via C# Fourth Addition I Read: Also, the .NET Framework exception-handling mechanism is built using the Structured Exception Handling (SEH) mechanism off...
stackexchange/codereview
I'm using iTextSharp to load an existing PDF and adding text using the PdfStamper. I want full control over the text, meaning I want to be able to control the font (only TrueType), font size and coordinates. Right now, I'm using ShowTextAligned to add text to certain coordinaties and setFontAndSize to set the font and ...
stackexchange/codereview
Possible Duplicate: How do I convert hex string into signed integer? example:"3A" convert to 0x3A,thanks a lot!
stackexchange/codereview
I have an xml object. I could loop through it this way to get values of following of its properties. I require to store these into database in a parent child relation. foreach ($xml->entry as $status) { echo $status->author->name.''$status->content.''.$status->id; } Depth of the tree is not finite. Also An examp...
stackexchange/codereview
MYSQL and apache server are already installed on my server. But still I encountered these problem. I dont understand the terms to compile php with --with-mysql Where should i compile? i am using window server. or how to install the mysql.so module?? Checking environment... Please include all of the lines below when ...
stackexchange/codereview
Is there any way in Crystal Reports(v11, if this matters) to prevent the images from stretching itself to fit in the whole OLE-object? I'm loading the images dynamically from a database and don't know their aspect ratio. Thanks for help.
stackexchange/codereview
I'm trying to get an if statement to work in Bash (using Ubuntu): #!/bin/bash s1="hi" s2="hi" if ["$s1" == "$s2"] then echo match fi I've tried various forms of the if statement, using [["$s1" == "$s2"]], with and without quotes, using =, == and -eq, but I still get the following error: [hi: command not found I'...
stackexchange/codereview
In my rails app, i want to store a value from the worker into the memcached and read it from the application controller. But in the worker i couldn't store the value as below cache_store.write('db_status','down') it says, undefined local variable or method cache_store. How do i configure my worker to write into the me...
stackexchange/codereview
I am trying to compile the Scintilla control with MSVC++ 2010 Express Edition, and it's quite painful getting it to work right because I need a bunch of files. When compiling SString.h, I noticed this: #include <crtdll/stddef.h> I am no C++ programmer, but I do understand what #include <xxx.h> means, but what does ...
stackexchange/codereview
I currently have a code (in C) with an outer loop that is OpenMP-parallelized (it operates locally on a shared-memory list). I'm rewriting it in C++, and for many things I found the BOOST_FOREACH macro a very nice syntax as loop construct for iterating over a list, array, etc. My question is: is there a way I can both ...
stackexchange/codereview
[Display(Name = "Type of Delivery:", Description = "(TBC)")] public string DeliveryType { get { return _deliveryType; } set { Validator.ValidateProperty(value, new ValidationContext(this, null, null) ...
stackexchange/codereview
after the update to 4.2 the setBackgroundImage behaviour changed! in my custom uibutton i have a white image as background (set with setBackgroundImage:forState:) and another image with a transparent layer (set with setImage:forState:) On iPad 3.2 and on all versions of iPhone this gets rendered as while on an iPad w...
stackexchange/codereview