Tuesday, March 15, 2011

git workflow question

Hi, this will be a long one but I hope you could bear with me.

I am trying to use git to put my team's source codes under version control. After trying to find different approaches that would work for me, I finally decided to use git format-patch feature. FWIW, the product is an ASP.NET web application running in Windows and I am currently using msysgit.

Background: I have a staging server(mirrors production server) which contains all the aspx files. I then created a git repo using init-db inside my root folder and did a "git add ." to track all the files.

In order for me to have a local copy on my laptop, I actually zipped up the ".git" folder from the staging server and FTP'ed it to my local machine. Renamed it to "staging.git" and did a "git clone staging.git webappfolder" to do my development against.

After doing 2 commits for feature1 and feature2, its time to apply the changes back to the staging server. I did a "git format-patch -2" which outputs to files 0001blah.patch and 0002blah.patch.

This 2 patch files are then sent to the staging server and I did a "git am 0001blah.patch" on the staging server itself. Doing a "git log" shows the commit went through. But when I do a "git status", it shows "Changed but not updated: modified: file1.aspx".

What does that mean exactly? I also tried doing a "git apply 0001blah.patch" but all I got was an "error" patch failed: file1.aspx: patch does not apply".

Is there a problem with my workflow? Any insight regarding the proper way or help would be exremely helpful. Again, the patching model would be the most viable for us right now as we won't be setting up an SSH server anytime. Once again, thanks in advance.

From stackoverflow
  • Did you try a

    git am -3
    

    ? From the git-am doc,

    -3
    --3way
    
    When the patch does not apply cleanly, fall back on 3-way merge
    


    Note: From Git Google Summer of Code 2009, there is a project to "Teach git-apply the 3-way merge fallback git-am knows":

    When git-apply patches file(s) the files may not patch cleanly. In such a case git-apply currently rejects the patch.
    If it is called from git-am then a 3-way merge is attempted by:

    • taking the "index ..." data from the patch and
    • constructing a temporary tree,
    • applying the patch to that, then
    • merging the temporary tree to the current branch.

    For various reasons it would be nice to do the entire temporary tree dance directly inside of git-apply, as it can benefit say the git-sequence's "apply" command, speed up git-am processing by forking less, etc

    Ghazaly : I tried git am -3 but the results were still the same but nonetheless, thanks for taking the time and effort.
  • I just tried this:

    rm -rf clone?
    
    # clone 1 is the working copy
    mkdir clone1
    (
        cd clone1
        git init
        echo foo >> file1
        git add file1
        git commit -m "Initial state"
    )
    
    # clone 2 is the staging repo
    git clone clone1 clone2
    
    # create patches
    (
        cd clone1
        git tag staging # tag to track what's in staging
    
        echo feature1 >> file1
        git add file1
        git commit -m "Feature 1"
    
        echo feature2 >> file1
        git add file1
        git commit -m "Feature 2"
    
        rm *.patch
        git format-patch staging
    )
    
    # apply patches
    (
        cd clone2
        git am ../clone1/*.patch
        # Cygwin/msysgit line ending weirdness when patching. Aborting and
        # reapplying clears it up.
        git am --abort 
        git am ../clone1/*.patch
        git log
        git status
    )
    

    Has the minor issue with the patches not applying clearly without doing the am twice, but I end up with a clean working dir in clone 2 with the right contents of file1. So there doesn't seem to be anything wrong with your workflow per se.

    Git apply will only update the working tree, not perform a commit.

    That said, I wouldn't use a git repository for staging. My workflow would probably make a release branch / fork of the development repository (or not), and just deploy full clean copies of that.

    For incremental updates to the staging environment, just use git tag staging in the release branch, "git diff staging..HEAD > update.patch" to email, and the standard unix "patch -p1" to apply it should work. That is unless you really need have the change history physically on the staging server.

    VonC : "Git apply will only"... "will only what" ? ;)
    Ghazaly : Thanks SiitheMoose, after trying out your example and getting no errors, I began to wonder what's wrong with my source files. That prompted me to re-edit my line endings and doing a "git am" works with no errors. I'm marking this answer correct since your suggestion works for my staging environment.
    VonC : Great test and description. +1

How to get UdpClient to react to DNS updates

I am using a UdpClient to send packets to a server. I am initializing the UdpClient upon construction of my Sender object, using the (hostname, port) constructor. When constructed in this manner, the UdpClient resolves the hostname to an IP address. Subsequent calls to the UdpClient object use the IP address.

Unfortunately, if the DNS alias used is updated through the DNS system to point to a different IP address, this change is not reflected in my Sender object unless it is re-created.

What would be the best way to have my Sender object react to DNS changes in a timely manner? Performance is very important. I can think of several solutions:

  1. Doing a DNS resolve on every call (i.e using the Send overload which accepts a hostname parameter). This may actually be quite fast because of the Windows DNS cache, I don't know.
  2. Having some sort of DNS checker running on a timer thread to check periodically if the DNS alias resolves to a different IP. If it does, it would somehow update the UdpClient to use the new IP Address. However, I don't really want to be locking the UdpClient object on every call - as I said, performance is important.

Anybody got any experience of doing this?

From stackoverflow
  • I would separate the address resolution from the UdpClient.

    1. Use Dns class to resolve IPaddress (and store in local variable)
    2. Use the parameterless constructor of UdpClient,
    3. Don't do a connect on UdpClient
    4. Use the explicit Send with the IPEndPoint parameter.

    On a background thread:

    1. check every X seconds for updated DNS
    2. replace the local IPEndPoint variable you pass to your UdpClient.Send call.

    No need to destroy your UdpClient every time you do this. Also, no need to lock when updating the IPEndPoint. The worse case is that you have one dirty send to an old address, but since you are not instantly notified on updates, you will have dirty sends anyway.

EntityFramework ObjectQuery<T>.Include With Filter ability

Hi, I'm using ObjectQuery.CreateQuery() to create eSQL query. I want to use the ObjcetQuery.Include to load related data, like Customer => Orders so let the EF to load all the orders for customer at the same time. The issue is that i don't want all the related objects and i want to fetch the result with condition.

Any idea?

From stackoverflow
  • Include will not work if you intend to materialize a master entity (Customer) with only some of the related child entities (Orders). The Entity Framework will not materialize a partially-complete type. Instead, I would recommend projecting into a new, anonymous type. Then you can include whichever Orders you like.

WCF Self Hosted App on 64bit Windows Server

I have a windows application that acts as a WCF Service that I developed on a 32bit Windows Server 2008 box. I have tested the application and everything works fine when running it from my development machine, as well as from my 32bit workstation. However, when attempting to run the application on a 64bit Windows 2008 Server, the application does not run, and a Windows Error Report is generated stating that the application stopped working. I have attempted to build the application on my 32bit Development Workstation, targeting both x86 and x64, to no avail. The only time I can get the application to run is if I comment out the code that starts the WCF Service. So my question is, do I need to dev and/or build this application on a 64bit workstation to allow the application to run on a 64bit machine?

From stackoverflow

Is there any way to put my custom name to LIB folder which i am going to place in WEB-INF folder of struts application?

Is there any way to put my custom name to LIB folder which i am going to place in WEB-INF folder of struts application?

From stackoverflow
  • And why on earth you wanna do that? FYI, its lib not LIB.

  • No.

    Or yes… if you don't want its contents on the classpath.

Is it possible to get upcoming event / show information from a Myspace page without scraping?

I want to get show information from myspace artists. One way I could do this is ask an artist to input their myspace URL and I could try to scrape the page.

What I would really like to do is ask the artist for their myspace credentials and use the myspace api to get their show data. I cannot find how to do this on the myspace developers site. Does anyone know?

And as a side question, if I decide to go the page scraping route, is that legal? I feel like a lot of people do this.

From stackoverflow
  • Try out http://livekick.com . It includes all music concerts posted on myspace.

  • Found this great article on just that: scraping myspace for tour dates. Haven't tested it but looks good. http://bit.ly/14HWWM

When to use boost thread join function?

I've recently managed to create a thread using the boost::bind function.

For the time being, I'm having the thread display to stdout. I can see the output if I use thread.join. However, if I don't do this, I don't see any output.

Why is this?

I'm hoping I don't have to use the join function, because I would like to call this function multiple times, without having to wait for the previously launched thread to finish.

Thanks for your responses. What I really wanted to make sure of was that the thread actually executed. So I added a system call to touch a non-existent file, and it was there afterwards, so the thread did execute.

From stackoverflow
  • I can see the output if I use thread.join. However, if I don't do this, I don't see any output. Why is this?

    Most probably this is a side-effect of the way standard output is buffered on your system. Do you have '\n' and/or endl sprinkled around in every print statement? That should force output (endl will flush the stream in addition).

    If you look at the documentation for join, you'd see that this function is called to wait till until termination of the thread. When a thread is terminated (or for that matter, a process) all buffered output is flushed.

    You do not need to wait till the thread has completed execution in order to see output. There are at least a couple of ways (I can remember off the top of my head) you can achieve this:

    • Make cout/stdout unbuffered, or
    • Use \n and fflush(stdout) (for C-style I/O) or std::endl stream manipulator
    Skurmedel : Maybe you should rephrase "is called to terminate a thread". join does not terminate the thread, but makes the current thread wait for the one the join-method was called on. Which I'm sure you are aware of.
    Skurmedel : "wait for the one the join-method was called on to terminate." (SO needs an edit comment button.)
    dirkgently : Yes, and yes again.
  • By default the thread object's destructor does not join to the main thread, could it be that your main thread terminates and closes STDOUT before the thread manages to flush its output?

    Note that in C++0x the default destructor for thread does join (rather than detach as in boost) so this will not happen (see A plea to reconsider detach-on-destruction for thread objects).

  • It may help to show some example code. I will guess that your main() may exit before your thread can print. The join call makes main wait for the thread to complete.

  • Maybe mail thread is finishing...Paste your code, so we can help you

Is there anything in the Django / Python world equivalent to SimplePie Plugin for Wordpress?

I know that SimplePie itself is derived from UFP, but the features I'm wondering about are the post-processing features that are available in SimplePie for WordPress plugin:

http://simplepie.org/wiki/plugins/wordpress/simplepie_plugin_for_wordpress/processing

Can I find something similar to this for my Django application?

Can this be accomplished using Django inclusion tags?

From stackoverflow

Custom URL protocol in windows - emailing links

I have a custom URL protocol for an application I'm working on (as defined here: http://msdn.microsoft.com/en-us/library/aa767914.aspx). This protocol works fine, I can go to Start -> Run and type:

foo:1_1

And my application launches as expected. If I create a web page that has a link of that type, it works as expected (I get a warning from the browser, but that's no problem). My issue comes when I try and send an email from my program containing one of these links. Gmail, in particular, seems to be stripping out my link, so when I send an email that contains this link:

<a href='foo:1_1'>foo</a>

I'm left with this resulting HTML:

<a>foo</a>

It seems to be stripping out my href tag, which I'm guessing is because it doesn't recognize the protocol. Does anyone have any idea how I can get around this? I tested it with my ISP's email service, and the tag was left unmolested. Is this just something I'm going to have to live with, and tell my users to cut & paste the link into their Start -> Run box?

From stackoverflow
  • After some exploration, and seeing what another application does, I've come up with what seems like a suitable workaround:

    Rather than a direct link to our protocol, we'll make a link to a page on our site where we pass the parameters, that page will then create the link using our protocol. This seems to be how iTunes does it when you send links through iTunes.

    Jonas : Interestingly, this seems to work for all browsers but IE8 (unsure about IE7). FF and Chrome will dutifully open the link, but IE8 just gives me a generic "Internet Explorer cannot display the webpage" error. Bah!

What, if any, is the resource penalty for using System.Diagnostics.Stopwatch?

For example

foo() //Some operation bound by an external resource. db,I/O, whatever.

vs.

var watch = new Stopwatch();
watch.Start();
foo()
var time = watch.ElapsedMilliseconds
watch.Stop();
From stackoverflow
  • I believe Stopwatch is built on top of QueryPerformanceCounter, so each call results in a kernel transition. If foo() is very brief, the QPC overhead will dwarf it.

    If you're using Stopwatch to measure short tasks, you should run foo() many times (like thousands), and use Stopwatch around the whole batch. Divide the total time by the number of runs to get average time for the task.

    Sam Saffron : @Michael another thing that should be mentioned is that it will fallback to tickcount if QPC is not available
  • This sounds like a recursive answer but the only way to truly know the penalty of Stopwatch is to measure it. Measuring managed code usually involves Stopwatch instances.

    Stopwatch is only meant for diagnostic purposes though and should not be used in a retail application. Unless of course you are in a diagnostic mode. Hence this really shouldn't be an issue for non-diagnostic code. Can you provide some insight into your scenario so that we can give a better answer?

    Stopwatch instances are built (usually) on top of a QueryPerformanceCounter call. These are not free but they're not terribly expensive either. Anything that's worth measuring with a Stopwatch will be a long enough running task that the cost of the task will make the QueryPerformanceCounter call insignificant. Otherwise, why are you measuring it?

  • In my experience, there is some noticeable overhead when using the Stopwatch class. Certainly much more than using Environment.TickCount or such to measure time, but still not too great. However, this may or may not be a big problem for you. If the time period being measured is typically a very short one (as should usually be the case when using Stopwatch, given that other methods are just as good for timing longer periods), then performance shouldn't be affected perceptably, I'd imagine. Also, the end of this page has a bit to say about the cost of running a Stopwatch in your program. (Not sure I would take the advice on using it for constant program monitoring however.)

text-align syntax for sifr?

I'm having trouble finding usage/syntax for the text-align feature of sifr. This feature goes inside the flashvars parameter correct? So would it be something like:

sIFR.replace(fontname, { selector: 'h1', wmode: 'transparent', flashvars: 'textalign=center' });

I tried the above with no luck using r436 build.

From stackoverflow
  • Apparently you only need to edit the all.css file. Here's someone talking about this.

    If you don't want to change the css styling of a root element, then you can specify what CSS selection you are applying your sifr is referring to with the sSelector

  • You're confusing sIFR 2 and 3 syntax. flashvars no longer exists, for sIFR 3 specify it in the replacement CSS:

    sIFR.replace(fontname, { selector: 'h1', css: '.sIFR-root { textalign: center; }' });
    

    You can also specify background-color here, so you don't need to use transparency.

How to manage local sql server database files?

My system is for development, and I run a local copy of sql server 2005. I want to move all the database files out of program files, and put in a better location on another partition. To do this would you simply detach all the databases in SSMS, move the .mdf and .ldf files with windows explorer, then reattach?

From stackoverflow

Which Google API search module for Perl should I use?

Which Google API search module for Perl do you recommend?

REST::Google::Search or Google::Search

Ease of use is important because I only really need to get the top two, maybe three results from the web search.

Also, is there a module that one knows of for getting things from wikipedia? Again easy of use is important.

From stackoverflow
  • There doesn't appear to be much to choose between them.

    For what it's worth, I'd go with Google::Search, mostly because it's written using Moose under the hood :D

ASP.NET Is it possible to differentiate session length from user?

In asp.net session length, can it be of a different length depending on the type of user logging in? I want admin users to timeout after 3 hours, but standard users to timeout after 30mins, because staff in the office often have multiple windows open, and requested a longer session length. I'm a little sceptical about lengthening it for the outside world.

From stackoverflow
  • You can set the Session timeout (minutes).

     if (User.IsInRole("Admin"))
          Session.Timeout = 3 * 60;
    

SQL/.NET TableAdapters - How do I strongly-type calculated columns in either the database or the DataSet?

We use calculated columns in a few SQL Server 2005 tables which always return data of a specific type (bit, varchar(50), etc...).

These tables are consumed by a .NET data layer using strongly-typed datasets and tableadapters, however since the calculated columns are not constrained to a specific type (we always return a specific type, but we could return anything) .NET does not generate strongly-typed columns.

Three questions here: - The calcuated columns typically check that related records have specific values, or they return a single value from a related XML document using XPath. Are calculated columns the proper tool for this, or is there a better way to return these related pieces of data?

  • My searches say no, but is it possible to strongly-type these columns at the database itself?

  • Is there a workaround inside of the Visual Studio DataSet designer that would allow me to set the proper types and maintain them across DataSet/TableAdapter updates (since the Designer will query the database to update it's schema)?

Thanks!

From stackoverflow
  • In the queries that you use to return these values, you can use the SQL CAST() function to cast them as whatever datatype you want. I believe .NET should recognize the casted datatype and put that type in the dataset.

  • First, they do have a type.

    Second, the SQL Server will tell clients the type if the client requests it, whether its a C API client, a C# client, a JDBC client, etc. Otherwise, the clients can't correctly cat the type.

    Third, you can find out what type they have by looking at the information_schema.columns (or syscolumns) row for the calculated columns.

    Fourth, you can use the CAST operator to cast these columns to any type compatible with their actual types.

Can I assign keyboard shortcut to the Microsoft Intellitype keyboard?

Hi,

Anyone know if I can assign a keyboard shortcut such as "CTRL-F4" (for closing the current tab in IE/Firefix etc) to the Microsoft Keyboard favourite keys 1-5.

I have Microsoft Keyboard software installed and I can only browse to applications I want to run and cant seem to see anywhere else where I can assign shortcuts.

Thanks

From stackoverflow
  • Unlock the Function button on top of the Numkey pad, then use the F6/Close key ;)

    CheGueVerra : Have fun with your new SO addiction ;)
  • trouble is it takes 2 button presses - was just looking for a single button press maybe using the user defined buttons 1 to 5 to quickly close tabs / windows etc.

    CheGueVerra : It takes 2 buttons presses if you enabled disable it all the time, mine is not on to use the features.
  • There is a way! i've done it before! Now I can't figure out how I did it. I had all the media keys configured to Control-alt-home and stuff like that to match with Winamp since the default play pause wasn't working. But I can't figure out howI did it.

Surprise! the shell suggests command line switches

I noticed that the bash shell can suggest command line switches for your command.

Just type your command, a dash (-) and type tab. The shell will show you available switches.

For example, try:

andy@andyx:~$ java -

and press tab - Surprise!

Screenshot

The question is:

How do I interface with this feature. I.e., if I write a program that is to be run from the console, what's the API to tell the shell what switches are available?

From stackoverflow
  • You have discovered Bash's programmable completion feature.

  • See:

    $ man bash
    

    In particular, the section entitled "READLINE" and subsection "Programmable Completion"

  • FYI: In Ubuntu and/or Debian the scripts are at /etc/bash_completion.d/

How does Thickbox work for displaying another page Like Login page?

I ask this because I want to display a page in iframe and on clicking any link in iframe content, it should display it in the same iframe.

Check this site. and see how an iframe alow me to surf other sites.

From stackoverflow
  • that's not anything special, that's just how iframes work.

    however if any of those sites had an

    <a href="LINK" target="_top">text</a>
    

    It would break out of the iframe and load in the main page.

    There is no way that I am aware of to stop an iframe from taking over your window with target=_top links. You can't modify someone else's content in the iframe from your parent window, there are security issues with talking cross frame that prevent you from doing this.

    With Thickbox just load your html file and make sure you dont target=_top in any of thage pages you want to stay in the iframe.

    So copy & pasting from ThickBox's example, with some jQuery:

    <script>
      var height = 300;
      var width  = 300;
      $(function(){
         $("#execute").click(function(){
             $("#link1").attr('href',$('#go').val() + "?height=" + height *"&width=" + width).trigger('click');
         });
      });
    </script>
    
    <input type="text" name="go" id="go" />
    <button id="execute">Go >></button>
    
    <a id="link1" href="ajaxOverFlow.html?height=300&width=300" title="add a caption to title attribute / or leave blank" class="thickbox">Scrolling content</a>
    
  • The Facebox plugin will pull in remote pages in a Thickbox way.

How to localize ASP.NET MVC + Spark application?

I'm using the Spark view engine, and want to localize the website. The methods described for 'conventional' MVC view engine do not work. Has anyone done this already? Any help would be appreciated.

From stackoverflow
  • The spark release package includes some sample projects, and one of them is called "Internationalization". I haven't had a look myself yet since I am just getting started with Spark, but it seems to be what you are looking for.

Reading from RichTextBox in VC++

Hi,

I have to read the text character by character from a RichTextBox in VC++. I need a function like getch or getche.

From stackoverflow
  • If you want to read the text while it is typed by the user, you'll have to attach to the "key up/down" or "text changed" events (depending on your ulterior motives).

In Javascript, can I get the exact coordinates on text cluttered with tags (childNodes everywhere?)

Hi,

See the example below: it shows lines of text in a table (there's a good reason for this, but that's not the issue here).

Basically, all I need is a function that alert()'s me the perfect coordinates of the text selection when I click on the link. By perfect coordinates, I mean: line number of the start of the selection, line number of the end of the selection (those two are trivial-esque, I just use the number in the <td> id, offset of the start of the selection, offset of the end of the selection.

So, if I select

first line and it contains text
This is the second

I get an alert that says:

selection starts at line 1, offset 12
selection ends at line 2, offset 18

It would be really easy with getRange() (I do not need Internet Explorer compatibility so getRange() which work for FireFox, Chrome and Safari is OK) if the text was plain text. The issue here is that <span>, <strong> and <em> tags are everywhere and that each of them is a new childNode. So getRange() doesn't work.

I have not found a way to ignore markup. It seems there's no easy way to do that. But I'm no Javascript expert and maybe that there's a trick to ignore (or to make the function act as if it ignored) the tags in the text.

<a href="javacript: magicCode();">Select some text in the table then click here</a>
<table>
<tr>
<td id="content1">This <span class="one">is the</span> first line <span class="two">and it contains</span> text</td>
</tr>
<tr>
<td id="content2">This is the <span class="three">second line and it contains text</span></td>
</tr>
<tr>
<td id="content3"><span class="four">This is <span class="five">the third</span> line and it</span> contains text</td>
</tr>
<tr>
<td id="content4">This is <strong>the fourth <em>line</em> and it</strong> contains text</td>
</tr>
<tr>
<td id="content5">This is the fifth line and it contains text</td>
</tr>
</table>

Could anyone help my write my magicCode()?

Thanks!

From stackoverflow
  • You can use the .textContent property to get just the text values without the HTML. You could easily make it work in all browsers as well by checking for .innerText and using that if it exists, otherwise use .textContent. innerText works in IE and textContent works in Firefox/Chrome etc.

    Here's a sample of that:

     var content = document.getElementById('content1');
     if(content.innerText){
       alert(content.innerText);
     }else{
       alert(content.textContent);
     }
    
  • You may want to look into using the canvas tag to generate your text; it may be a bit complicated and over-the-top for your project.

    Bespin is a code editor created entirely with the canvas tag. I haven't look at the source so I can't tell you how they manage to render text and mimic text selection.

    https://bespin.mozilla.com/

How to get timezone value in SSRS

Hi,

I have SSRS reports which displays the execution time each time while running the report. I would like to display the timezone value next to it . How do i get that.

Thanks, Jaz

From stackoverflow
  • To get the timezone on the server, use:

    TimeZone.CurrentTimeZone.StandardName
    TimeZone.CurrentTimeZone.GetUtcOffset(Now()).ToString()
    
    PJ8 : Are you looking to display the server time zone? or the time zone of the person running the report?
  • How do display the time when the report was. This time should be displayed in the time zone of the person running the report. Any help would be appreaciated.

    Thanks in Advance...

    -- Datta

Vertical labels with google charts API?

Anyone know how to get x-axis labels to be vertical with google charts API?

I need to fit a lot of labels in a small chart.

Thanks

From stackoverflow
  • The API does not provide anyway to get verticle x-axis labels (unless i missed it cause i need it too) what we did was a combination of datapoint point labels and regular x-axis labels - not perfect but works

    Might try something like Dundas charts if you need more control

    Tony : can you specify the rotation for a data point label? do you have an example URL you can post? thanks!
    codemypantsoff : Nope there is nothing i have ever found to rotate any of the labels
  • Could you please write more details about your workaround ?

OpenGL rotate around a spot

Hi, I'm wanting to rotate a gluSphere around a fixed point in a circular motion, like a planet going around the sun.

Would it be best to use glRotatef or glTranslate?

Cheers!

From stackoverflow
  • glRotatef will multiply the current matrix by a rotation matrix. This can (given the right vector) do what you are attempting.

    glTranslatef will multiply the current matrix by a translation matrix, which would effectively "move" the object, not rotate it, so it will not be what you want.

    : So for a circular motion what glRotatef should I use to rotate around a set point?
    Tartley : I think it's true to say that he needs one of each - translate the object away from the origin, and then rotate about the origin. (where 'origin' is the center that you want to rotate around)
  • Translate away from the center and then rotate all the way

  • You'll have to do a little of both:

    • Make sure the sphere is "facing" the fixed point, so that translating forward with respect to the sphere puts you closer to the center of its orbit
    • glTranslatef the gluSphere forward to the point around which you want it to rotate
    • glRotatef the direction you want the sphere to orbit
    • glTranslatef backwards just as far as you went forward

    That way, your sphere stays the same distance from the center, but gets translated "around" in a nice orbit.

    : Cheers, spot on!

How to scale MySQL with multiple machines?

I have a web app running LAMP. We recently have an increase in load and is now looking at solutions to scale. Scaling apache is pretty easy we are just going to have multiple multiple machines hosting it and round robin the incoming traffic.

However, each instance of apache will talk with MySQL and eventually MySQL will be overloaded. How to scale MySQL across multiple machines in this setup? I have already looked at this but specifically we need the updates from the DB available immediately so I don't think replication is a good strategy here? Also hopefully this can be done with minimal code change.

PS. We have around a 1:1 read-write ratio.

From stackoverflow
  • There're only two strategies: replication and sharding. Replication comes often in place when you have less write and much read traffic, so you can redirect the reads to many slaves, with the pitfall of lots of replication traffic with the time and a probability for inconsitency.

    With sharding you shard your database tables across multiple machines (called functional sharding), which makes especially joins much harder. If this doenst fit anymore you also need to shard you rows across multiple machines, but this is no fun and depends a sharding layer implemented between you application and the database.

    Document oriented databases or column stores do this work for you, but they are currently optimized for OLAP not for OLTP.

  • You may not think replication is not the optimal strategy, but take a look at this link which provides a fairly simple and straightforward tip for using replication to help balance the load across several machines.

  • You should take a look at MySQL Performance Blog. Maybe you'll find something useful.

  • Clustrix (http://www.clustrix.com) has the best and easiest solution for this. We've built a clustered database system that looks just like a MySQL server, except this one can scale as far as you need to take it.

    I work there. Check us out.

Regular Expression engine that supports raw UTF-8?

Hi, I need a regular expression engine that supports raw UTF-8 - meaning, the UTF-8 string is stored in char * as two chars(or one, or less) - for example, Ab is the array {0x41,0x62}. Anyone know of an regex engine that can receive that format? I can convert to wchar_t if needed first.

From stackoverflow
  • The current implementation of PCRE (release 7.x) corresponds approxi- mately with Perl 5.10, including support for UTF-8 encoded strings and Unicode general category properties. However, UTF-8 and Unicode support has to be explicitly enabled; it is not the default. The Unicode tables correspond to Unicode release 5.1.

  • This page says that it is possible with Boost.Regex, on the condition that you configure and use ICU library.

  • Dealing with the non constant character length nature of UTF-8 makes it very hard to create algorithms (like regex).

    It's better to convert the utf-8 string to a unicode wstring with ICU and then use the wstring variant of boost::regex

What describes @property(.....) best? What's that actually good for?

All I think to know is, that it marks a property "public". And it creates setters and getters automatically. But when I don't have that, are my properties private?

What's the name of this "technology"? Why's there an @ in front of "property"?

From stackoverflow
  • My understanding is that the @ infront of property makes it a compiler directive. It tells the compiler to do things. In this case it creates tells the compiler how to create the getter and setter methods for the member variable. You could do this manually of course, but this is there so that the compiler can do it for you.

  • @property () type prop_name is just a signal to compiler to create two methods:

    -(type) propName;

    and

    -(void) setPropName; // Not created for readonly properties

    In objective-C all methods are public. Let is why all properties are public too

jXchange - How To Get Started?

jXchange is apparently some sort of Web Service made by a company called Jack Henry. It's used for (I'm assuming) talking to your core AS400 system.

I've quite literally found nothing useful for documentation on how to get started using this.

Does anyone have experience with this and can direct me to a good starting point?

From stackoverflow
  • You can email a request for help to VendorQA@jackhenry.com if you are working for one of our customers licensed to jXCHANGE. We do have vendor documentation available provided that you are sponsored by a JHA customer.

    Hugoware : That's too bad - It's unfortunate you can't learn the system before you pay for licenses, documentation, etc...

javax.comm: Error when device is disconnected

I have an application that reads data from a com port using javax.comm.

The problem I am having is that if the device that I'm reading from is unexpectedly disconnected I get an error in the console that says "WaitCommEvent: Error 5"

I have looked around and can't find any helpful information about this. I have set all of the notifyOn* methods to true so I think I should be receiving all of the events but I'm not catching this one.

The error message that is printed out does not come from anywhere in my code so it must be in the javax.comm package somewhere. Can anyone tell me how to handle this error so that I can close the com port properly when it occurs?

Thanks!

From stackoverflow
  • IF anyone is interested in this, I found a solution. I was using the javax.comm api but to solve the problem I replaced it with rxtx api (http://rxtx.qbang.org/wiki/index.php/Main_Page). No code changes were needed but now when the device is disconnected I receive an IOException with the message "Underlying input stream returned zero bytes". I handle that message and kick off a new thread. In the new thread I call port.close() and port.removeEventListener(). These two calls must be done in a new thread or the application will hang.

URL routes - registering problem

Hello All.

I've been using ASP.NET MVC for a few weeks, looking screencast, reading tutorials and so on. It turns out to be very interesting technology for me and I started to experimenting with it. I wrote simple web application which simply gets data from one table and shows it.

All works fine on my dev environment, but when I tried to "deploy" my simple web app onto my hosting I encountered a problem - URL routing was not working. After some digging into the problem I discovered, that for some reason Routes table is empty.

What may cause the problem? Why Application_Start method would not be called? And how to solve this problem?

P.S. I created my test web app using ASP.NET MVC 1.0 // template ASP.NET MVC Project. IIS7 runs in Intergrated mode, and I do not have access to its administration (only via web.config files).

From stackoverflow
  • Turns out to be deployment problem - I was not copying Global.asax file among the others.

Cannot add Entity Data Model in Visual Studio

I am running Visual Studio 08 Team Edition with .NET Framwork 3.5 SP1 on WinXP. I am trying to add a Entity Data Model to my project, however, the option to add an "ADO.NET Entity Data Model" selection does not appear. To give you a visual, I am essentially following the directions here ( http://www.aspfree.com/c/a/ASP.NET/Introduction-to-the-ADONET-Entity-Framework-using-ASPNET/) , but cannot get past step 5 (Right click on project and click Add New Item) because the option to add an EDM does not appear.

Any ideas? I'm sure I have all of the prerequisites.

From stackoverflow
  • 1) Is the target framework for your project set to .net 3.5? (in project options)

    2) Is it a website or webapp project? If website project, you need to add it under app_code...

    CoolGravatar : Yes, the target framework is set to 3.5
  • I'm guessing that your VS 2008 SP1 installation did not complete successfully. Here are some things to verify:

    1. Take a look at http://download.microsoft.com/download/A/2/8/A2807F78-C861-4B66-9B31-9205C3F22252/VS2008SP1Readme.htm and verify if any of the known issues apply in your scenario

    2. Open a Visual Studio 2008 SP1 command prompt and type: devenv.exe /setup [ENTER]

    3. Repair VS 2008 SP1 from "Add/Remove Programs" or try uninstalling and reinstalling VS 2008 SP1

    CoolGravatar : It looks like none of the issues apply. I type devenv.exe /setup but it returns nothing, just a newline and a prompt appears again. Is it supposed to do anything?
    Jose Basilio : devenv /setup does not display anything, it just restores settings behind the scenes. Have you tried repairing or even reinstalling your VS2008 SP1?
    CoolGravatar : I just ended up reinstalling VS 08 and SP1...it works now although I'm still curious as to why exactly I couldn't add an EDM. Thanks for the help
  • Can you verify that you have: Microsoft® Visual Studio Team System 2008 Database Edition GDR R2 The important thing to note is the GDR. Basically, it's like a service pack. They added some features, like Entity framework.

    non-R2 would be ok too. the article you linked above doesn't list this at all, but it's required for entity framework