I've got a simple question: I was wondering if it is possible to (temporary or permanent if possible) block the insertion of a record into a table with a specific value for a specific column. I'm using mysql with InnoDB  So I have this table Cart, which contains some columns and one of them is CartID (it is not the primary key thou). And I would like to block insertions in the table Cart with a specific CartID (let's say 100), while I'm doing work on another table in the DB.
I need help making a TRIGGER that compares two dates being entered into a table, but I'm not 100% on the syntax I should use.  Something like:  CREATE TRIGGER chk_dates    BEFORE INSERT ON `job_history`    FOR EACH ROW     BEGIN       IF( NEW.end_date &lt; OLD.start_date ) .../// error, don't insert data       ELSE .../// allow the data to be entered   My table job_history will have a start_date, and when end_date is entered, I want it to check to ensure that it isn't prior to start_date.    How do I accomplish this?
How do the Hat Dash points work? Can I use a Mac Mini as an Airplay audio receiver? I don't have an AppleTV (yet), but I do have a Mac Mini hooked up to some decent speakers.  Is there something I can run on it, so that it acts like an Airplay audio receiver?  (Video support isn't important to me.) How should I understand "$A$ unless $B$"? Why do all SSH-RSA Keys begin with "AAAAB3NzaC1yc"? $X_1, X_2, \ldots, X_n$ are $n$ i.i.d. uniform random variables. Let $Y = \min(X_1, X_2,\ldots, X_n)$. Then, what's the expectation of $Y$(i.e., $E(Y)$)?  I have conducted some simulations by Matlab, and the results show that $E(Y)$ may equal to $\frac{1}{n+1}$. Can anyone give a rigorous proof or some hints? Thanks! Libraries module. Where to extract? Where should I be extracting the  module, sites/all/modules or sites/all/libraries? Can I access private members from outside the class without using friends? Disclaimer Yes, I am fully aware that what I am asking about is totally stupid and that anyone who would wish to try such a thing in production code should be fired and/or shot.  I'm mainly looking to see if can be done. Now that that's out of the way, is there any way to access private class members in C++ from outside the class?  For example, is there any way to do this with pointer offsets? (Naive and otherwise non-production-ready techniques welcome) Update As noted in the comments, I asked this question because I wanted to write a blog post on over-encapsulation (and how it affects TDD).  I wanted to see if there was a way to say &quot;using private variables isn't a 100% reliable way to enforce encapsulation, even in C++.&quot;  At the end, I decided to focus more on how to solve the problem rather than why it's a problem, so I didn't feature some of the stuff brought up here as prominently as I had planned, but I still left a link. At any rate, if anyone's interested in how it came out, here it is:   (I suggest reading it before you decide that I'm crazy). how to fill color in image in particular area? Double decimal formatting in Java Make grub keep its default boot under kernel updates I dual-boot my machine and I want it to default to boot into windows so that whenever I restart the machine remotely from my home it will be able to get back into Windows (instead of Ubuntu).  The problem is that every time Ubuntu upgrades the kernel, I have to reset the default boot item of grub back to windows. This is because the grub menu loader uses positions i.e. 6 for default OS to boot. And when Ubuntu installs a new kernel it changes that order.  I am looking for a way to configure grub to remember its default boot item under kernel updates. Changing precision on a column in the attribute table without losing data? I have data in an Excel file that I want to join with a shapefile in my project. The Excel file contains values like volumes. The Excel file and the shapefile I want to join it with both contain the same property names.  The problem is, when I join the two, I get too many decimals in the attribute table. I get six, but I only want it to be one.  I tested to change the format of the cells to one decimal, and then I saved the file as *csv. But, somehow I seem to loose data in the process? It should be 42 rows that contains data in the column i am working with, but I end up with only like 10?  Another thing is that my property names contains the letters Å. Ä and Ö, perhaps this complicates things?  I read the question , but it doesn't mention the problem with the data loss.  My question was tagged with , but I didn't write what version I'm using. I use QGIS 2.2.0. Would it help to upgrade to the latest version? How to see the correctness of close/reopen votes? How can I see the ratio of my previous close/reopen votes that were correct (i.e. resulted in the question being closed/reopened) or incorrect (i.e. resulted in the question left open/closed)?   I am interested in this statistic, because it would help self-educate about the correct use of close/reopen votes. Idea of paying for things with time I recently read the .  This book had the idea of the time you live as something that can be used to pay for things. When you run out of "money" you die.  I was wondering is this the original source for this idea? Or does anyone know of an earlier book with the same idea? Updating a field programmatically, hook_node_update it normally shows in the bottom corner as a sort of 'pie' that fills up as the picture is downloaded, similar to the 'app downloading' pie when viewing a downloading app on the home page/s  prior to this the picture resolution is terrible How do I integrate the Poisson equation to determine the electric potential along a particular direction (e.g., $z$)? This question is a sequel of sorts to my  about .  In the paper, the authors performed molecular dynamics (MD) simulations of parallel-plate supercapacitors, in which liquid resides between the parallel-plate electrodes.  The system has a "slab" geometry, so the authors are only interested in variations of the liquid structure along the $z$ direction.  In my previous question, I asked about how particle number density is computed.  In this question, I would like to ask about how the electric potential is computed, given the charge density distribution.  Recall that in CGS (Gaussian) units, the Poisson equation is   $$\nabla^2 \Phi = -4\pi \rho$$  where $\Phi$ is the electric potential and $\rho$ is the charge density.  So the charge density $\rho$ is proportional to the Laplacian of the potential.  Now suppose I want to find the potential $\Phi(z)$ along $z$, by integrating the Poisson equation.  How can I do this?  In the paper, on page 254, the authors write down the average charge density $\bar{\rho}_{\alpha}(z)$ at $z$:  $$\bar{\rho}_{\alpha}(z) = A_0^{-1} \int_{-x_0}^{x_0} \int_{-y_0}^{y_0} dx^{\prime} \; dy^{\prime} \; \rho_{\alpha}(x^{\prime}, y^{\prime}, z)$$  where $\rho_{\alpha}(x, y, z)$ is the local charge density arising from the atomic charge distribution of ionic species $\alpha$, $\bar{\rho}_{\alpha}(z)$ is the average charge density at $z$ obtained by averaging $\rho_{\alpha}(x, y, z)$ over $x$ and $y$, and $\sum_{\alpha}$ denotes sum over ionic species.  The authors then integrate the Poisson equation to obtain $\Phi(z)$:  $$\Phi(z) = -4\pi \sum_{\alpha} \int_{-z_0}^z (z - z^{\prime}) \bar{\rho}_{\alpha}(z^{\prime}) \; dz^{\prime} \; \; \; \; \textbf{(eq. 2)}$$  My question is, how do I "integrate the Poisson equation" to obtain equation (2)?  How do I go from  $\nabla^2 \Phi = -4\pi \rho$ to equation (2)?  In paricular, where does the $(z - z^{\prime})$ factor come from?   Thanks for your time. Error when using apt-get update So I had been literally trying to fix my windows not being able to boot at all for more than 24 hours straight till now. I almost read every single article and troubleshooting step on the web to find a solution but nothing seems to work. I will keep it short as much as I can.  I did all of the following and it was:  "Reset this PC" gave an error "The required drive partition is missing"  "Refresh this PC" gave an error "The drive where windows is installed is locked. Please unlock and try again"  "System restore" gave an error something I don't actually remember but its like "Choose your OS and then try again"  "Automatic Repair" just failed to fix it and reverted me back to advanced options.   After all of that, I did  bootrec /fixboot bootrec /fixmbr bootrec /scanos bootrec /rebuildbcd bcdboot d:\windows (D is where I have the windows installed and C is for system reserved) bcdboot d:\windows /s c: /f ALL   All of these command prompt lines failed giving multiple errors like:  For REBUILDBCD, it said "Identified total windows installations: 1" then clicked "Y" to add it to the list and then it said "The requested system device cannot be found"  For bcdboot d:\windows it said Failure when attempting to copy boot files"   I wiped the disk multiple times using diskpart and installed fresh copies of windows on it 3 times but each time the installation will finish stage 1 (at a very slow pace) then when it restarts to continue installation, it simply won't boot (Windows logo and a spinning dot circle below forever)  I gave up and tried a totally new HDD and installed windows to it, it booted so normal and fast actually so I made sure it was not an issue with the windows.  Now I am booted from the new HDD and reformatted the old HDD and working on data recovery using easeus and it is finding my stuff luckily. It is also noticeable that the old HDD is making some noise while it is reading now as I scan for lost files.  My ultimate question is, will this HDD ever be able to used again? Even as a storage drive not as a drive I boot from? Because it is being seen through the bios boot menu and I see it in the disk management with healthy status. Can this HDD be fixed or I'm better off stop using it?  Here is a screenshot of the health status through SMART using HD Tune Pro: Test to see if the title length requirement can be circumvented by appending lots of dots. Is there a way to do concurrent editing? Is there a MediaWiki-like method for supporting concurrent editing of text bodies in Drupal 7?  If no feature currently exists, what are some decent PHP diff libraries that could be wrapped up by a Drupal module that could do the job?