Arabic Maqam Keyboard?

Question: I have read that the Arabic maqam system has 24 pitches in an octave. Are there any instruments (keyboards especially) that have been made specifically to be able to play all 24 tones?
Answer: First of all, let's get this fact out of the way: 24 pitches in an octave is a rather simplistic notational convention. It doesn't reflect the actual state of affairs at all. Actual number of notes can be much higher. One practitioner, for instance, claims to have identified at least 12 notes between his lowest e-flat and his highest e-natural. Anyone who tries to perform Arab music (or the music of other closely related traditions, like Turkish) with 24 equal-tempered tuning will quickly realize that it sounds horribly out of tune (for both western and oriental ears).
But this is for all possible maqams. In a usual musical piece, one maqam will be used, often with occasional modulations to other related maqams. The number of notes in a single maqam is usually only slightly higher than 7 per octave. So, in a usual song, you will most probably be using fewer than 12 notes per octave.
In some electronic keyboards, individual notes can be microtuned. This way you can play, for example, in the maqam rast on C by slightly lowering your E key (and with smaller slight adjustments to other keys). Such keyboards usually offer a preset system for tunings too. So you can change to appropriate tuning for the maqam before each song. From what I've seen, this seems to be the most popular choice for performing maqam music on a keyboard.
Keyboards with more than 12 keys per octave are uncommon but not at all unheard of. You can find literally hundreds of designs by searching for "microtonal keyboard". There are also solutions that sense which region of the key you press to change the pitch accordingly.
For other instruments, authentic Arab (and Turkish) instruments are of course capable of producing more than 12 notes per octave:
For string instruments, one obvious solution is to go fretless, like in oud. Turkish tambur uses 21 to 35 (depending on the practitioner) movable frets per octave. So, the performer can make slight adjustments in between pieces in order to better accommodate the maqam of the piece.
With ney and other flutes, musicians can bend the pitch by changing their embouchure and/or they can partially close a hole to produce the "in-between" notes.
Turkish qanuns have small levers for fine tuning that enable the performer to divide the octave in roughly 72 equally spaced pitches. Here you can see the performer manipulating the levers with his left hand. That's right, seventy two!¹ Take that 24 :)
Apart from that, several western instruments can also produce microtones. Clarinet (sometimes with slight modifications) is actually quite popular in Turkish music for example.
Finally, there are experimental designs that are yet to prove popular.
¹ Actually that's not quite true. Usually not all 72 pitches are available.
Comment: the [fluid piano](https://www.youtube.com/watch?v=vr3L-Fv2lX8) is another experimental instrument that I hope people will find relevant and interesting here, a dynamically retunable piano.  Can be used to bend notes on the fly or just tune the piano to specific not ET scales for a whole piece.  Being as how I think there are only a couple in existence though, a synth might be more practical...
Comment: How well does 19TET work with a maqam music?  I'm pretty ignorant about middle eastern music theory, but I have been listening a lot to persian, armenian, and arabic music recently, and one of the things that really sticks out to me is the "not minor or major" 2nd that seems to come up quite a lot; like a D "half flat" in C. 19TET has the "western" scale down well (better thirds, slightly worse fifths) but also has the "in between" 2nds and 7ths that I hear in middle eastern music.  Having said that, my ears aren't finely tuned to those scales, so it might only be a really rough approximation.

Arabic Maqam Keyboard?


what controller do we use in robots that has forward and inverse kinematics?

Question: i used ATmega328p chip to make a car, but its the car is always controlled by me.
my question is in robotic arms , the arm moves using the kinematics that i put, what chip and programming language should i use? i know of matlab which works with matrices, but what chip works with it?
Comment: why you do not use ATmega328p for example? It is complete computer, you can program it to do nearly everything you want (with some limitation given computing speed and memory, but both can be improved if needed)?
Answer: There are a number of way to integrate code written in Matlab to a number of platforms. For a robot arm, you would most likely need a processor with a floating point unit.
Probably the most cost effective solution is to use a Raspberry Pi. It is officially supported as a platform by Matlab (Simulink), so you may be able to transfer matlab code directly to the Pi (please look up the limitations here)
Arduino is also supported by Matlab (however computational performance is more limited then the rPi).
If you want to use different chips, Matlab can generare C/C++ code from Matlab or Simulink applications. It require some coding knowledge, but you can incorporate these to an IDE using the same language and use them even if Matlab does not officially support the integration to that IDE.
Answer: Matlab doesn't run on the Atmega328p. You have to use a separate computer, which runs Matlab, and then use some kind of data transmission from the computer to the chip to tell it where to go. I e, the chip would receive solved joint angles from the transmission, and drive the actuators to those angles.
If you need to run the Matlab on your particular robot, then you need a computer on the robot that can run Matlab. An Intel NUC is a good choice for this. You'll still need some way to get the data from Matlab to the actuators; either use actuators with a built-in serial bus (such as Robotis Dynamixel servos and the USB2Dynamixel serial interface) or use your Atmega328p as a translator from Matlab commands to actuator signals.
Another option is to write the forward kinematics directly in C++ code. This requires that you're OK with linear algebra details and with C++ programming. Most microcontrollers can do well in this situation, but I'd recommend something reasonably modern an powerful, such as the Teensy 3.5 from PJRC: https://www.pjrc.com/store/teensy35.html
It has a hardware floating point unit, which is great, and a good set of libraries and integration into the Arduino IDE, so it will look similar to what you're used to.


Is there a way to replicate Postgres databases in Amazon RDS between regions?

Question: We have a Postgres RDS instance in the AWS Oregon Region.  For some supposed legal reasons, we have to host our client's European data in the Ireland AWS Region, but we need that data synchronized to the Oregon Region.  We will probably have to have an instance in the Singapore Region eventually, too.
We would like the databases to all be synchronized across regions.
Is this something that can even be done with Postgres RDS instances, or is MySQL the only database in RDS that supports this concept of replication between regions?
Any input on this matter would help.  We really enjoy how RDS makes administering the databases so easy, but if RDS can't allow us to sync databases between regions with Postgres, then we'll have to switch back to EC2 Linux instances with Postgres.
Comment: The last I saw RDS PostgreSQL can't do this, though of course the underlying PostgreSQL engine can. See this post: http://dba.stackexchange.com/questions/61305/get-wal-files-from-aws-rds-postgresql-instance
Answer: AWS offers cross region data replication for MySQL RDS with a few clicks on aws console cross-region replication for MySQL, but not for postgreSQL yet, maybe in the future they will provide such functionality.
However, you might be able to implement such replication across regions with ec2 instances and avoiding RDS instances.


Can someone explain in simple terms what is the disruptor pattern?

Question: I would like if you could explain to me in a simple way how does the disruptor patter work. This concept has been elusive to me as of know.
Perhaps with your help I could comprehend it.
Comment: http://stackoverflow.com/questions/6559308/how-does-lmaxs-disruptor-pattern-work
Answer: The Fowler Article providers a good primer, and this explanation:

At a crude level you can think of a Disruptor as a multicast graph of
queues where producers put objects on it that are sent to all the
consumers for parallel consumption through separate downstream queues.
When you look inside you see that this network of queues is really a
single data structure - a ring buffer.
Each producer and consumer has
a sequence counter to indicate which slot in the buffer it's currently
working on. Each producer/consumer writes its own sequence counter but
can read the others' sequence counters. This way the producer can read
the consumers' counters to ensure the slot it wants to write in is
available without any locks on the counters. Similarly a consumer can
ensure it only processes messages once another consumer is done with
it by watching the counters.

A more conventional approach might use a Producer Queue and a Consumer Queue, each using locks as concurrency mechanisms.  In practice, what happens with producer and consumer queues is that the queues are either completely empty or completely full most of the time, which causes lock contention and wasted clock cycles.  The disruptor alleviates this, in part, by having all of the producers and consumers use the same queue mechanism, coordinating with each other by watching the sequence counters rather than using locking mechanisms.
Answer: From this article about CoralQueue:

The disruptor pattern is a batching queue backed up by a circular
  array (i.e. the ring buffer) filled with pre-allocated transfer objects which uses
  memory-barriers to synchronize producers and consumers through
  sequences.

So producers and consumers do not step on each other inside the circular array by checking their corresponding sequences. And to communicate their sequences back and forth to each other they use memory-barriers instead of locks. That's the fastest lock-free way that they can communicate.
Fortunately you don't need to get down to the internal details of the disruptor pattern to use it. Besides the LMAX implementation there is CoralQueue developed by Coral Blocks, with which I am affiliated. Some people find it easier to understand a concept by reading code, so below is a simple example of a single producer sending messages to a single consumer. You can also check this question for a demultiplexer (one producer to many consumers) example.
<code>package com.coralblocks.coralqueue.sample.queue;

import com.coralblocks.coralqueue.AtomicQueue;
import com.coralblocks.coralqueue.Queue;
import com.coralblocks.coralqueue.util.Builder;

public class Basics {

    public static void main(String[] args) {

        final Queue<StringBuilder> queue = new AtomicQueue<StringBuilder>(1024, new Builder<StringBuilder>() {
            @Override
            public StringBuilder newInstance() {
                return new StringBuilder(1024);
            }
        });

        Thread producer = new Thread(new Runnable() {

            private final StringBuilder getStringBuilder() {
                StringBuilder sb;
                while((sb = queue.nextToDispatch()) == null) {
                    // queue can be full if the size of the queue
                    // is small and/or the consumer is too slow

                    // busy spin (you can also use a wait strategy instead)
                }
                return sb;
            }

            @Override
            public void run() {

                StringBuilder sb;

                while(true) { // the main loop of the thread

                    // (...) do whatever you have to do here...

                    // and whenever you want to send a message to
                    // the other thread you can just do:
                    sb = getStringBuilder();
                    sb.setLength(0);
                    sb.append("Hello!");
                    queue.flush();

                    // you can also send in batches to increase throughput:
                    sb = getStringBuilder();
                    sb.setLength(0);
                    sb.append("Hi!");

                    sb = getStringBuilder();
                    sb.setLength(0);
                    sb.append("Hi again!");

                    queue.flush(); // dispatch the two messages above...
                }
            }
        }, "Producer");

        Thread consumer = new Thread(new Runnable() {

            @Override
            public void run() {

                while (true) { // the main loop of the thread

                    // (...) do whatever you have to do here...

                    // and whenever you want to check if the producer
                    // has sent a message you just do:

                    long avail;
                    while((avail = queue.availableToPoll()) == 0) {
                        // queue can be empty!
                        // busy spin (you can also use a wait strategy instead)
                    }

                    for(int i = 0; i < avail; i++) {
                        StringBuilder sb = queue.poll();
                        // (...) do whatever you want to do with the data
                        // just don't call toString() to create garbage...
                        // copy byte-by-byte instead...
                    }
                    queue.donePolling();
                }
            }
        }, "Consumer");

        consumer.start();
        producer.start();
    }
}
</code>
Disclaimer: I am one of the developers of CoralQueue.
Answer: Disruptor pattern is the circular buffer queue that based on the following concepts:

Prevent false sharing using contended memory. Put the events into separated cache lines.
Use memory barrier to propagate write signal to producers and consumers.
Array backed to fast access to the continuous memory cells (based on cpu cache)
Early initialization to prevent high GC time and decrease latency of event adding.
Use busy spin loop and CAS instruction instead of mutex and semaphore to handle read and write contentions.


Unable to locate "fim" package

Question: sudo apt-get install fim results in the error message "unable to locate package fim". fbi seems to be fine though. Any idea why?
Answer: It appears that fim simply isn't in the Jessie repository. If you like, you can install it manually using the following steps.

Download the source code from its project webpage.
Install some dependencies: sudo apt-get install -y flex bision libreadline-dev libexif-dev libpng-dev libjpeg-dev libgif-dev libtiff-dev libpoppler-dev These were the libraries I was missing. I already have a lot of development libraries installed, so you may be missing more than this. Feel free to leave a comment if you get an error from this step.
Extract the source tar xfa fim-0.5-trunk.tar.gz
Enter the new directory cd fim-0.5-trunk
Configure the software by running ./configure
When that's finished, compile the software by running: make. Do not use the -j option. The Makefile does not appear to be properly configured for it. Note: this will take a long time to run, especially if you're not using an RPi 2.  Grab a cup of coffee or something and be patient.
Install the software by running: sudo make install
Refresh your session. If you're using the default bash shell, this is accomplished by typing source ~/.bashrc
Enjoy your new software. At this point you can delete the directory you extracted the source files to; you no longer need it.
Comment: `fbi` (Frame buffer viewer) is a current package [fbi 2.10-2+b1_armhf.deb](http://archive.raspbian.org/raspbian/pool/main/f/fbi/fbi_2.10-2%2bb1_armhf.deb) and is dated 2015-12-19 at the time of writing.  However `fim` is old [fim_0.3-beta-prerelease-1.3_armhf.deb](http://archive.raspbian.org/raspbian/pool/main/f/fim/fim_0.3-beta-prerelease-1.3_armhf.deb) (Scriptable frame buffer and ascii art image viewer) dated 2012-05-10, it is NOT in the Jessie Debian distribution but only in the Wheezy one - as Raspbian is derived from Debian it is not surprising that that package is not available.
Answer: Actually there is a new Fim build dated 2016/01/31.
Compile istructions follow. Successfully built on a Raspbian Jessie as root user.
apt-get install -y flex bison libreadline-dev libexif-dev libpng-dev libjpeg-dev libgif-dev libtiff-dev libpoppler-dev checkinstall #maybe others on your system.

wget http://download.savannah.nongnu.org/releases/fbi-improved/fim-0.5-rc1.tar.gz
tar -xf fim-0.5-rc1.tar.gz
cd fim-0.5-rc1

./configure --disable-readline
mkdir -p /usr/local/share/doc # Fim will fail creating by itself.
checkinstall

Change the Version field in the Checkinstall values page into a numeric one, otherwise it will fail compiling (Checkinstall issue).
Previous commands will compile Fim with framebuffer (built-in) support only and directly create a standard .deb package.
You should add the "non-dev" version of the dev- installed packages as dependencies in the Checkinstall Requires field in order for the .deb to be correctly installed on another Raspbian Jessie.
Notes.
--enable-exiftool flag seems not to work with this upstream release.
Use ./configure --help=short for a complete list of configure options specific to Fim.

Unable to locate "fim" package


Should the order of a filter be proportional to the sampling rate?

Question: I have designed a fir filter with my desired frequency response at a specific sampling rate and filter order. If I were to redesign my filter for a new higher sampling rate, should I change the filter order? I am having trouble understanding how the same filter order influences the desired frequency response at different sampling rates.
Comment: To be more clear, I assume you have an analog signal $x_a(t)$ which is to be sampled at a rate $F_s$ samples per second and you will process those samples $x[n]$ in discrete-time with your designed FIR filter $h[n]$ and you wonder what to do with the FIR filter, if the sampling rate $F_s$ is changed, such as doubled ?
Comment: Right that is what I am asking but specifically for the filter order when the sampling rate is changed. The typical way I create a Fir filter is by windowing the corresponding iir filter impulse response.
Comment: You already selected the answer but you have a more serious problem than the filter order here. Your Effective Frequency response on the signal will change due to sampling rate change (or stated the other way: the input signal's Frequency spectrum on the Discrete time domain will shrink) and you must redesign your filter (not only changing the order) to have the same Frequency Response with the previous one.
Comment: I stated that I am redesigning my filter for the new sampling rate. Assuming that it was redesigned but the order was kept the same is where my concerns start.
Comment: ok I just missed it somehow.!
Answer: Keeping the FIR filter the same order and doubling the sample rate will effectively halve the accuracy of frequency resolution which will be noticable at low frequencies (this is based on the assumption you are using something like FFT to create your FIR, otherwise the order of the FIR and it's resolution is a bit more complicated).


Are there psychiatric medications that have an anti-tolerance effect?

Question: Patients usually develop tolerance to their psychiatric medications when used over a long period of time. This is because of how the brain gets used to the dosage in order to reach equilibrium again. Are there any that have an anti-tolerance effect? Which means over time you would need less and less of the medication to get the same effect?
Answer: I don't know of any drug therapy that becomes less with use, especially for treatment of psychological disorders. The only instance I would know of is an individual is attempting to remove a medication to try something new/ different. The basic reasoning is described below.
There is an understanding of the pharmacodynamics of how the drugs or medications are believed to behave when interacting with the brain. Receptor cites can also be a factor, and will depend on if the medication is believed to be an agonistic action, or an antagonistic action (does it block receptors from uptake, or does it increase?). Either way, the neurobiology of the brain at the synapse of the neurotransmitter is believed to change, and the amount of certain chemicals could change as well.
Another few contributing factors would be how the therapeutic range for the medication is thought of by the pharmacological community, or how much dosage an individual needs for the medication to be therapeutic. Anyone that has been on a medication longer-term might experience withdraw effects when reducing the medication because the brain isn't able to take over production of the "needed" neurotransmitters. A half-life discusses how long the drug will remain in the body, and at what point it might stop the therapeutic range, which is why some dosing is over several ingestion cycles verses an extended release.
I highly recommend the book "A Primer of Drug Action" by Julien, Adcokat and Comaty (2011) for further reading. It describes a lot of medications and drugs. There are a variety of understandings of these medications and drugs currently.


Proper way to wire 4 light switches

Question: I have a two switch box with a single light on one switch and a ceiling fan and two separate lights on the second switch. There are 5 sets of wires coming into the box with one being the main feed. I want to separate the fan and two lights onto their own switch each... The way it is currently wired is a little confusing. All white wires are twist cap together as well as all the grounds.  The black wires are what is confusing... there is black coming into the bottom and top of each switch. Can anyone provide a diagram of what the wiring should look like for the four switch configuration?
Comment: Can you provide a diagram or pictures of what you have now?
Comment: @DanielEvans 5 sets of wires, 1 double switch (Light and Fan), 2 Lights on a switch. [3 switches] yet you have 5 wire sets (are you positive you have 5 wire sets? AND only ONE line In feed? ). Clarify how the wires are connected to the switch that controls the 2 lights. Something seems odd.
Re-reading your question I am thinking you have two main feed lines  [1 for your ceiling fan/light, and 1 for your 2 lights. This is very important you verify what you have .
Answer: All white wires are twist cap together as well as all the grounds.
This is normal.
The black wires are easy the first is the main feed - you will need to feed a black wire from each Switch Line In to the next Switch Line In [Also referred to as Daisy Chaining].
The below is an example - the order of what is a light and what is a fan does not matter.
Comment: Thanks for the reply... I figured it out... one of the sets of wires coming into the switch box, I had assumed was one of the three lights, was actually an outlet which needed to be wired for always hot.  Turns out the wires for that light were ran from one of the other light's receptacle box.  Found out, after I had wired everything like you have above, when my outlet wouldn't work unless I had the switch on.  That was a quick fix... just moved that black to the always hot side of the switch. That's what happens when you can't see through walls... lol
Comment: Electricaly, pitch perfect.   Mechanically though, daisy chaining switches is hard.  They generally don't have 2 wires per terminal (except Leviton and competitor screw-and-clamp types do). You'll either need to use those, or do some fancy mid-wire insulation stripping, or bring a bottom wire off each switch and pigtail them to the line in.
Comment: @Harper all the recent ones I have seen have both the terminal and push in connections. Maybe I am just accustomed to it now and thought all manufacturers did that as a standard. I guess I will need to make sure I pay close attention when I am buying them.
Comment: They only have 1 terminal or 1 backstab.  **You're not supposed to use both at once**, one binding system or the other.  And besides, it's pretty much the consensus around here that backstabs shouldn't be used *at all*, because they have a disturbingly high failure rate, not to mention they are not legal with either stranded or 12AWG wire.
Comment: @DanialEvans if you feel this is the answer - please click on the number area to mark as answer .
Answer: To clear up your confusion, have a look at a basic light circuit. Two blacks on the switch is very common:

You probably can't separate the lights without running additional cables. They're connected in a string, and you can't switch them independently unless the hot for each passes through the switch box.
Comment: the op states: 5 sets of wires, 1 double switch (Light and Fan), 2 Lights on a switch. [3 switches] yet he has 5 wire sets. Which seems a bit strange for what he describes you would think only 4 wire sets.
Based on his description I can see why you stated he might have to run another wire set (but he seems to have that already) and I understand why you put the multiple lights picture up. I think the op will need to either accept an answer or clarify his question.
Comment: Thanks for the replies and suggestions... I did have to run another set of wires and had to take out 4 feet of dry wall to do it... but have it all patched up now.
Comment: Please provide and accept an answer or delete your question so this post can be resolved.

Proper way to wire 4 light switches


Can an offensive lineman catch a lateral in high school football?

Question: In high school football, can an offensive lineman legally catch a lateral pass? Does it make any difference if a receiver is covering him from the snap?
Comment: There may be an issue with the jersey number.
Comment: You mean specifically, a lineman who is not an eligible receiver?  (IE, someone with a lineman's number, who is lined up in a lineman's spot and not declared to the referee as eligible)?  Or are you asking if someone who is declared eligible but is wearing a lineman's number?
Comment: Jersey # is not an issue with "lateral" passes. (My rule references come directly from the 2016 NFHS Football Rules Book.) Lateral passes are grouped with backwards passes. Rule 2-31-5 A backward pass is a pass thrown with its initial direction parallel with or toward the runner's end line.

Rule 7-5-6 Pass eligibility rules apply only to a legal forward pass. Rule 7-5-6-a. All A players eligible by position and number include those who, at the time of the snap, are on the ends of their scrimmage line or legally behind the line (possible total of six) and are numbered 1 to 49 or 80 to 99.
Answer: As far as I understand, from reading the most recent NHFS rulebook I can find online, there is no specific difference here between high school and any other level of play.  As such, any player may receive a lateral or backward pass, regardless of position or number; only passes deemed forward passes are restricted to eligible recievers.

Rule 7-4

Article 1... During any down, any player in possession may make a backward pass [...]
Article 2... If a fumble or backward pass is caught or recovered by any player, he may advance.
Comment: Agreed. 2016 NFHS Football Rules Book Rule 7-5-6 Pass eligibility rules apply only to a legal forward pass. The following players are eligible pass receivers: a. All A players eligible by position and number include those who, at the time of the snap, are on the ends of their scrimmage line or legally behind the line (possible total of six) and are numbered 1 to 49 or 80 to 99.
Comment: This does not apply to planned loose balls: 2016 NFHS Football Rules Book Rule 7-2-8 Any A (offense or kick team) player on his line of scrimmage may not advance a planned loose ball in the vicinity of the snapper.
Comment: This does not apply to handing the ball forward: 2016 NFHS Football Rules Book Rule 7-3-2 No player may hand the ball forward except during a scrimmage down before a change of possession, provided both players are in or behind the neutral zone and it is to: a. A lineman who has clearly faced his end line by moving both feet in a half-turn and is at least 1 yard behind his line when he receives the ball. b. A back or a teammate who, at the snap, was on an end of his line and was not the snapper nor adjacent to the snapper.
Answer: T, wearing #75, lines up in the left tackle position. After the snap, T fakes blocking and then takes a few steps back and to his left. QB fakes a hand off to RB and, while rolling right, stops, turns around, and throws the ball backwards(from the original line of scrimmage) to T. T proceeds to run it in for a touchdown.
Ruling: Touchdown. Although T does not have a jersey number permitting him to catch a forward pass, he (and any other player on the offense) may catch a backward lateral pass.
Comment: Copy-pasta answers, especially without attribution and without further explanation, are very poor form. Either fix these issues or remove the material (which you are unlikely to have permission to use, currently).
Comment: This looks convincing, but what's the source?


M-Audio Jamlab & LMMS / Ubuntu Studio

Question: Is there a way to get M-Audio Jamlab working with LMMS and / or Ubuntu Studio in elementary OS?
I haven't found an appropriate driver yet...

I'm on a Macbook (3,1 - late 2007).
Answer: To get guitars or other "non-digital" (MIDI) equipment working with Linux, you will need to learn how to use JACK. Using a program called Catia from the KXStudio repository is much much easier than QJackCtl.
You will also need to make sure pavucontrol and pulseaudio-module-jack is installed.
My favorite cable so far has been a Rocksmith USB guitar cable, though they go out after regular use in a few months. Buying any audio cable with an LED light on it doesn't make any sense to me (buzzing).
Quick disclaimer
You may not be able to get LMMS working with JACK since I think it is technically dependent on Wine to work. If not, and still want to record, you could still try Ardour or Audacity.
Open PulseAudio Volume Control (pavucontrol) and look under configuration and make sure the USB M-Audio JamLab device is set to input only (I doubt you'll get both in/out working). Then, go to Input Devices tab and make sure JamLab device is the one being used. Go to Output Devices tab and make sure audio is going to the headphones or whatever you want.
Open Catia --> Tools --> Jack Server --> Configure Jack
Select Duplex Mode and make sure the Input Device and the Output Devices are correct.
Click OK, Next, go to Tools --> Jack Server --> Start Jack Server
Open the applications you want to use Catia to pipe audio through. Linux has programs like Guitarix and Rakarrack for guitar. You move the virtual cables in Catia around to make connections.
BE AWARE
That just because you stop the Jack server, you will also have to run killall jack or use htop to find and stop the process. If your audio still acts funny afterwards, try killall pulseaudio.
Your are kind of lucky, even though you have an older MacBook, because I have a newer one with an actual HDMI port (so video and audio), and it has been nothing but hell trying to get Jack and PulseAudio to work properly. I have to kill pulseaudio to get it to reset just for normal things like Kodi or Firefox videos sometimes. And, sometimes my HDMI as an option disappears all together. If you plan to buy a newer laptop soon for Linux-only and want an actual HDMI port, don't get an Apple.
Comment: Thank you, @TheOuterLinux, for this very good information.

M-Audio Jamlab & LMMS / Ubuntu Studio


How do you troubleshoot character encoding problems?

Question: If all you see is the ugly no-char boxes, what tools or strategies do you use to figure out what went wrong?
(The specific scenario I'm facing is no-char boxes within a <select> when it should be showing Japanese chars.)
Answer: Firstly, "ugly no-char boxes" might not be an encoding problem, they might just be a sign you don't have a font installed that can display the glyphs in the page.
Most character encoding problems happen when strings are being passed from one system to another. For webapps, this is usually between the browser and the application, between the application and the filesystem and between the application and the database.
So you need to check where the mis-encoded data is coming from, what character encoding it has at the source, and what encoding it is being received as. The best way is to send through characters you know the system is having problems with, and examine them at each level of the app. What do they look like inside the app? In the database? When you get them back from the database? When they're displayed in the browser?
Sorry to be so general, but the question doesn't give much more to work with.
Comment: Also make sure the application (console, editor, webpage) you are watching the characters with is correctly configured to show the expected character set.
Answer: If the data you send to the browser becomes mangled (moji-bake) you will get trash characters. Also, if you specify the wrong character set in your META headers, your browser will render the page incorrectly, causing moji-bake again, sometimes in random places on the page.
When handling CJK character sets, you must be sure to use UTF8 character encoding throughout the lifetime of your program (data storage, retrieval, data manipulation in your code, displaying in the browsser etc...)
What is UTF8?
UTF8 handles binary streams of data, not strings. This means the bit combinations can have variable length. ASCII characters have a fixed length of 8 bits representing 1 byte, however UTF8 characters can be composed of 6bits, 8bits, 12bits, etc... As such, UTF8 is prone to what Japanese call "mojibake".
As a coder, from database to codebase to browser, you should try and use UTF8 completely. For email you can use UTF8, but you will probably find most mail servers and clients are still old and use a mishmash of different character sets (e.g. ISO9022X).
Database Settings
If you are a mysql user, then make sure you have to ensure all connections to the DB use UTF8, and that all tables/fields use UTF8. By default mysql uses Latin (Swedish) character sets. Those kooky swedes love their sense of humour!!
Checking your Codebase
In my experience editors like Notepad++, Notepad2, UltraEdit, e, etc... all have UTF8 support problems. They mostly work, but since their developers don't use CJK languages themselves, they are not perfected. Issues like turning off BOM (Byte Order Mark), mangled tabs, poor character set conversion, etc ... all present problems.
I highly recommend using a proven UTF8 editor like Maruo. This is made by a Japanese company, but there is an English version (and a trial version) at http://www.hidemaru.interlink.or.jp/software/
Lastly, you may need to convert your source files into UTF8. Especially if the codebase itself has CJK language strings contained therein.
Manipulating Strings
Any string function need to multibyte safe. Notice I didn't say double-byte. UTF8 is not a double byte but multibyte, depending on the total number of bits used to represent a character. In PHP you need to call the MB string functions specifically. Ruby and other languages have more transparent support, but you need to check the docs for your flavour of application server!
META Tags
Check out google.co.jp or yahoo.co.jp for their META headers. These are sites that know how to to it properly. Basically include the following META tag the doucment <HEAD>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
It is usually safe to mix English HTML document type attributes with the above character too. So adding the META tag above seems to work in a HTML document that has:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
Email
This is a wholly different can of worms. UTF8 works a lot, but many older Japanese clients use ISO2022X more. This is not worth covering here.
Debugging UTF8 Issues
Once you have a reliable UTF8 editor like Maruo, you can create static pages and resolve your issues.
Hope that helps
Answer: Redirect the data to disk and use a Hex Editor. Most text editors / viewers do their own conversions behind the scenes, so it is difficult to be sure you are seeing the data in it's true form.


Energy of a signal

Question: Suppose that $E(k)$ be the energy distribution of a signal in spectral domain with a finite total energy. Is there anyway to concentrates all the energy of signal around a specific point?
Comment: Is the "specific point" that you are thinking about in the frequency domain or in the time domain? Are nonlinear methods acceptable or are you thinking about linear filtering only?
Comment: Bandpass filter with a very narrow passband plus normalization to the original level?
Answer: Yes indeed. Bear with me, I am in a mood for a long explanation.
Remember physics of motion, and how one concentrates the information related to the motion of an object on its center of mass, that capture a unique point from a distribution of mass.
A similar reasoning can be applied to positive quantities $q(k)$ (like energy) whose sum is finite. Thus, you can normalize them to  unitless and positive quantities  $q(k)/\sum_k q(k)$ that sums to $1$, similarly to probability distributions.
There, to characterize or summarize distributions with a few values, you can use the notion of moments (probably borrowed from the same moment notion in physics) or cumulants:

an expression involving the product of a distance and another physical
  quantity, and in this way it accounts for how the physical quantity is
  located or arranged

The $\alpha$ moments $m_q(c,\alpha)$ of  $q(\cdot)$, centered around $c$, are given by:
$$m_q(c,\alpha) = \sum_l (l-c)^\alpha \frac{q(l)}{\sum_k q(k)} =  \frac{\sum_l (l-c)^\alpha q(l)}{\sum_k q(k)} \,.$$
Here, the $q$s can be interpreted as unit-sum weights, affecting the "distance" $(l-c)^\alpha$ (more a power-norm, to be honest).
So, in discrete signal processing, using orthogonal or energy-preserving transformations, it is customary to take $q(\cdot)$ as the energy of signal samples, either in the time or the frequency domain. And $l,k$ are discrete indices. For distribution location, we usually set $\alpha=1$.
So for finite-energy signal $s[n]$, you can define its "center mass" in time with:
$$ \overline{s} =\frac{\sum_n n |s[n]|^2}{\sum_n |s[n]|^2}$$
and in frequency by:
$$ \overline{E} =\frac{\sum_k k E[k]}{\sum_k E[k]}$$
but beware in summing on positive frequencies only for a meaninful interpretation for real signals (as spectra are symmetric, and would yield a center of frequency mass at $0$).
To illustrate it with a picture and a Matlab code (using FFTR.m):

<code>clear all;
timeStart = 0;
timeStop = 1;
nPoint = 1024;
time = linspace(timeStart,timeStop,nPoint)';
dataFreqSampling = 1/median(diff(time));
dataFreq = 56;
dataSpread  = 0.2;
data = sin(2*pi*dataFreq*time).*exp(-((time-(timeStop-timeStart)/16)/(dataSpread)).^2);

dataEnergy = data.^2;
timeCenterOfMass = sum(time.*dataEnergy)/sum(dataEnergy);

[fftR,fftAxe] = FFTR(data,1/dataFreqSampling);
dataEnergyFreq = fftR.^2;
freqCenterOfMass = sum(fftAxe.*dataEnergyFreq)/sum(dataEnergyFreq);

figure;clf;
subplot(2,1,1);hold on
plot(time,data);axis tight;
plot(timeCenterOfMass,0,'o');axis tight;grid on
xlabel('Time (s)');ylabel('Amplitude')
legend('Time Signal','Center of mass')

subplot(2,1,2);hold on
plot(fftAxe,fftR);axis tight;
plot(freqCenterOfMass,0,'o');axis tight;grid on
xlabel('Frequency (Hz)');ylabel('Amplitude')
legend('Frequency Spectrum','Center of mass')
</code>
More details about:

moment names in statistics: Higher-order cumulant and moment names beyond variance, skewness and kurtosis
How to calculate the mean/center frequency of the spectrum?
What is meant by "spectral moment"?
Comment: I do apologize, I knew I could spread confusion. Yet, I don't really get what you mean by "transition of whole the energy", "a gaussian like spreading". I think an illustration could be informative (on both sides :)
Comment: No problem @Laurent. :)
Comment: Thanks. But I don't understand well your response. In question I meant for example transition of whole the energy around a specific point. Consider a gaussian like spreading of a signal around a point which has energy equal to the original signal.
Comment: I have added a picture and some code, please to intereact
Answer: Without understanding the context of your question, you might consider a Class C power amplifier used in broad cast radio.
It uses a high Q  resonator with nonlinear feedback. It is not  a DSP technique but does concentrate energy if you have a loose definition of input.
The best you can do with a linear process is to excite a high Q resonance.

Energy of a signal


Can a Chromebook be infected by a computer virus through a malicious website?

Question: I am wondering if a Chromebook can receive a virus through a malicious website. I recently have heard they are immune to any sort of virus, but I am not sure that's true. Does somebody know if Chromebooks can be infected with a virus?
Comment: General rule of thumb: if it runs software it can be infected. The odds of infection depends on many things, which are well explained in the answers already posted.
Comment: @rackandboneman No, _if it runs software_. RAM-resident malware has been around for years; in fact, it used to be [the norm](http://malware.wikia.com/wiki/Category:TSR); if the goal is to steal credit card details instead of just format the hard drive, it'd be profitable to make these again.
Comment: @AlexandreAubrey if it runs software and has any permanent storage.
Comment: Not sure if its worth an answer on its own, but IF your chromebook does get a virus somehow(I've never had one in 5+ years of using one), its really easy to powerwash the device which is ChromeOs terms for reset to factory settings. Since all your settings and everything are on the cloud, once you log back in it will be all back to normal. The whole powerwash takes 15-30 minutes until you are back to the state you were before. I love chromebooks so feel free to message me if you have questions.
Answer: Tl;dr - yes (but unlikely).

From https://en.wikipedia.org/wiki/Chrome_OS:

Chrome OS is an operating system designed by Google that is based on
  the Linux kernel and uses the Google Chrome web browser as its
  principal user interface. As a result, Chrome OS primarily supports
  web applications.

Google around for information about Linux & virus and you will find that it is low runner, but certainly not unheard of.
For instance, Does Linux need antivirus? says

There is much debate as to whether Linux needs antivirus. Proponents
  of Linux state that its heritage as a multi-user, networked operating
  systems means that it was built from the ground up with superior
  malware defense. Others take the stance that while some operating
  systems can be more resistant to malware, there's simply no such thing
  as a virus-resistant operating system. The second group is correct –
  Linux is not impervious to viruses

and  Can my UNIX or Linux computer become infected with a virus? says

Few viruses are currently known for UNIX or Linux. However, virus
  checking is necessary for these reasons:

UNIX or Linux computers acting as servers for other operating system client workstations can become carriers for other virus types, e.g. Windows macro viruses.
UNIX and Linux computers are often used as mail servers, and can check email for worms and infected attachments before they reach the desktop.
If your UNIX or Linux computer is running a PC emulator (a 'soft PC'), applications running under that emulator are vulnerable to viruses, particularly macro viruses.

So, you are at little risk, but not no risk
Recommended reading: Chromebook How To: Viruses, Malware and Chrome OS Security
Comment: Your last quote suggests that you use the anti-virus on the linux machine not to protect itself, but to protect the windows machines "downstream"; the the latter part isn't about running linux at all.

Since a chromebook is out of scope of all these points, I feel it's just not relevant to the question.
Comment: deleted my answer as yours was way more complete. I couldn't provide more without replicating your answer... :)
Comment: then again, there are quite a few people arguing that you shouldn't even install antivirus on Windows (maybe aside MS's own version), as this will open up another attack vector for viruses to get on your system in the first place.
https://arstechnica.com/information-technology/2017/01/antivirus-is-bad/
Comment: I didn't even see yours; we must have posted simultaneously (so, upvote to your comment ;-).  Bottom line, if it has a processor, someone will try to code a virus for it. In this case, the biggest risks are browser plugins.
Comment: Should one consider the tons of malware apps for Android as an example for a linux-based system which needs some form of defense against malware? And the risk seems not so small, when one includes a broad variety of malware, not just viruses attacking the underlying linux system...
Comment: Yes, I agree. Maybe I just copy pasted too much? Otoh, it's nice to be nice :-)  Feel free to edit that part out (+1).
Comment: Upvote, but perhaps if it is open source, from a known source, with valid MD5 and you build it yourself?
Comment: Note also that ChromeOS is actually somewhat harder to persistently infect than most Linux systems with drive-by infections.
Comment: Interesting. Can you cite a reference for that?
Answer: tl;dr
Yes, just be careful and don't install any extensions and if you do make sure you understand the permissions they ask for.

Note: The professional definition of "computer virus" is a specific type of malicious application, the "normal" definition of "computer virus" is more or less any malicious application. Reading the OP's post I have interpreted his question to be using the term in the latter meaning.

Totally agree with the other answer and will start from the same place, but expand on it a bit:

Chrome OS is an operating system designed by Google that is based on the Linux kernel and uses the Google Chrome web browser as its principal user interface. As a result, Chrome OS primarily supports web applications.

Source: Wikipedia
Chrome: Passive attacks
Description of attack:

You open a website
Suddenly you have a virus

Likelihood: Even with Chrome on Windows these are incredibly uncommon, but the fact that Chrome on ChromeOS runs on Linux means that it's far less "worth" it for attackers to create attacks for Linux/ChromeOS.
Chrome: Stupid user attacks (malware + malicious site)
Description of attack:

You open a website
Website convinces the user to do something stupid

Example: You open a streaming site (the type which takes its content without permission or legal right from the copyright owner) and the site convinces its users to install a missing codec, whilst they actually install some virus.

Likelihood: As Chrome doesn't allow (by default) running actual Linux applications there is a far smaller attack surface. Additionally most of those attacks target once again Windows, so you end up with a bunch of useless .exe files in your Downloads folder.
BUT another type of cross platform attack which does work and is not uncommon is the installation of malicious chrome extensions. These will typically request the permission to

Read and change your data on all sites

Anyway, this requires the user to do something stupid and ignore the literal warning that the extension will have the permission to see and change anything you see (including for example your online banking interface).

Note: This doesn't start with a malicious site, so it doesn't really fall under the OP's question from the title, but does answer the question in the body.
Android: Passive attacks
Description of attack:

You install and open a malicious android app
Suddenly you have a virus (where a virus is once again defined as something that could steal your passwords or access your online banking)

Likelihood: The sandboxing on Android apps is so well done that as far as I currently know nobody has yet broken through it. This means practically that you are reasonably safe from this happening though. Of course, any permission you do grant to the android app - just like with the chrome extensions - can be used against you by a malicious player.
Linux attack surface
Description of attack:

(Prequel) You enable linux applications (this is disabled by default and only for powerusers)
You open some innocent looking file

Example: Some libreoffice document

Suddenly you have a virus

Likelihood: Even if you do enable linux apps and you open yourself to more or less all the dangers or running normal linux, viruses on Linux are incredibly uncommon. See Mawq's answer for a discussion of this.
Answer: Chrome OS has some features that make it very difficult for a virus to run, to elevate privilege to root, or to survive a reboot (become persistent).

The Chrome Sandbox (pdf) limits what a process can do. All operations are sandboxed, apart from basic CPU and memory usage. This means the renderer, javascript process, PDF renderer, etc. are sandboxed, and will not be allowed to execute arbitrary syscalls, write to arbitrary files, do network io, etc. unless those calls are explicitly allowed.
Verified Boot (Firmware boot). The Chrome OS boot happens in several stages. The first stage is a boot flash ROM, which is protected from writing by a hardware switch on the motherboard (this protection can be disabled if you want to flash your own boot loader). The Chrome firmware is stored in two writeable slots, but the signature is verified by the first stage, so it can't be arbitrarily modified and still boot. The kernel and initramfs are stored as GPT volumes and are signed, so those can't be modified either. The actual OS filesystem uses Verity to sign every block, and the signature is checked when a block is loaded, so the file system can't be modified either.
Constant updates. Chrome OS uses an A/B OS install so that security updates can be shipped regularly and automatically, with failed updates being easily reverted.

So, for a virus to run on the Chromebook, it would require a persistent compromise that chains something like:

an exploit to run native code (the virus)
a sandbox escape, to access the filesystem
a root exploit, in order to modify OS files
a "verified boot" exploit, targetting the firmware flash or filesystem, so that the modified OS files will be loaded on reboot
some way to spread to other Chromebooks (if we are talking about a traditional virus)

Google offer a $100k bounty for anyone who reveals such a persistent compromise. There are only a couple of instances (1,2) where this has been claimed. The second of these required chaining together five CVE vulnerabilities. Not easy.
Comment: This is true if you take the "proper" definition of computer virus, but the OP was not likely using the "proper" definition of virus, but rather the common definition of virus which includes things like malware.
Comment: Yes, it depends how you define "malware". Malware, as it is usually known on Windows, would still need an ability to run code, escape the sandbox, and modify the file system to become persistent. But if you define malware as something that happens purely in the browser, like a malicious Chrome extension, then every OS that allows Chrome to be run is vulnerable.
Answer: Do Chromebooks have vulnerabilities ?
Yes.
A brief search,at the time of writing this answer, on MITRE's CVE website by "chromebook" keyword, results in 9 vulnerability reports, all dated 2011 or 2012. Specifically, these mention "Acer AC700, Samsung Series 5, and Cr-48". According to the article in Security Week by Eduard Kovacs:

A researcher who uses the online moniker Gzob Qq informed Google on
  September 18 that he had identified a series of vulnerabilities that
  could lead to persistent code execution on Chrome OS, the operating
  system running on Chromebox and Chromebook devices.
The exploit chain includes an out-of-bounds memory access flaw in the
  V8 JavaScript engine (CVE-2017-15401), a privilege escalation in
  PageState (CVE-2017-15402), a command injection flaw in the
  network_diag component (CVE-2017-15403), and symlink traversal issues
  in crash_reporter (CVE-2017-15404) and cryptohomed (CVE-2017-15405).

So there's another set of CVE exploits dated 2017.
Attack surface:
Note that this does not take into account vulnerabilities in extensions from Google Store. Every additional extension may increase attack surface. An interesting example of an extension that  violates user's privacy and puts machine into botnet service can be found in Trend Micro's article:

This botnet was used to inject ads and cryptocurrency mining code into
  websites the victim would visit. We have dubbed this particular botnet
  Droidclub, after the name of one of the oldest command-and-control
  (C&C) domains used.
In addition to the above features, Droidclub also abuses legitimate
  session replay libraries to violate the user's privacy. These scripts
  are injected into every website the user visits. These libraries are
  meant to be used to replay a user's visit to a website, so that the
  site owner can see what the user saw, and what he entered into the
  machine, among other things.

Of course, physical access to devices it a significant factor - hardware itself could be compromised.
Note that attack surface may increase of the Chromebook runs out of the support cycle, which currently is 5 years, according to PC World's article. While the article states there's no clarity on the situation, apparently Google does intend to provide security updates:

There is, however, one more wrinkle to this story: Given that security
  is "one of the key tenets of Chrome OS," Google says it's "working
  with our partners to update our policies so that we're able to extend
  security patches and updates beyond a device's EOL date."
Google isn't making any guarantees at this point, but it sounds like
  the company wants to extend updates—at least on the security
  side—beyond five years. It also sounds like device makers such as Acer
  and Samsung would be partially responsible for making that happen.

Conclusion
In short, yes, one can get exploits on Chrome OS. As mentioned Mawg's answer, Chrome OS uses Linux Kernel, so Windows-specific exploits won't affect Chrome OS. Nonetheless, that doesn't decrease the attack surface if Linux Kernel exploits are of interest.


How to link one contact's address to be the address of all contacts in a specific group via SQL?

Question: I would like to link one contact's address to the main address of a group of many other contacts.
I see how to do this manually for one contact, but I cannot find a way to to this in a bulk way for a whole group.
Thank you
Comment: Pls provide a clear example of what you require. I think no one has understood you properly
Answer: This is how you set the address of all people in a certain group (group id = 13), to be the address of a specific, different contact (address id 15432)
SET @InGroup:=13;
SET @MasterAddress:=15432;
UPDATE civicrm_address SET master_id = @MasterAddress
WHERE contact_id IN
    (SELECT contact_id
    FROM civicrm_group_contact
    WHERE status = 'Added'
    AND group_id = @InGroup)
Answer: One way you can do this is to use the Advanced Search under the "Search" link on the Civi navigation bar. Expand the Address Fields tab, enter the address. This should produce a list of users with the indicated address. Now you can check all the users and use the dropdown to add them into the group.
Comment: Have you tried the "Import Contacts" under Contacts? If you run identify all the group of contacts that needs their primary address changed, you can setup a spreadsheet with the updated address column and map it. However, I never tried this with data replacement.
Comment: I don't think you understood what I mean.
I have a group of contacts, and I want to set their primary address, of all of them, to the address of another contact's address (the address of the organization they are all part of)


How can I promote my game?

Question: I am a beginning indie developer, and I want to get the word out about my game. What sites can I go to to ask about reviews of my game, and where might I be able to talk about and get feedback on my game from players?
Comment: What type of game? Web, downloadable, Flash, Java, etc. makes a big difference in terms of who you should talk to.
Comment: Yes but there is nothing that makes your request specific. This is a very open question that can have any number of answers but none that really qualifies as the right one. Because at any number of sites you can get reviews of, and get feedback on your game from players. Hence, why I called it a list and CW'ed it.
Comment: i need someone to add appropriate tags to this question, since i don't have 150 rep...
Comment: In my case, an Xbox Live Indie game, but i wanted to word the question generically to make it of most use to everyone.
Comment: List 'questions' should be community wiki as a minimum. Forced it.
Comment: @Noctrine: how is this a list question? i got many unique answers...
Answer: The answer will really depend on what kind of game you've made. Here are some of my thoughts:

For Flash: Flash Game License is a good place to get feedback from other developers, you could also try Mochi's forums. The FGL people also run Flash Game Distribution which can help get your game out to different portals (if you decide not to get an exclusive sponsor). This answer has a good list of portals you could submit your game to.
Generally: Sites such as the Indie Game Blog and TIGSource might review your game if you send them some info. The TIG Source also runs forums where people can play your game and leave feedback. The Indie Gamer forums is another community which can help.
Comment: Looks like there haven't been new posts on TIGSource since December 2015, but it's a cool site with a big forum
Answer: I would send (and have) an e-mail to every single website out there that reviews games of any kind. But not before I have an almost completed game. Be real. Be humble. Show off something innovative.
A lot of places won't really take their time looking at you until you have something put together. Don't try to approach reviewers to review a pre-alpha-alpha prototype. It might sound like common sense but I have read reviewers make that kind of remark (which is enough of an indicator).
As for feedback. Grab a few play testers, preferably locally, that you can watch play your game. That will be some of the best feedback you can get. Alternatively, follow the other's advice. tigsource.net, gamedev.net and devmaster.net forums.
Answer: Both Bytejacker and Rock, Paper, Shotgun have a sizable readership and will review indie games sent to them if they find them interesting enough.  I also second Alex's idea of the TIGSource forums; just make sure you follow their guidelines for new users and post in the appropriate category.
Comment: Bytejacker is outdated, last post is from 2011
Answer: My advice is to know your market.
A mud for example, usually buy ads on topmudsite or mudconnect.
An MMO might want to buy an ad at massively.
Indie game developer probly could get some good publicity by being upfront and simply posting at an related forum saying that they have a new game and want people to check it out. If you do this however, dont be pretentious and say you found a cool game and want people to try it. Just say that you are the developer and hope people give feedback on it. Try to find a genre specific forum for this. For example the wargamer forum is a nice place to do this if you have a grognard-ish game. Gamedev forum is also nice for this, but targeted audience is always better.
Answer: Find blogs that post about games/apps of what you are developing for.  For instance, if you are creating an Android game, then first I would get some sort of PR statement about the game together for blogs to post (with some screenshots of the game or video!  A must!).  This is even better if you have a website you can put this out on.  Then hit up every Android related blog and see if they'll write a review for your game.  Most of these blog sites also have forums that you can post to about your game's release.
You can easily replace "Android" for "iPhone" or "xBox" etc.
Answer: I posted this answer in a similar question

I don't know how effective this idea is (I haven't tried it yet) but for my current project I am going to advertise on Facebook. Let me explain.
Essentially I am going to create a fan page, and run an ad campaign on Facebook. What I figure is I can spend like $30/mo (or what ever you want) for advertising. As people become a "fan" of the page, a lot of other people will see that. So basically, if that $30/mo generates 5 fans directly, it could generate 50 fans indirectly. I figure I could also do some fun stuff with the fan page such as give away copies, solicit ideas, etc...
Like I said above, I haven't tried this so I don't know if it will work. However, I will let you know in the near future. :)

How can I promote my game?


My Samsung tablel 1 is not restarting?

Question: It stop working in process of restarting where android symbol is coming. So what should I have to do for resolve this issue?
Answer: Ugh...I have been researching this problem too my friends. I have the galaxy tab 7.0 and it has that stupid market instead of play store. While reading, i noticed this happens quite a bit. From what i have seen a hard reset doesn't always do the trick, good luck, sorry i couldnt be more help. I am interested in this solution myself.

My Samsung tablel 1 is not restarting?


Ripples in filter

Question: What are the uses of ripples in the filter design. We try to design a filter with least ripples but sometimes we design a filter to have 2 or 3 ripples. Why is it so?
Answer: Ripples are usually an undesired side effect. E.g., when designing a frequency selective filter you normally want a piecewise constant magnitude of the frequency response, but this is physically impossible.
Certain design criteria result in filters without ripples, such as the Butterworth criterion, which results in filters with a maximally flat response.
Answer: There is usually a trade-off between filter length or delay, transition bandwidth, and ripple.  Sometimes to get a filter with a sharper cut-off, the only alternatives include designs (via FIR optimization or IIR pole zero placement) that have (greater) ripples in the stop band or pass band.

Ripples in filter


Cycles wont do the amount of samples I put in at min samples

Question: I don't know what I changed but I've been trying to change my settings to get less noise and a faster render, but now it wont do the amount of samples I want it to. 1 sample takes as long as 1000 samples and has 0 difference in noise.
Comment: Might be the Min samples option, anway quick way to find out whats wrong would be to make a new scene and have a look at the default render settings, and exchange them until you find the error.
Answer: Adaptive Sampling min samples is not the actual amount of samples that cycles is using to render the scene.
From the manual:

Min Samples
The minimum number of samples a pixel receives before adaptive
sampling is applied. When set to 0 (default), it is automatically set
to the square root of the total (max) sample count.

So, what is happening in your case, is that your scene is set to render at 128 samples (the default until changed), so changing the adaptive samples to a higher setting doesn't change anything. If you raise the sampling to something more like 500, you will see a difference.


Computer is laggy when editing with Multiresolution

Question: After sculpting my mesh with Multiresolution modifier it became incredibly laggy. I can't even start render because of this although my PC isn't so bad. How do you make it work?
Comment: unfortunately the image doesn't show the top of the window, where you can see the number of vertices and faces.
Comment: 9 300 000 vertices and same amount of faces, am i suppose to reduce them?
Comment: 9 million vertices is a lot... do you really need that many? To make the interface more responsive bring down the number of subdivisions for preview on the multires and subsurf. Read this related link: https://blender.stackexchange.com/questions/15654/how-do-i-know-the-number-of-polygons-after-adding-a-subdivision-surface-modifier/15667#15667
Comment: Blender will struggle with polycounts in millions. If you can, reduce the subdivision amounts. If you need to work with such subdivision amounts you need to get an app that will handle it, like Zbrush. Your pc is not the bottle-neck.
Answer: The issue for the slowdown is due to how dense your model is. Generally it's a trade-off between quality and performance. in this instance you are using a multi-resolution modifier as well as a subdivision modifier. Both modifiers accomplish pretty similar tasks however in this case your subdivision modifier is subdividing an already subdivided surface adding significantly more vertices than what is needed in your model. This is why your are experiencing such a large amount of slowdown due to the amount of subdivisions that are in place.
I recommend picking either the the multi-resolution modifier or the subdivision modifier and sticking with that.


Extract custom icons from Word 2000 template

Question: I'm upgrading some custom templates/macros from Word 2000 to Word 2010.  There are custom icons that are embedded in the .dot template files.  I'd like to use those same icons for my new Ribbon - does anyone know how to extract the icons from the old .Dot file?
Answer: You can open the .dot files by using a zip extraction program such as 7-zip.
In there you will find the icon files.


How to show the full text in mod_article_category?

Question: I override the Joomla mod_article_category. I set hide introtext in Joomla CMS. And I used the print_r($list) to check the fulltext variable. However, there are [fulltext] but no content after print_r($list). How can I display the fulltext in the mod_article_category?
Answer: If you don't use the "Read more" separator in article's content editor, all the  text is actually stored in the introtext field.
Use that field to print full content or add the "read more" in your articles.


convert pump tap to kegorator tap

Question: I have a "party" pump tap. I want to convert this to use on a DIY kegerator. Can this be done? After taking the tap apart it looks pretty basic: CO2 in one side, beer out the other. I am specifically interested in what the threading is on this tap where the pump connects.
Comment: done. was waiting until I had enough reputation
Comment: some pictures may help
Answer: I just went and worked on this the past weekend (11/14/2015).  This allows me to run the output from my corny keg through my standard kegerator.  The thread you need for the "beer end" is a 7/8-14, which is also know as 5/8"bsp.  Ask the hardware store for this and they will look at you very strange....It ends up being the thread for a flare fitting (i think it is actually 3/4", but i took the female fitting in and verified.  You will then need to cut off the protrusion that makes it flare and grind flat so you can add washer.  I have not finshed yet and can send photos, but this was the closest and cheapest i could come up with (All in less than $10).  I then converted brass 3/4f lare to 1/2 brass pipe, and then brass pipe to 3/3" hose fitting.  text me at 262-424-7600 for photos.  ANDY
Comment: I would not recommend leaving your phone number (on any website), but it's your call.
Answer: Looks like a Sankey keg coupler which is the standard coupler for commercial beer kegs. Sankey kegs have a single port which both lets gas in and beer out. Hooking it up to a CO2 tank and a tap is no problem -- it's just a matter of getting the right connectors and hoses. However, if you're planning on serving homebrew, you might have problems.
Most homebrewers use soda kegs (often referred to as "Cornerlius kegs", though there are many other brands) which have two separate valves for beverage (out) and CO2 (in). Importantly, they also have a large opening at the top which is very handy for filling and cleaning the keg. Sankey kegs just have the single port and no opening. So, there's no simple way to clean or fill the keg without specialized equipment. If you Google "sankey homebrew", you'll see how others have dealt with the difficulties of using these kegs for homebrew.
If, one the other hand, you're planning on serving commercial beer from you kegorator, then the Sankey connector is exactly what you need.
Comment: I got all of that about the end that connects to the keg. I'm interested about how to hook this up to the CO2 and beer spigot. I updated my picture to show the threading I'm talking about. The 'beer out' is a simple NPT threading. Do you know anything about the 'CO2 in' threading?
Comment: Oh. I should have read the question more closely. Party pumps are built differently from the normal Sankey connector for draught beer. A few people have tried what you're doing. [This poster](http://hbd.org/discus/messages/40327/43079.html?1192548406) seems to have made it work, by screwing a barb to male pipe thread adapter into the gas side of the pump. He doesn't say what size the adapter is, but Googling "party pump piston thread count" makes me think it's 3/4". Good luck.
Answer: I'm trying to do the exact same thing with a party pump and am stuck exactly where you are. It doesn't seem to fit any standard pipe thread sizes. The thread count seems slightly tighter than pipe thread (more threads per inch) and the diameter of the male thread is exactly 3/4". If anyone out there knows other thread standards besides Pipe threads that might work, where we could set an adaptor to a barb for a hose, that's what's needed.
Other than that, I'm thinking that a 3/8 male NPT fits pretty snug, and just dumping solder around the outside to hold it in there. Even Dumping JB weld around the threads and pushing in the pipe thread would probably hold under the 10-15psi that it will be holding. That's what I'm going to do if I can't figure out the actual threads. McMaster.com has all the fittings in stainless and tubing also. Would love to hear what you end up doing
Update: just found this
http://www.micromatic.com/draft-keg-beer/keg-pump-parts-pid-HP-700.html
Looks like 3/4"-18 Threads. Now just have to find an adaptor to a barbed fitting
Answer: Short answer: yes it can be done. All you need to do is hook up the gas and beer out, which is pretty simple. For the gas you'll just need to hook it up to your regulator directly or to a CO2 manifold. For the beer out something as simple as a cobra head and a short length of tubing works. Obviously, you can go fancier and hook it up to a tower or something similar if you like.
I have a 4 tap system at home, but a 5 line out manifold for CO2. The first 4 are used for the 4 taps. On the 5th I put in sankey coupler, similar to what is pictured. I've used this to pump beer from commercial kegs into the home brew corny kegs (5 gallon soda kegs). This allows me to serve commercial beer without having to take all the corny kegs out of kegerator to make room for the large commercial keg. The biggest downside is that this is a bit of a pain to do. Additionally, a commercial keg is 15.5 gallons which means you have a bit more than 3 corny kegs.
Answer: I wonder if it's worth the trouble. $30 will buy you a no-foolin' Sankey coupler that should last you the rest of your beermaking (and beer-drinking) life. The proper fittings, and seals if needed, are cheap and readily available.
If you use more than one style of keg (I have Sankeys and Cornelius), you might also consider spending another $30 or so to convert the bare bones Sankey coupler to accept ball-lock in & out fittings. Seems like a good idea to have all the connectors the same style. I'd post a link to the site if I knew it was OK.
Side note to Kyle: If you end up using solder, I hope you'll use the lead-free kind. JB Weld might be equally toxic, since epoxy is a known mutagen. The metal filler may likewise be suspect. Just a caution.

convert pump tap to kegorator tap


Bivariate One-Sided Chebyshev Inequality (Symmetric Case)

Question: Let $X$ and $Y$ be random variables with finite means $\mu_X$ and $\mu_Y,$ finite variances $\sigma_X^2$ and $\sigma_Y^2,$ and correlation $\rho.$ Let $A$ be the event that $X \leq \mu_X + k\sigma_X$ and $Y \leq \mu_Y + k\sigma_Y,$ where $k \gt 1.$ Using the one-sided univariate Chebyshev inequality, I can find this lower bound on the probability of $A$ occurring: $$P[A] \geq {{k^2-1} \over {k^2+1}}$$ But this does not use the correlation. If the correlation is known, what is the tightest bound possible?
Comment: Are you sure you don't want $A$ to be the event $|X-\mu_X|\le k\ \sigma_X$ and $|Y-\mu_Y|\le k\ \sigma_Y$? That would be closer to the univariate Chebyshev situation.
Comment: Formulas for that case are available from Wikipedia's article on Chebyshev's inequality. I couldn't find anything on the one-sided scenario.
Answer: Using the results from  wikipedia page of Chebyshev's inequality  (first inequality in section "two correlated variables"), I dont see anything for your case with one-sided inequalities. The more usual case with double inequalities, one obtains, with the event $A$ defined as $A=|\frac{X-\mu_X}{\sigma_X}|\le k ~~\text{and}~~ |\frac{Y-\mu_Y}{\sigma_Y}| \le k$ we get the inequality
$$
Pr(A) \ge 1 - \frac{2k^2+\sqrt{4k^4-4k^4\rho}}{2k^4} = 1- \frac{1+\sqrt{1-\rho}}{k^2}
$$
where $\rho$ is the correlation between $X$ and $Y$.  Observe that negative correlation reduces the bound, while positive correlation increases it.


Historical forward exchange rate between $ and yen.

Question: Does anybody know where I can find historical forward exchange rate data between the us $ and yen? I've looked for quite a while (federal reserve, OECD, Thompson Reuters, etc) but haven't been successful.
Answer: If you're just looking for FOREX data, http://ratedata.gaincapital.com/ has a ton of it. FOREX assumes you will be taking delivery in 2 days (or 1 day in some cases).
I read your question as "if I want to buy yen at today's price, but delivered (and paid for) in 6 months, how much will it cost?". Is my understanding correct?
If so, you're talking about currency futures, which involve rollover rates.
If US banks are paying a higher interest rate than Japanese banks, there is a holding cost for the person who has the yen, even if the exchange rate remains the same. So, you have to adjust today's exchange rate for the interest the yen-holder will lose (compared to the dollar holder) in 6 months.
Comment: Hi Barry, your interpretation is right on. Do you know where I can find historical information about currency forwards for $ vs yen. (I do believe there's a distinction between currency forwards and futures though)
Comment: Wouldn't currency futures and currency forwards be priced identically? If not, there would be an arbitrage possibility, no? Having said that, rollover rates are based on national bank's interest rates differences. So, if you can find the Bank of Japan's historical interest rates and the Federal Reserve's historical interest rates, I think you'll have what you need?
Answer: The European Central Bank has an interface for downloading daily historical exchange rates since 1999 to the Euro Dollar. The output can be exported in several formats including CSV:
http://sdw.ecb.europa.eu/browseSelection.do?node=2018794
You can create a custom table with OCED StatsExtract showing monthly exchange rates of the Yet to Dollar since 1957:
http://stats.oecd.org/index.aspx?queryid=169#
The Bank for International Settlements (BIS) has statistics for monthly effective and foreign exchange rates since 1994.
http://www.bis.org/statistics/eer/index.htm
OANDA will give you daily/weekly history on exchange rates between YEN and USD for the last five years. It is an interactive form and you will need to scrape the results:
http://www.oanda.com/currency/historical-rates/
Exchange Rates displays a history table for daily rates for the last 6 months. Again, you need to scrape the information:
http://www.exchangerates.org.uk/USD-JPY-exchange-rate-history.html


Transforming to new "Partitioned Tables" from existing system

Question: I have plenty of tables sharded by date. I am exploring the way to move on and use the new "Partitioned Tables" instead.
I have found this reference for converting tables: https://cloud.google.com/bigquery/docs/creating-partitioned-tables#converting_dated_tables_into_a_partitioned_table
However, as I have many processes relating to existing tables (loading data or Querying), I am looking for a phased transition approach.
Meaning: I would like to change the load process and the table definition at 1st, and afterwards, slowly change all relating processes.

How should I go about this transition?
(We have considered and ruled out the option to duplicate everything and maintain each process twice due to obvious reasons.)
Is there a way to use the old table names convention (MyTable_YYYYMMDD) when querying a partition of the new transitioned table?
Can I use the older Table wildcard functions to query it until I transform all my query templates?
Are there existing partitioned tables on a public dataset where we can experiment?

Thanks
Answer: This is not exactly quite what you want, but may serve the purpose. With standard SQL, BigQuery supports the equivalent of table wildcard functions:
Documentation for this feature is going to be available soon, but to summarize:
We provide a pseudo column _TABLE_SUFFIX that provides a way to address the table. For example, the following query allows you to read from tables myproject.mydataset.20150105, and myproject.mydataset.20150106 (assuming value1 is a field in both).
SELECT _TABLE_SUFFIX AS table_name, SUM(value1)
FROM myproject.mydataset.*
WHERE _TABLE_SUFFIX = '20150105' OR _TABLE_SUFFIX = '20150106'
GROUP BY 1;
For your use case:
You could first convert your queries against date sharded tables to use _TABLE_SUFFIX pseudo column. Then, when you are able to convert these tables to partitioned tables. After that point, you will need a minor change to your scripts to use the partitioning pseudo column (since the pseudo column name is a bit different in these two cases).
Comment: when you say "After that point, you will need a minor change to your scripts to use the partitioning pseudo column..." do you mean the load processes, or my queries?
Comment: How would your sample query work with table name that contains prefix before the date, such as myproject.mydataset.mytablename_YYYYMMDD?
Answer: My few cents:

Can I use the older Table wildcard functions to query it until I
  transform all my query templates?

Directly against new partitioned table - No. You will most likely get something like "table wildcards matches no table"

Is there a way to use the old table names convention
  (MyTable_YYYYMMDD) when querying a partition of the new transitioned
  table?

The option I see is to create respective daily Views named after new_partitioned table but following new_partitioned_YYYYMMDD naming.
So while having use of new partitioning feature you will still use old syntax before you do full migration.
This comes with a little extra headache as you will need to make sure you have those daily views created daily going forward for new partitions - but if you are looking for temporary solution  - this should be not big deal.

Finally quick comment on reference for converting tables:

It is not clearly stated in documentation, but looks like you cannot just use bq partition command to convert existing sharded to new partioned.  First you actually need create that partitioned table. If not - you will get new table w/o schema so it will be useless. It might be a bug - dont know
Comment: I have a non sharded, non partitioned table, how to get to partitioned?
Comment: easy :o) - 1. create partitioned table with same schema 2. select out of your original table (partition by partition) into new partitioned table. if you need more details  - post new question as comment are hard to use for detailed answer
Comment: Are there existing partitioned tables on a public dataset where we can experiment?
Comment: I do'nt know. I have created my own for experimanting/playing


Suggested Server Specs

Question: I am going to host 5 magento websites which include about 1000 products max each, about 25k visits per month each(max). I don't want to buy a server and waste its resources, either struggle so looking for suggestion on whats the best number of cores/RAM for a package like this?
Comment: what size your database ? you will have to calculate from that
Comment: You need much more than 2gb, I would suggest a minimum of 32gb
Answer: For software specs you can check http://magento.com/resources/system-requirements
For the database please find a hosting provider that supports Percona MySQL
For hardware with a setup like this I'd say 2GB RAM and 2CPU should be enough but it depends a lot on how well the shop was built and the type of caching you are using.
Some tips on server configuration can also be found here: https://www.mgt-commerce.com/blog/magento-on-steroids-best-practice-for-highest-performance/
Comment: @MagenX this is not a shot in the dark. This is from having set up dozens of shop. As I said, it depends on a lot more than the information given in the question but it has some foundation. But if you know it so much better feel free to add your own answer
Comment: i would not be so sure about 2GB RAM, this advice is like a shot in the dark. calculation is coming from database size. and whether Percona or mysql version 5.6 would be good. that page at mgt-commerce is not correct and weird copy-paste.
Comment: i can not answer until we know the database size, unfortunately it can be 1Gb or even 10Gb, if he follow your advise, eventually he will tear the hair on the ass...
Comment: @MagenX first of all thank you both for your replies. To give you a bit more information, my largest store database is around 599.28 MB. Few more information is that my site which is currently on VPS, its homepage size is 2.27MB with about 74 HTTP requests.

Suggested Server Specs


How long does it take for someone to get promoted in Starfleet?

Question: After watching the series finale of Star Trek Enterprise, not a single bridge officer has acquired additional rank in the 10 year mission of the NX-01. How is that possible?
Comment: Wasn't there at least one occasion during TNG when Riker was offered a promotion to captain of his own ship, but turned it down in order to stay on the Enterprise?
Comment: If you believe the 2009 Star Trek film, then promotions take no time at all. In fact promotion can occasionaly happen in a quantum-like tunneling-effect manner - Kirk apparently got bumped from cadet to starship captain in a single instant...
Comment: The chance of someone getting a promotion that actually moves them to a new position is (with one or two exceptions) inversely related to their value to the ship.  The more important they are and the more screen time they have when historians tell stories about the experiences of the crew of that ship, the less likely they are to ever get a promotion that moves them off that ship.  (Sometimes they are offered promotions, such as the command of another vessel, but such offers are designed to look unattractive under close consideration, thus causing that officer to remain at their current post.)
Comment: Yeah, I guess that's an exception -- perhaps people can be promoted ONTO the ship, but not off of it - unless they're moving to another series, like Miles O'Brian moving to DS9.
Comment: Data gave a run down on how to attain his rank (at the time) in Datalore, but I can't find a quote or clip online.
Comment: There were IIRC no less than three such offers made to Riker. At one point the question was asked in-series why Riker continued to stay on the Enterprise when it was so obviously hurting his career, at least on paper.
Comment: @thkala historically, you can be titled 'captain' of a ship while only holding the rank of lieutenant... graduating from cadet to lieutenant isn't such a big step.
Comment: "How is that possible?" Because they sucked?
Comment: A person in command of a ship is called captain regardless of actual rank.
Comment: @Jack B. Nimble: 1. I think this only happens when on the ship itself, to avoid confusion wrt the command chain - although this may vary among the various navies. 2. Does it seem logical to you that the *flagship* of a fleet is under the command of anything less than an actual captain?
Comment: @thkala - Yes of course, only on the actual ship.
Comment: (cough)Star Fleet > Starfleet(cough)
Answer: Most likely it is because the producers of the show forgot. In the military it is very common for officers and enlisted to be promoted in rank while still occupying the same job. It is even possible (in the real world, anyway) for two officers to have the same rank but one be in a subordinate position to the other. For example, two captains could be CO and XO of a ship or unit.
At higher ranks it is certainly possible for someone to go 5-10+ years without a promotion, but they would be the slackers (which of course do not exist on the Enterprise). But at lower ranks (ensign, LT) it would be almost unheard of for someone to go even 2-4 years without advancing.
I am basing all of this on my experience in the U.S. Coast Guard. Starfleet is clearly based on the actual U.S. Military (Most likely Navy, though the Coast Guard rank structure duplicates the Navy's). Perhaps Starfleet is intended to be different. I suspect that it was just an oversight.
Comment: Roddenberry was an air force pilot. I suspect that having bridge officers beam down the planet of the week was more a function of the show only having so many recurring characters.
Comment: I'd have said Star Fleet is *loosely* based on some writer's conception of the U.S. Military, from a comic book he vaguely remembers reading while stoned in college. Not that it wasn't fun, watching Captain Kirk *personally* beam down into the most hostile situations to kick alien a##, but still...
Comment: Promotion, like the Enterprise, moves at the speed of plot.
Comment: @GoodbyeStackExchange In the Army, the officers send the enlisted forward to fight. In the Air Force, the enlisted (maintainers) send the officers (pilots) forward to fight.
Answer: Out-of-universe, in the first place it is generally a good idea to maintain ranks in a more static fashion, so that you can more readily identify who's being talked about by rank without having followed each episode.
Also, in the real-life military, ranks above Army Captain (Navy Lieutenant SG) are not easily obtained, because there are a limited number of posts requiring the rank. Even with meritorious service and high decoration, commissioned officers retire as Navy Lieutenants (or Army/AF Captains) all the time, simply because there isn't room at higher levels of the chain of command. Lieutenant Commanders are routinely first or second mates (XOs, COWs) of various ship classes, and if they worked up through the flying ranks they're wing commanders. Commanders are captains of smaller ships, squadron commanders of carriers, and XOs of cruisers/carriers/subs. Captains are the commanding officers of most ship classes and XOs of flag ships. All told there are not a lot of those jobs available in the field. Getting to Admiral is even harder; in the US Navy the maximum number of admirals is limited by statute, so the selection of group and fleet commanders and chiefs of staff becomes very political.
So, back in-universe, most of the TNG bridge staff besides the helmsmen extras are, in present-day Navy ranks, already pretty high up there by the events of Star Trek: Generations:

Captain Jean-Luc Picard, CO
Commander William Riker, XO
Commander Deanna Troi, Ship's Counselor/Second Officer
Commander Dr. Beverly Crusher, Chief Medical Officer
Lieutenant Commander Data, Second Officer/Chief Science Officer
Lieutenant Commander Worf, Chief Tactical Officer (thought he made Commander; guess not)
Lieutenant Commander Geordi LaForge, Chief Engineering Officer

Remember that this is 11 years after the maiden voyage of the Enterprise-D, and the only major promotions during the series were Troi's, Worf's and LaForge's. That is quite a while for so many to go without a promotion, especially Riker (who specifically turns down a command post three times before finally accepting command of the Titan at the end of Nemesis). However, like I said, they're all at very "mature" ranks.
Back in the TOS era, pretty much everyone got bumped up a rank between ST:TMP and ST2, and some more than that:

Rear Admiral (demoted to Captain) James Kirk, CO (started TOS as Captain)
Captain Spock, XO/Chief Science Officer (started TOS as Commander, having served on the Enterprise under Captain Pike, and was the Captain of record of the Enterprise as of the start of STII)
Captain Montgomery Scott, Chief Engineer (started TOS as Lieutenant Commander)
Commander Nyota Uhura, Communications Officer (started TOS as Lieutenant)
Commander Pavel Chekov, Helmsman/Tactical Officer (also served as XO of the Reliant; started TOS as Ensign)
Commander (promoted to Captain) Hikaru Sulu, Helmsman/Tactical Officer (also served as Commander of the Excelsior; started TOS as Lieutenant)
Commander Dr. Leonard McCoy, Chief Medical Officer (started TOS as Lt. Commander, already well-experienced; would have begun his Starfleet service two ranks higher as Lieutenant due to his medical degree, but never intended to be a Starfleet career man)

That's a LOT of senior staff to still be aboard the same ship, and some of the crew do branch out: Chekov is XO on the Reliant, Sulu commands the Excelsior, and Spock spends some time as Ambassador to the Klingon Empire as well as officially captaining the Enterprise. However, it is a much more realistic promotion timeline; over about 8-10 years from the first TOS episode, Chekov went from entry-level officer to XO of a ship. Sulu went from helmsman to commanding officer over a slightly longer time. Kirk would have been a Vice Admiral by the time he died if he'd played by a few more of the rules (not all of them, but maybe not stealing a Federation starship and blowing it up?)
Now, it's not unusual for a "flagship" like Enterprise to have that kind of senior staff on it, but it is unusual for a flagship to not have a "flag officer" (aka Admiral) on board. Also, there were plenty of starships that were getting along just fine with bridge staff of much lower average rank. Here's the shakeout of DS9:

Commander (promoted to Captain) Benjamin Sisko - Commanding Officer
Bajoran Colonel (equiv to Commander) Kyra Nerys - First Officer
Lieutenant Commander Worf - Tactical Officer
Lieutenant Commander Jadzia Dax (deceased) - Science Officer
Lieutenant Julian Bashir - Chief Medical Officer
Lieutenant JG Ezri Dax - Counselor
Senior Chief Petty Officer Miles O'Brien - Chief Engineering Officer (seriously? O'Brien never got promoted during his time on both the Enterprise and DS-9?)
Constable Odo - Chief Security Officer ("Constable" is an unofficial title; Odo has no official rank in either the Bajoran or Federation complements on the station)

... That's a much more regular staff list (non-official rank of "Constable" notwithstanding; call him a non-com, maybe a Petty Officer). Here's Voyager's command staff:

Captain Kathryn Janeway - Commanding Officer (her first command)
Provisional Commander Chakotay - XO (the Federation-appointed XO was only a LtC and was KIA in the pilot)
Lieutenant Commander Tuvok - Officer "of all trades"; chiefly Security/Tactical Officer
Provisional Lieutenant JG B'Elanna Torres - Chief Engineering Officer
Lieutenant JG (demoted to Ensign) Tom Paris - Helmsman
Ensign Harry Kim - Operations Officer
Seven of Nine - Science/Astrometrics Officer (no official rank, but she seems to have authority over various non-coms and ensigns on board, so call her a Provisional LtJG)
The Doctor - Chief Medical Officer (no official rank; the official CMO was a LtC who was also KIA. By convention any medical officer starts as at least a Lieutenant, but The Doctor isn't "conventional" in any sense. He does, again by convention, have ultimate authority in any medical decision aboard ship, superceding even Janeway)

... So, even before things went pear-shaped for Voyager, it had a very junior crew.
So, in summary, what you see in the Star Trek universe is both pretty normal and not so much; decorated senior officers gain rank and seniority in their Starfleet careers on famous ships like Enterprise, and then some will stay on the Enterprise of their day even when it begins to hurt their career paths on paper, because it's a much more exciting job than being Captain of any other ship.
Comment: Good run-down here, but the OP was specifically asking about the Enterprise series - mind adding a quick run-down of that crew's ranks, for completeness?
Comment: Regarding O'Brien:  Memory-Alpha lists him as a CPO on the Enterprise-D, and then "receiving a promotion" when transferring to DS9.  He is referred to as Senior CPO partway through the DS9 series.  So the only enlisted rank he didn't achieve was Master Chief Petty Officer.  Of course, O'Brien's rank among the writers was always in [flux](http://en.memory-alpha.org/wiki/Miles_O'Brien#Problematic_Rank_History).
Comment: You've answered for everything except the actual question - the Enterprise NX-01
Comment: Interesting you label Data as Chief Science Officer, when he wears the Engineering/Ops colors.
Comment: @Iszi - That is interesting; do you disagree with the assessment? Other than Troi and Crusher, both more on the medical side of the blue-shirt discipline, there aren't any blue-shirt bridge officers in the Spock archetype of CSO. Either Data or Wesley Crusher, depending on who's sitting in that left-front station from season to season, get the lines relating to sensor scans of spatial anomalies. Neither are blue-shirts.
Answer: Most likely, because they don't get all that many new recruits to fill out the ranks (or personnell losses/departures to allow for promotional slots), which is a prerequisite of a promotions process. If you don't have the Captain GTFO the vessel to retire or become an Admiral, his XO can't very well be promoted to Captain. If First Lft. doesn't get promoted (due to the same reason), then you can promote HIS subordinates to First Lft. Repeat recursively.
Comment: @JackBNimble It started with Yar dying, tho. Once she died, then Warf got promoted. And I don't remember another promotion until Star Trek Generations when Warf got promoted again. There might have been one or two in there I'm forgetting. But basically someone had to leave for the promotions to become available.
Comment: Well, there was no one above them in each of their positions.
Comment: People aboard the Enterprise on TNG got promoted as the series progressed, without the loss of officers.
Comment: Troi got promoted to commander, La Forge got promoted to Lt. Commander, Riker was offered his own command. I believe there might have been others as well.
Comment: @OghmaOsiris The same could be said for all of the senior staff excluding Archer and T'Pol on NX-01 Enterprise; granted Trip was already a Commander so he likely couldn't have been promoted further without getting his own command.
Answer: I suppose that one could argue that the star ship crew were rarely very well behaved, and so would not have attracted the right sort of attention. When they returned back to Star Fleet, they could offer explanations and discuss their positive contributions, and so after a while back at home base, when they have shown that they are suitable for promotion, they achieve it.
Which sort of means that they only achieve promotions - richly deserved - between versions, when they are doing nothing of interest. As others have said, they are largely senior staff anyway, so promotions on the ship would not mean a great deal, and they need to do some political face-showing when they return home to achieve them.
And I can see that those who would be promoted off active service - to Admiral for example - may resist this for as long as they can. Which tends not to lead to many other chances for promotions below them.
Answer: IN my opinion, in star trek enterprise, it's due to all the incidents the have got themselves into, and the fact that the Vulcan's don't like them that much, and at that time, Vulcan were a major influence in star fleet
Comment: Except the Vulcan's weren't a major interference by the end of the fourth season, and the last episode is supposed to take place six years after that.
Answer: In theory, any crew member could get a promotion in rank without a change of the duty position. It would be awkward if a subordinate suddenly outranks a former superior, but it would be no problem at all if both are the same rank. (The superior would still have more time in grade and hence be senior.)
If everybody on a ship got promoted one grade, nothing would really change except for the rank insignia. The former Captain (now an Admiral) still outranks the former Commander (now a Captain). They would get more pay deposited in their accounts back home, at least while the Federation still uses money, and they would outrank crew with comparable jobs on other ships. But way out in deep space, the promotions would be meaningless. A bad joke.
In the real world, this kind of rank inflation would be uncommon, but you can find some examples. Back in WWII, there were sergeant pilots. These days, most are officers.
So the in-universe explanation is probably that promotions come after a careful evaluation at the end of the multi-year mission, not in between. The real reason is not to confuse the viewers. "Captain Archer" has to stay "Captain Archer" ...
Comment: There is no Federation during _Enterprise_.