Daily Archives

Articles indexed Sunday December 26 2010

Page 17/23 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Improving performance in this query

    - by Luiz Gustavo F. Gama
    I have 3 tables with user logins: sis_login = administrators tb_rb_estrutura = coordinators tb_usuario = clients I created a VIEW to unite all these users by separating them by levels, as follows: create view `login_names` as select `n1`.`cod_login` as `id`, '1' as `level`, `n1`.`nom_user` as `name` from `dados`.`sis_login` `n1` union all select `n2`.`id` as `id`, '2' as `level`, `n2`.`nom_funcionario` as `name` from `tb_rb_estrutura` `n2` union all select `n3`.`cod_usuario` as `id`, '3' as `level`, `n3`.`dsc_nome` as `name` from `tb_usuario` `n3`; So, can occur up to three ids repeated for different users, which is why I separated by levels. This VIEW is just to return me user name, according to his id and level. considering it has about 500,000 registered users, this view takes about 1 second to load. too much time, but is becomes very small when I need to return the latest posts on the forum of my website. The tables of the forums return the user id and level, then look for a name in this VIEW. I have registered 18 forums. When I run the query, it takes one second for each forum = 18 seconds. OMG. This page loads every time somebody enter my website. This is my query: select `x`.`forum_id`, `x`.`topic_id`, `l`.`nome` from ( select `t`.`forum_id`, `t`.`topic_id`, `t`.`data`, `t`.`user_id`, `t`.`user_level` from `tb_forum_topics` `t` union all select `a`.`forum_id`, `a`.`topic_id`, `a`.`data`, `a`.`user_id`, `a`.`user_level` from `tb_forum_answers` `a` ) `x` left outer join `login_names` `l` on `l`.`id` = `x`.`user_id` and `l`.`level` = `x`.`user_level` group by `x`.`forum_id` asc USING EXPLAIN: id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 Using temporary; Using filesort 1 PRIMARY <derived4> ALL NULL NULL NULL NULL 530415 4 DERIVED n1 ALL NULL NULL NULL NULL 114 5 UNION n2 ALL NULL NULL NULL NULL 2 6 UNION n3 ALL NULL NULL NULL NULL 530299 NULL UNION RESULT ALL NULL NULL NULL NULL NULL 2 DERIVED t ALL NULL NULL NULL NULL 3 3 UNION r ALL NULL NULL NULL NULL 3 NULL UNION RESULT ALL NULL NULL NULL NULL NULL Somebody can help me or give a suggestion?

    Read the article

  • Google Bar Chart Time Label Interval

    - by Alex Angelini
    Hi I am using Google Bar Chart through the visualization API on my site: http://code.google.com/apis/visualization/documentation/gallery/imagebarchart.html And my x-axis is time, and every time interval is a time of day in the format (HH:MM) Here is my code for the graph: <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> %s google.load("visualization", "1", {packages:["imagebarchart"]}); google.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Date'); data.addColumn('number', 'Amount'); data.addRows({{Rows}}); %s var chart = new google.visualization.ImageBarChart(document.getElementById('chart_div')); chart.draw(data, {width: 900, height: 340, min: 0, isVertical:true, legend:'none'}); } </script> The rows of data are added later using a templating engine, but that is the jist of my chart. Because I have added my time variable as 'string' I cannot use the valueLabelsInterval option to only show every 4 labels. Because I can't do that the labels overlap and look ugly. Is there any other way to only show every other time label or every 4th one, I read through the docs but could not see how to do it. Any help would be greatly appreciated thanks

    Read the article

  • Personal project in Java

    - by Chuck
    My first project in java is going to be a program (eventually I have to create a GUI interface but for now CLI would do) to keep track of my books (something similar to what libraries have only a simpler). I need to be able to insert, update, remove, show all books, update, search(by name or author or date). For the design I was thinking one main class Library which will have all of the above as methods that connect to the db and retrieve the data. Is this approach ok? I realize it's simple but it's my first real project and I would appreciate a little feedback. Also, is it too soon to consider reading up on design patterns and database design ?

    Read the article

  • Like posts over Facebook graph api

    - by Sima
    HI! I have little problem with facebook PHP SDK..I want to like a post, or something else via facebook PHP SDK..I am doing this code, I think it should be right, but  apparently it's not working..The given error code is, the PHP SDK dont know this kind of POST request(the generated link is definitely alright). What I have seen on Facebook Developers page is about the same..There is an example of Curl command, and I the PHP SDK is doing this requests over Curl (propably). $this->getFacebook()->api("/"+$id+"/likes", 'post'); This is what I am using in my code and it's not working(Facebook API Exception unsupported post request). Maybe, I have bad syntax in my code, but, for example, when I want to post a status to my Profile, it's working..Another cause which confused me, was when I tried to fetch these data over Graph api(on the documentation page is written, I should use address like graph.facebook.com/POST_ID/likes)... You can comment on or like a post by posting to https://graph.facebook.com/POST_ID/comments and https://graph.facebook.com/POST_ID/likes,respectively: curl -F 'access_token=...' \ https://graph.facebook.com/313449204401/likes <=this is from facebook documentation And all these requests or commands(liking ones, comments have I not yet tried) are putting me back a JSON array which contents any already existing likes, but my like is nowhere. Does anyone know what to do?How to like a post from PHP..There are other SKDs like FQL, but I haven't any knowlegde with it, so I like rather to use the standard PHP SDK(but if is there some possibility how to call for example FQL from PHP SDK, here I am:)) Please help..

    Read the article

  • Android strange behavior with listview and custom cursor adapter

    - by Michael Little
    I have a problem with a list view and a custom cursor adapter and I just can't seem to figure out what is wrong with my code. Basically, in my activity I call initalize() that does a bunch of stuff to handle getting the proper data and initializing the listview. On first run of the activity you can see from the images that one of the items is missing from the list. If I go to another activity and go back to this activity the item that was missing shows up. I believe it has something to do with setContentView(R.layout.parent). If I move that to my initialize() then the item never shows up even when returning from another activity. So, for some reason, returning from another activity bypasses setContentView(R.layout.parent) and everything works fine. I know it's impossible for me to bypass setContentView(R.layout.parent) so I need to figure out what the problem is. Also, I did not include the layout because it is nothing more then two textviews. Also, the images I have attached do not show that the missing item is the last one on the list. Custom Cursor Adapter: public class CustomCursorAdapter extends SimpleCursorAdapter { private Context context; private int layout; public CustomCursorAdapter (Context context, int layout, Cursor c, String[] from, int[] to) { super(context, layout, c, from, to); this.context = context; this.layout = layout; } public View newView(Context context, Cursor cursor, ViewGroup parent) { LayoutInflater inflater = LayoutInflater.from(context); final View view = inflater.inflate(layout, parent, false); return view; } @Override public void bindView(View v, Context context, Cursor c) { if (c.getColumnName(0).matches("section")){ int nameCol = c.getColumnIndex("section"); String section = c.getString(nameCol); TextView section_text = (TextView) v.findViewById(R.id.text1); if ((section.length() > 0)) { section_text.setText(section); } else { //so we don't have an empty spot section_text.setText(""); section_text.setVisibility(2); section_text.setHeight(1); } } else if (c.getColumnName(0).matches("code")) { int nameCol = c.getColumnIndex("code"); String mCode = c.getString(nameCol); TextView code_text = (TextView) v.findViewById(R.id.text1); if (code_text != null) { int i = 167; byte[] data = {(byte) i}; String strSymbol = EncodingUtils.getString(data, "windows-1252"); mCode = strSymbol + " " + mCode; code_text.setText(mCode); code_text.setSingleLine(); } } if (c.getColumnName(1).matches("title")){ int nameCol = c.getColumnIndex("title"); String mTitle = c.getString(nameCol); TextView title_text = (TextView) v.findViewById(R.id.text2); if (title_text != null) { title_text.setText(mTitle); } } else if (c.getColumnName(1).matches("excerpt")) { int nameCol = c.getColumnIndex("excerpt"); String mExcerpt = c.getString(nameCol); TextView excerpt_text = (TextView) v.findViewById(R.id.text2); if (excerpt_text != null) { excerpt_text.setText(mExcerpt); excerpt_text.setSingleLine(); } } } The Activity: public class parent extends ListActivity { private static String[] TITLE_FROM = { SECTION, TITLE, _ID, }; private static String[] CODE_FROM = { CODE, EXCERPT, _ID, }; private static String ORDER_BY = _ID + " ASC"; private static int[] TO = { R.id.text1, R.id.text2, }; String breadcrumb = null; private MyData data; private SQLiteDatabase db; CharSequence parent_id = ""; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); data = new MyData(this); db = data.getReadableDatabase(); setContentView(R.layout.parent); initialize(); } public void initialize() { breadcrumb = null; Bundle bun = getIntent().getExtras(); TextView tvBreadCrumb; tvBreadCrumb = (TextView)findViewById(R.id.breadcrumb); if (bun == null) { //this is the first run tvBreadCrumb.setText(null); tvBreadCrumb.setHeight(0); parent_id = "0"; try { Cursor cursor = getData(parent_id); showSectionData(cursor); } finally { data.close(); } } else { CharSequence state = bun.getString("state"); breadcrumb = bun.getString("breadcrumb"); tvBreadCrumb.setText(breadcrumb); CharSequence code = bun.getString("code"); parent_id = code; if (state.equals("chapter")) { try { Cursor cursor = getData(parent_id); showSectionData(cursor); } finally { data.close(); } } else if (state.equals("code")) { try { Cursor cursor = getCodeData(parent_id); showCodeData(cursor); } finally { data.close(); } } } } @Override public void onStart() { //initialize(); super.onResume(); } @Override public void onResume() { initialize(); super.onResume(); } private Cursor getData(CharSequence parent_id) { Cursor cTitles = db.query(TITLES_TABLE_NAME, TITLE_FROM, "parent_id = " + parent_id, null, null, null, ORDER_BY); Cursor cCodes = db.query(CODES_TABLE_NAME, CODE_FROM, "parent_id = " + parent_id, null, null, null, ORDER_BY); Cursor[] c = {cTitles, cCodes}; Cursor cursor = new MergeCursor(c); startManagingCursor(cursor); return cursor; } private Cursor getCodeData(CharSequence parent_id2) { Bundle bun = getIntent().getExtras(); CharSequence intent = bun.getString("intent"); CharSequence searchtype = bun.getString("searchtype"); //SQLiteDatabase db = data.getReadableDatabase(); if (intent != null) { String sWhere = null; if(searchtype.equals("code")) { sWhere = "code LIKE '%"+parent_id2+"%'"; } else if(searchtype.equals("within")){ sWhere = "definition LIKE '%"+parent_id2+"%'"; } //This is a search request Cursor cursor = db.query(CODES_TABLE_NAME, CODE_FROM, sWhere, null, null, null, ORDER_BY); startManagingCursor(cursor); return cursor; } else { Cursor cursor = db.query(CODES_TABLE_NAME, CODE_FROM, "parent_id = "+ parent_id2, null, null, null, ORDER_BY); startManagingCursor(cursor); return cursor; } } private void showSectionData(Cursor cursor) { CustomCursorAdapter adapter= new CustomCursorAdapter(this, R.layout.item, cursor, TITLE_FROM, TO); setListAdapter(adapter); } private void showCodeData(Cursor cursor) { CustomCursorAdapter adapter = new CustomCursorAdapter(this, R.layout.item, cursor, CODE_FROM, TO); setListAdapter(adapter); Bundle bun = getIntent().getExtras(); CharSequence intent = bun.getString("intent"); if (intent != null) { Cursor cursor1 = ((CursorAdapter)getListAdapter()).getCursor(); startManagingCursor(cursor1); TextView tvBreadCrumb; tvBreadCrumb = (TextView)findViewById(R.id.breadcrumb); tvBreadCrumb.setText(cursor1.getCount() + " Records Found"); //cursor1.close(); //mdl } }

    Read the article

  • A specific data structure

    - by user550413
    Well, this question is a bit specific but I think there is some general idea in it that I can't get it. Lets say I got K servers (which is a constant that I know its size). I have a program that get requests and every request has an id and server id that will handle it. I have n requests - unknown size and can be any number. I need a data structure to support the next operations within the given complexity: GetServer - the function gets the request ID and returns the server id that is supposed to handle this request at the current situation and not necessarily the original server (see below). Complexity: O(log K) at average. KillServer - the function gets as input a server id that should be removed and another server id that all the requests of the removed server should be passed to. Complexity: O(1) at the worst case. -- Place complexity for all the structure is O(K+n) -- The KillServer function made me think using a Union-Find as I can do the union in O(1) as requested but my problem is the first operation. Why it's LogK? Actually, no matter how I "save" the requests if I want to access to any request (lets say it's an AVL tree) so the complexity will be O(log n) at the worst case and said that I can't assume Kn (and probably K Tried thinking about it a couple of hours but I can't find any solution. Known structures that can be used are: B+ tree, AVL tree, skip list, hash table, Union-Find, rank tree and of course all the basics like arrays and such.

    Read the article

  • Simple Properties in Objective-C Classes

    - by tarnfeld
    Hey, I've bene working with Objective-C for a while now, and so far I have never really needed to craft my own classes, properly. I am a bit confused with the two arguments you can give the @property(a, b) declaration in a header file. When creating outlets to Interface Builder I usually do @property(nonatomic, retain) but I have no idea what this means. I'm writing a simple class which has a set of properties which will be set from the outside, like [instance setName:@"Bla Bla Bla"]; or I guess like instance.name = @"Bla@" but I would rather the first option. How would I declare this kind of property on a class? Thanks in advanced! Sorry for the n00bish question :-)

    Read the article

  • Syntax errors on Heroku, but not on local server (postgresql related?)

    - by Phil_Ken_Sebben
    I'm trying to deploy my first app on Heroku (rails 3). It works fine on my local server, but when I pushed it to Heroku and ran it, it crashes, giving a number of syntax errors. These are related to a collection of scopes I use like the one below: scope :scored, lambda { |score = nil| score.nil? ? {} : where('products.votes_count >= ?', score) } it produces errors of this form: "syntax error, unexpected '=', expecting '|' " "syntax error, unexpected '}', expecting kEND" Why is this syntax making Heroku choke and how can I correct it? Thanks! EDIT: I was using sqlite on my local machine and Heroku does not support that. Trying to make sure the db is properly configured for PG. I believe I have done that by specifying in the gemfile that sqlite only be used in development. Yet I still get these syntax errors, that interrupt even the db:migrate. EDIT: So now it seems more likely that my scope syntax doesn't work in postgreSQL. Does anyone know how to convert this properly?

    Read the article

  • Retrieving images when database is in remote location...

    - by sasidhar
    Hi everyone, I am developing an application using java, my application would be accessed by number of different users simultaneously and the database resides in a central server. The access of the database from remote server is handled by just giving the appropriate IP of the server in the hibernate configure file. My question is, i have to store a picture regarding each user of the database, i heard that storing the image in the database and retrieving it from the database is not advised and has negative impact on the performance. Is it so ? What are the other possible ways i can implement this ? What is the best way to do it..? Please help....

    Read the article

  • WebBrowser.Navigate overload doesn't add cookies

    - by kaharas
    Hi guys, I'm experimenting with C#, and right now I'm trying to get a web page that needs cookies. Since I had no success doing it, I wrote this little PHP script ( directly from php.net): <?php foreach (getallheaders() as $name => $value) { echo "$name: $value\n"; } ?> but, when i run: this.WBro.Navigate("http://localhost/cookie.php", null,null,"Cookie: foo=bar"); the foo cookie isn't there, and all I got is a page displaying the "usual" headers ( except the cookie one). Does somebody has any idea of why this happens? Thanks a lot!

    Read the article

  • How to setPage() a JEditorPane with a localfile which is outside of the .jar file?

    - by Jaguar
    My program has the following path in the .jar file src/test/Program.class and my program is as follow... Program.java package test; import java.io.File; import java.io.IOException; import javax.swing.JEditorPane; import javax.swing.JFrame; public class Program { JEditorPane editorPane; public Program() { File file = new File("temp.htm"); try { file.createNewFile(); editorPane = new JEditorPane(); editorPane.setPage(Program.class.getResource("temp.htm")); } catch (IOException e) { e.printStackTrace(); } } public JEditorPane getEditorPane(){ return editorPane; } public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 400); frame.setVisible(true); Program p = new Program(); frame.getContentPane().add(p.getEditorPane()); } } The problem is that I have compiled the program in a .jar file. The file.createNewFile(); creates the temp.htm file outside the .jar file So when editorPane.setPage(Program.class.getResource("temp.htm")); is called the file is not found as it searches for file inside the test package. How to setPage() the temp.htm file whiich is outside the .jar file but in the same folder as the .jar file? As the temp.htm is a localfile and I want a relative path instead of an absolute path. Thanks.

    Read the article

  • Are Thread.stop and friends ever safe in Java?

    - by Stephen C
    The stop(), suspend(), and resume() in java.lang.Thread are deprecated because they are unsafe. The Sun recommended work around is to use Thread.interrupt(), but that approach doesn't work in all cases. For example, if you are call a library method that doesn't explicitly or implicitly check the interrupted flag, you have no choice but to wait for the call to finish. So, I'm wondering if it is possible to characterize situations where it is (provably) safe to call stop() on a Thread. For example, would it be safe to stop() a thread that did nothing but call find(...) or match(...) on a java.util.regex.Matcher? (If there are any Sun engineers reading this ... a definitive answer would be really appreciated.) EDIT: Answers that simply restate the mantra that you should not call stop() because it is deprecated, unsafe, whatever are missing the point of this question. I know that that it is genuinely unsafe in the majority of cases, and that if there is a viable alternative you should always use that instead. This question is about the subset cases where it is safe. Specifically, what is that subset?

    Read the article

  • How to grow to be global sysadmin of an organization?

    - by user64729
    Bit of a non-technical question but I have seen questions of the career development type on here before so hopefully it is fine. I work for a fast growing but still small organization (~65 employees). I have been their external sysadmin for a while now, looking after hosted Linux servers and infrastructure. In the past 12 months I have been transforming into the internal sysadmin for our office too. I'm currently studying Cisco CCNA to cover the demands of being an internal sysadmin and looking after the office LAN, routers, switches and VPNs. Now they want me to look after the global sysadmin function of the organization as a whole. The organization has 3 offices in total, 2 in the UK and 1 in the US. I work in one of the UK offices. The other offices are primarily Windows desktops with AD domain shops. My office is primarily a Linux shop with a file-server and NFS/NIS (no AD domain for the Windows desktops yet but it's in the works). Each other office has a sysadmin which in theory I am supposed to supervise but in reality each is independent. I have a very competent junior sysadmin working with me who shares the day-to-day tasks and does some of the longer term projects with my supervision. My boss has asked me how to grow from being the external sysadmin to the global sysadmin. I am to ponder this and then report back to him on how to achieve this. My current thoughts are: Management training or professional development - eg. reading books such as "Influencer" and "7 Habits". Also I feel I should take steps to improving communication skills since a senior person is expected to talk and speak out more often. Learn more about Windows and Active Directory - I'm an LPI-certified guy and have a lot of experience in Linux (Ubuntu or desktop, Debian/Ubuntu as server). Since the other offices are mainly Windows-domains it makes sense to skill-up in that area so I can understand what the other admins are talking about. Talk to previous colleagues who have are are in this role already - to try and get the benefit of their experience. Produce an "IT Roadmap" or similar that maps out where we want the organization to be and when, plotted out over the next couple of years with regards to internal and external infrastructure. I have produced a "Security roadmap" already which does cover some of these things. I guess this can summed up as "thinking more strategically"? I'd appreciate comments from anyone who has been through a similar situation, thanks.

    Read the article

  • master-slave-slave replication: master will become bottleneck for writes

    - by JMW
    hi, the mysql database has arround 2TB of data. i have a master-slave-slave replication running. the application that uses the database does read (SELECT) queries just on one of the 2 slaves and write (DELETE/INSERT/UPDATE) queries on the master. the application does way more reads, than writes. if we have a problem with the read (SELECT) queries, we can just add another slave database and tell the application, that there is another salve. so it scales well... Currently, the master is running arround 40% disk io due to the writes. So i'm thinking about how to scale the the database in the future. Because one day the master will be overloaded. What could be a solution there? maybe mysql cluster? if so, are there any pitfalls or limitations in switching the database to ndb? thanks a lot in advance... :)

    Read the article

  • Security considerations for my first eStore.

    - by Rohit
    I have a website through which I am going to sell few products. It is hosted on a simple shared-hosting and does not have SSL. On the products page, each product has a Buy Now button created from my PayPal Merchant account. PayPal recommends to use it's Button Factory to create secure buttons and save it inside PayPal itself. I have followed the same advice and the code of any button is secure and does not disclose any information on either a product or it's price. When the user clicks on a Buy Now button, he/she is taken to PayPal site where a page is opened in SSL for the user to fill in the credit card and shipping details. After a successful transaction, the control is passed back to my site. I want to know whether there is still any chance when security could be compromised.

    Read the article

  • Google Chrome not using local cache

    - by Steve
    Hi. I've been using Google Chrome as a substitute for Firefox not being able to handle having lots of tabs open at the same time. Unfortunately, it looks like Chrome is having the same problem. Freakin useless. I had to end Chrome as my whole system had slowed to a crawl. When I restarted it, I opted to restore the tabs that were last open. At this stage, every one of the 20+ tabs srated downloading the pages they had previously had open. My question is: why can't they open a locally stored/saved copy of the web page from cache? Does Google Chrome store pages in a cache? Also: after most of the pages had completed their downloading, I clicked on each tab to view the page. Half of them only display a white page, and I have to reload the page manually. What is causing this? Thanks for your help.

    Read the article

  • So confused by these CPU Specs can someone please help me out? THanks!

    - by Kevin
    Intel® Core™ i7-640M (2.8~3.46GHz, 35W) w/4MB Cache - 2 Cores, 4 Threads - 2.5 GT/s SO i'm buying a new laptop, which i have not done in 6 years. So i am not familiar with any of these cpu specs. It was the highest option for intel for this laptop. So i am assuming it is somewhat fast. But i'd like to learn what these specs mean. Any help would be greatly appreciated. i am not really a computer guy but would love to learn about what I am buying. Thanks!

    Read the article

  • GhostScript noob help - Breaking a multipage PDF file into many single page PS or EPS files.

    - by godzilla_g
    Hi, I'm trying to do the following with ghostscript: Turn one multipage PDF file (about 3,000 pages, 200mb file) into: One file per page of the PDF, and convert each (page/file) to EPS or PS (post script(preferably)). Example: hello.pdf (10 pages) would produce: hello1.ps (page 1 out of 10) hello2.ps hello3.ps ... hello10.ps How can I do this? I've been trying for 4 days, and can't figure it out. I have a script I've tried(won't work): Note: Windows(7) user here. gs -sDEVICE=epswrite -o documentname-%.eps documentname.pdf I also don't know how to navigate to the directory where my file resides (cannot figure that out, too). If you can, please show me how. A big thank you.

    Read the article

  • Can a company use VPN to spy on me?

    - by orokusaki
    I'm about to work with a company on a development project, but they first need to set up a pretty complicated environment, and suggested they use VPN to work on my machine to do this. Should I be concerned that somebody can just watch me work? It would be embarrassing, if somebody could witness my work habits (e.g. Asking questions on SO and researching all day is part of my daily work regiment, and makes me feel like a noob, but it keeps me sharp. I also listen to conspiracy videos all day, and RadioLab podcasts, :). Is VPN going to introduce this possibility, and if so, is there a way around it? EDIT: Also, is there a way I can always tell when somebody is VPNed into my computer?

    Read the article

  • Are there alternative ways to implementing an "active link" navigation without using server side languages?

    - by Mel
    By "active" I mean to have the link pointing to the current page classed as "active." This way the link's appearance can be modified using css. Is it possible to implement an active link navigation without using a server side language? I would like to only use CSS/HTML/jQuery if possible. If there are, what are those methods? Assuming you want to create the following structure: <ul id="nav"> <li class="active">Home</li> <li>About</li> <li>Contact</li> </ul>

    Read the article

  • load different images for each item on the listbox

    - by user161179
    Javascript: function changeMap() { imagesource = "http://maps.google.com/maps/api/staticmap?size=500x500&maptype=hybrid&zoom=16&sensor=false&markers=color:blue|label:K|28.541250,77.204100" ; mapimage.src = imagesource ; } Html code : <select name="choose_colony" id="choose_colony" size="8" onchange="changeMap()" style="float: left;"> <option value="1" >Big apartments</option> . . <option value="999">plaza</option> </select> <img name="mapimage" src="" alt="Select your Colony" style="float: right;"> In this whenever a selection on the listbox is made changeMap is called and an image is loaded. What I want is for a different image to be loaded everytime depending upon the option selected . there will be over 2000 entries in the listbox. Considering this what is the best way of going about this ? I can figure out the if/then part , but my main question is whether its ok to put all the 2000 long image addresses in the html file itself ? I hope I was clear ..

    Read the article

  • parsing command option with default values and range constrains in C

    - by agramfort
    Hi, I need to parse command line arguments in C. My arguments are basically int or float with default values and range constrains. I've started to implement something that look like this: option_float(float* out, int argc, char* argv, char* name, description, float default_val, int is_optional, float min_value, float max_value) which I call for example with: float* pct; option_float(pct, argc, argv, "pct", "My super percentage option", 50, 1, FALSE, 0, 100) however I don't want to reinvent the wheel ! My objective is to have error checking of range constrains, throw an error when the option is not optional and is not set. And generate the help message usually given by usage() function. The usage text would look like this: --pct My super percentage option (default : 50). Should be in [0, 100] I've started with getopt but it is too limited for what I want to do and I feel it still requires me to write too much code for a simple usecase like this. thanks

    Read the article

  • Beginner error in CUDA

    - by Dimitri
    Hi folks, first all i want to wish you a merry christmas. I am writing a small program in CUDA and i have the following errors : contraste.cu(167): error: calling a host function from a __device__/__global__ function is not allowed I don't understand why. Can you please help me and show me my errors. It seems that my program is correct. Here is a the bunch of code causing the problems : __global__ void kernel_contraste(float power, unsigned char tab_in[], unsigned char tab_out[], int nbl, int nbc) { int x = threadIdx.x; printf("I am the thread %d\n", x); } Part of my main program : unsigned char *dimg, *dimg_res; ..... cudaMalloc((void **)dimg, h * w * sizeof(char)); cudaMemcpy(dimg, r.data, h*w*sizeof(char), cudaMemcpyHostToDevice); cudaMalloc((void **)dimg_res, h*w*sizeof(char)); dim3 nbThreadparBloc(256); dim3 numblocs(1); kernel_contraste<<<numblocs, nbThreadparBloc >>>(puissance, dimg, dimg_res, h, w); cudaThreadSynchronize(); ..... cudaFree(dimg); cudaFree(dimg_res); The line 167 is the line where i call the printf in function kernel_contraste. For information, this program takes an image as an input( a sun Rasterfile ) and a power then it calculates the contraste of that image. Thanks !!

    Read the article

  • Trying to use a authlogic-connect as a plugin in place of gem - Server doesn't start

    - by Arkid
    I am trying to use Authlogic-connect as a plugin in Rails 3 in place of a gem. I have made an entry in the gemfile as gem "authlogic-connect", :require => "authlogic-connect", :path => "localgems" Now when I run the bundle install, it runs fine. When I try to start the server i get the error Could not find gem 'authlogic-connect (>= 0, runtime)' in source at localgems. Source does not contain any versions of 'authlogic-connect (>= 0, runtime)' Try running `bundle install`. I have placed the unzipped Gem renamed as authlogic-connect in the localgems folder. what is the problem? Here is what I get on using rails plugin install arkidmitra$ rails plugin install git://github.com/viatropos/authlogic-connect.git Usage: rails new APP_PATH [options] Options: [--skip-gemfile] # Don't create a Gemfile -d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db) # Default: sqlite3 -O, [--skip-active-record] # Skip Active Record files [--dev] # Setup the application with Gemfile pointing to your Rails checkout -J, [--skip-prototype] # Skip Prototype files -T, [--skip-test-unit] # Skip Test::Unit files -G, [--skip-git] # Skip Git ignores and keeps -r, [--ruby=PATH] # Path to the Ruby binary of your choice # Default: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -m, [--template=TEMPLATE] # Path to an application template (can be a filesystem path or URL) -b, [--builder=BUILDER] # Path to an application builder (can be a filesystem path or URL) [--edge] # Setup the application with Gemfile pointing to Rails repository Runtime options: -q, [--quiet] # Supress status output -s, [--skip] # Skip files that already exist -f, [--force] # Overwrite files that already exist -p, [--pretend] # Run but do not make any changes Rails options: -h, [--help] # Show this help message and quit -v, [--version] # Show Rails version number and quit Description: The 'rails new' command creates a new Rails application with a default directory structure and configuration at the path you specify. Example: rails new ~/Code/Ruby/weblog This generates a skeletal Rails installation in ~/Code/Ruby/weblog. See the README in the newly created application to get going.

    Read the article

  • Jquery grid overlay in wordpress

    - by Anders Kitson
    I am adding this simple plugin that I have working in a static html site, and am trying to add it to a wordpress development site based off of 960 gs. The jquery code links are correct but the console gives me this error "Uncaught TypeError: Cannot call method 'addGrid' of null" I got the code from this turtorial http://www.badlydrawntoy.com/2009/04/21/960gs-grid-overlay-a-jquery-plugin/ Here is the code I am using /*<![CDATA[*/ // onload $(function() { $("body").addGrid(12, {img_path: 'img/'}); }); /*]]>*/ Here is the code for the plugin /* * @ description: Plugin to display 960.gs gridlines See http://960.gs/ * @author: badlyDrawnToy sharp / http://www.badlydrawntoy.com * @license: Creative Commons License - ShareAlike http://creativecommons.org/licenses/by-sa/3.0/ * @version: 1.0 20th April 2009 */ (function($){$.fn.addGrid=function(cols,options){var defaults={default_cols:12,z_index:999,img_path:'/images/',opacity:.6};var opts=$.extend(defaults,options);var cols=cols!=null&&(cols===12||cols===16)?cols:12;var cols=cols===opts.default_cols?'12_col':'16_col';return this.each(function(){var $el=$(this);var height=$el.height();var wrapper=$('<div id="'+opts.grid_id+'"/>').appendTo($el).css({'display':'none','position':'absolute','top':0,'z-index':(opts.z_index-1),'height':height,'opacity':opts.opacity,'width':'100%'});$('<div/>').addClass('container_12').css({'margin':'0 auto','width':'960px','height':height,'background-image':'url('+opts.img_path+cols+'.png)','background-repeat':'repeat-y'}).appendTo(wrapper);$('<div>grid on</div>').appendTo($el).css({'position':'absolute','top':0,'left':0,'z-index':opts.z_index,'background':'#222','color':'#fff','padding':'3px 6px','width':'40px','text-align':'center'}).hover(function(){$(this).css("cursor","pointer");},function(){$(this).css("cursor","default");}).toggle(function(){$(this).text("grid off");$('#'+opts.grid_id).slideDown();},function(){$(this).text("grid on");$('#'+opts.grid_id).slideUp();});});};})(jQuery);

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23  | Next Page >