Search Results

Search found 22 results on 1 pages for 'serg555'.

Page 1/1 | 1 

  • What is a proper MySql replication configuration for frequent db updates and rare selects?

    - by serg555
    We currently have 1 master db on its own server and slave db on app server. App executes very frequent but light updates (like increasing counters), and occasional (once in a few minutes) heavy selects (which is the most important part of the app). When app was connected only to master db there were no performance issues. With slave db introduction CPU load avg on app server increased to about 6-10 during that heavy select period (from 3-4 as before). When server doesn't run those frequent updates it seems like performance for selects stays within the limits. So I have a feeling that those updates is what is causing the performance drop (also these frequent updates are not critical so if slave db doesn't have them in sync with master for some time it would be ok). What would be a good db replication setup for such kind of app? What are the replication parameters we could tweak? Thanks.

    Read the article

  • Quick question - how to comment if-else structure?

    - by serg555
    Lets say you have: if(condition) { i = 1; } else { i = 2; } and you need to put comments explaining if and else blocks. What's the most readable way of doing it so someone can easily pick them up at first glance? I usually do it like this: //check for condition if(condition) { i = 1; } else { //condition isn't met i = 2; } which I find not good enough as comments are located at different levels, so at quick glance you would just pick up if comment and else comment would look like it belongs to some inner structure. Putting them like this: if(condition) { //check for condition i = 1; } else { //condition isn't met i = 2; } doesn't look good to me either as it would seem like the whole structure is not commented (condition might be big and take multiple lines). Something like that: //check for condition if(condition) { i = 1; //condition isn't met } else { i = 2; } would be probably the best style from comments point of view but confusing as a code structure. How do you comment such blocks?

    Read the article

  • Inspiring web experiments and technical demos

    - by serg555
    Probably everyone knows about Chrome Experiments: http://www.chromeexperiments.com/ that contain some stunning examples of what JS is capable of. It would be nice to compile a collection of similar projects (usually just blog posts) that showcase some original JS/CSS/HTML/Flash or any other web-related ideas and solutions.

    Read the article

  • Why do programmers have to learn for their whole lives and aren't you afraid of that?

    - by serg555
    Programming technologies are evolving so fast that programmers constantly have to learn more and more to catch up whether you want it or not. Often it is not just learning more in the same direction but starting from a scratch. Lets say you were a topnotch programmer in 1999 who quit for 10 years and went to a job interview in 2009 (funny even to imagine) - how much of your knowledge is still needed? And if we take a carpenter, engineer, doctor or even mathematician - they all are still good specialists after 10 years. So why programming is so not stable? Is it because it is just relatively new or because something important is still missing after 50 years and we can't find it to settle in that direction? Do you think after some time situation will change? Learning something new all the time is exciting and all, but it is starting to worry me that as I become older it will be harder and harder. After all "you can't teach an old dog new tricks" and I'm afraid that at the end I just end up behind college students and become one of those "cobol dinosaurs", only it will be probably "java dinosaurs" by that time.

    Read the article

  • Easiest way of checking if a string consists of unique characters?

    - by serg555
    I need to check in Java if a word consists of unique letters (case insensitive). As straight solution is boring, I came up with: For every char in a string check if indexOf(char) == lastIndexOf(char). Add all chars to HashSet and check if set size == string length. Convert a string to a char array, sort it alphabetically, loop through array elements and check if c[i] == c[i+1]. Currently I like #2 the most, seems like the easiest way. Any other interesting solutions?

    Read the article

  • How to align 3 divs (left/center/right) inside another div?

    - by serg555
    I want to have 3 divs aligned inside a container div, something like this: [[LEFT] [CENTER] [RIGHT]] Container div is 100% wide (no set width), and center div should remain in center after resizing the container. So I set: #container{width:100%;} #left{float:left;width:100px;} #right{float:right;width:100px;} #center{margin:0 auto;width:100px;} But it becomes: [[LEFT] [CENTER] ] [RIGHT] Any tips?

    Read the article

  • How to make safe frequent DataSource switches for AbstractRoutingDataSource?

    - by serg555
    I implemented Dynamic DataSource Routing for Spring+Hibernate according to this article. I have several databases with same structure and I need to select which db will run each specific query. Everything works fine on localhost, but I am worrying about how this will hold up in real web site environment. They are using some static context holder to determine which datasource to use: public class CustomerContextHolder { private static final ThreadLocal<CustomerType> contextHolder = new ThreadLocal<CustomerType>(); public static void setCustomerType(CustomerType customerType) { Assert.notNull(customerType, "customerType cannot be null"); contextHolder.set(customerType); } public static CustomerType getCustomerType() { return (CustomerType) contextHolder.get(); } public static void clearCustomerType() { contextHolder.remove(); } } It is wrapped inside some ThreadLocal container, but what exactly does that mean? What will happen when two web requests call this piece of code in parallel: CustomerContextHolder.setCustomerType(CustomerType.GOLD); //<another user will switch customer type here to CustomerType.SILVER in another request> List<Item> goldItems = catalog.getItems(); Is every web request wrapped into its own thread in Spring MVC? Will CustomerContextHolder.setCustomerType() changes be visible to other web users? My controllers have synchronizeOnSession=true. How to make sure that nobody else will switch datasource until I run required query for current user? Thanks.

    Read the article

  • Why JavaScript dialogs (alert/prompt/confirm) are not widely used and not under active development?

    - by serg555
    If there is a need to display some simple confirmation popup, most developers would rather install jQuery, find some dialog plugin for it, skin it, than put a one liner: if(confirm("Are you sure?")) { ... } Using alert() for displaying error messages is considered cheap. And how many sites can you name that are usingprompt()? So, the question is: Is there something wrong with those dialogs so they should be avoided? Yes they have (very) limited functionality and customization, but when you don't need anything fancy, is using js dialogs still a bad practice? Why these dialogs haven't seen any improvement in past 10 years (probably longer) and none is planned for near future? Wouldn't it be nice to have native js access to fully customizable desktop-level dialogs? At least adding error/warning/info type of dialogs and adding ability to customize button captions would be a big help.

    Read the article

  • Facebook JS API: users_getInfo() inside ifUserConnected() deadlock.

    - by serg555
    I am trying to put Facebook connect button on the site and once connected display connected username. But for some reason following code goes into some infinite loop during first connection, and then works fine unless I delete this app from my facebook profile which causes freezing again. Here is a code on FB connect button click: FB.Connect.requireSession(); Here is code directly on the page: <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US" type="text/javascript"></script> <script type="text/javascript"> FB.init("123", "/xd_receiver.htm"); FB.ensureInit(function() { FB.Connect.ifUserConnected(function() { FB.Facebook.apiClient.users_getInfo(new Array(FB.Connect.get_loggedInUser()),new Array("name"), function(user, exec) { console.log("logged in:"+user[0].name); }); }, function(){ console.log("guest"); }); }); </script> If I remove FB.Facebook.apiClient.users_getInfo() it works fine, but I need to get username somehow. Any tips? Thanks.

    Read the article

  • Need to map classes to different databases at runtime in Hibernate

    - by serg555
    I have MainDB database and unknown number (at compile time) of UserDB_1, ..., UserDB_N databases. MainDB contains names of those UserDB databases in some table (new UserDB can be created at runtime). All UserDB have exactly the same table names and fields. How to handle such situation in Hibernate? (database structure cannot be changed). Currently I am planning to create generic User classes not mapped to anything and just use native SQL for all queries: session.createSQLQuery("select * from " + db + ".user where id=1") .setResultTransformer(Transformers.aliasToBean(User.class)); Is there anything better I can do? Ideally I would want to have mappings for UserDB tables and relations and use HQL on required database.

    Read the article

  • Need some sort of "conditional grouping" in MySQL.

    - by serg555
    I have Article table: id | type | date ----------------------- 1 | A | 2010-01-01 2 | A | 2010-01-01 3 | B | 2010-01-01 Field type can be A, B or C. I need to run a report that would return how many articles of each type there is per every day, like this: date | count(type="A") | count(type="B") | count(type="C") ----------------------------------------------------- 2010-01-01 | 2 | 1 | 0 2010-01-02 | 5 | 6 | 7 Currently I am running 3 queries for every type and then manually merging the results select date, count(id) from article where type="A" group by date Is it possible to do this in one query? (in pure sql, no stored procedures or anything like that). Thanks

    Read the article

  • What is a good solution to link different tables in Hibernate based on some field value?

    - by serg555
    I have article table and several user tables a_user, b_user, ... with exactly the same structure (but different data). I can't change anything in *_user tables except their table name prefix but can change everything else (user tables contain only user information, there is nothing about article or user_type in them). I need to link article to a user (many-to-one), but user table name is defined by user_type field. For example Article table record: ... user_id="5" user_type="a" means that it is linked to a user with id=5 from a_user table (id 5 is not unique in users scope, each user table can have its id 5). Any suggestions how to handle this situation? How can I map this relation in Hibernate (xml mapping, no annotations) so it will automatically pick up correct user for an article during select/update? How should I map user tables (one or multiple classes?)? I would need to run some queries like this: from Article a where a.userType=:type and a.user.name=:name Thanks.

    Read the article

  • Conditional sorting in MySQL?

    - by serg555
    I have "tasks" table with 3 fields: date priority (0,1,2) done (0,1) What I am trying to achieve is with the whole table sorted by done flag, tasks that are not done should be sorted by priority, while tasks that are done should be sorted by date: Select * from tasks order by done asc If done=0 additionally order by priority desc If done=1 additionally order by date desc Is it possible to do this in MySQL without unions? Thanks.

    Read the article

  • Looking for a full list of jQuery event types.

    - by serg555
    Where I can find a complete list of all jQuery supported events (like click, mouseup etc) with some explanations when they are triggered? I am looking for those that can be binded: $('#foo').bind('click', handler); For example I just found out by accident that there is paste event but I can't find any references to it anywhere in their docs. What else is there?

    Read the article

  • Aligning divs with different dimensions horizontally.

    - by serg555
    I have a tag cloud with different font sizes. <div> <a style="font-size:15px;">tag1</a> <a style="font-size:10px;">tag1</a> </div> And it looks like this: Now I need to wrap each tag into its own div: <style> .cloud {float:left} .tag {float:left} </style> <div class="cloud"> <div class="tag"><a style="font-size:15px;">tag1</a></div> <div class="tag"><a style="font-size:10px;">tag1</a></div> </div> Which puts them all over the place. How to make them look like on the first picture?

    Read the article

  • How to write native SQL queries in Hibernate without hardcoding table names and fields?

    - by serg555
    Sometimes you have to write some of your queries in native SQL rather than hibernate HQL. Is there a nice way to avoid hardcoding table names and fields and get this data from existing mapping? For example instead of: String sql = "select user_name from tbl_user where user_id = :id"; something like: String sql = "select " + Hibernate.getFieldName("user.name") + " from " + Hibernate.getTableName(User.class) + " where " + Hibernate.getFieldName("user.id") + " = :id";

    Read the article

1