Complex calculus problem

Question: For the following question:
There is an entire function $z^2+Bz$, find $B$ so that $|f(B)|=|B|$ and at z=0 the map defines a rotation through $\theta =\pi /4$.
I do not understand what it means with rotation through an angle at a point. Can anyone explain? Thanks in advance.
Answer: At $z\approx 0$ the function is mainly $Bz$, so $\arg B=\frac\pi4$. The first condition results in $|2B^2|=|B|$, where only $|B|=\frac12$ is compatible with the other condition. Now you know the polar coordinates of $B$.
Answer: The condition in $z=0$ means that the differential of $f$ at $0$ (which is a linear transformation of the complex plane, i.e. a map of the type $az$ with $a=f^\prime (0)\in \mathbb{C}$) is a $\frac{\pi}{4}$-rotation. Since a $\theta$-rotation is represented by multiplication against a suitable complex exponential, namely $e^{\imath \theta}$, your condition translates into $f^\prime (0)\cdot z = r e^{\imath\ \frac{\pi}{4}}\cdot z$ for all $z\in \mathbb{C}$ (here $r>0$ is a real scaling factor).
On the other hand, $f^\prime (0) = B$, hence $B=re^{\imath \frac{\pi}{4}}$.
The condition on the module of $f(B)$, i.e. $|f(B)|=|B|$, may be rewritten as $2r^2=r$, from which $r=0$ or $r=1/2$.
Since only the latter solution is $>0$, you find $B=\frac{1}{2} e^{\imath \frac{\pi}{4}} = \frac{\sqrt{2}}{4} + \imath \frac{\sqrt{2}}{4}$.

Complex calculus problem


Dúvida - inserir máscara html

Question: Olá,
estou precisando colocar uma máscara da seguinte forma:
Tenho um campo:
<input type="text" required maxlength="4" name="minimumGrade"  id="minimumGrade" ng-model="capacity.minimumGrade">
E preciso que nesse campo ele receba somente três dígitos (números) e que ao digitar ele fique com uma máscara dessa forma:
#.##
Deverá ficar em forma de "nota", exemplo: 9.00, 7.50 e assim vai...
Answer: <input type="number" pattern="(\d{3})([\.])(\d{2})">

deve resolver teu problema, porem não é bem uma mascara será necessário colocar os pontos e virgulas.
mascara apenas com js
jQuery-Mask
Comment: Não deu certo como o pattern, passa a qtd de caracteres que desejo...
Comment: http://html5pattern.com/Dates para mais sobre o pattern

Exemplo utilizando o jquery-Mask
(precisa do jquery)

https://jsfiddle.net/1zt9abp2/
Comment: Deu certo! Obrigado!
Answer: Como o @MarcoViniciusSoaresDalalba citou, com o attribute pattern o usuário ainda deverá colocar o . ou a ,.
Para realmente colocar uma máscara, utilize a biblioteca JQuery Mask Plugin do Igor Escobar.
Com ela, você pode utilizar a anotações para facilitar seu código e que funciona muito bem.
Seu código ficará assim:
<input type="text" required maxlength="4" name="minimumGrade"  id="minimumGrade" ng-model="capacity.minimumGrade" data-mask="9.99">

E o resultado desse input será como esperado:
7.89, 9.45, 2.47.
Comment: Olá, fiz conforme passou acima importei as bibliotecas, mas não funciona... Tem como me mandar um exemplo?

Dúvida - inserir máscara html


Naming and analyzing chords : problem with a stack of fourths (and 2 other slash chords)

Question: I am writing a piece from little licks I have from years, and I found what seems to me a really moody intro consisting of 3 "exotic" chords.

for context, I have no education in music theory, but I am really enthusiastic about it. If I speak nonsense below, please pardon me.

I love these chords and I would like to analyse them or find any progression with the same vibe because I would like to revisit this chord progression later in the piece
For the intro part, they resolve in a Gm (in a dorian scale) which I'll consider the I chord
The piece is modulated later (in Eb dorian/Db major) so I need transposable relations of these chords with this resolving Gm
here is the score (ignore the chords names in purple) :

this is what I found so far :

the first chord : A D G C (F B) is just a stack of fourths in A minor.
it could be some kind of Am11
or using a slash, a... D7sus/A ??
is there any way to notate a stack of fourths ?
if i was obliged to find the position of the chord, I would say II since the bass is A
but it could be V with the D as tonic.

the second chord : Ab Eb G Bb (Db G)
is either a very complex Ab
or a simple Eb major triad over Ab bass (Eb/Ab), but in this case, how am I supposed to analyse it ?
is it a bII or a VI ? I would go for a VI so far

the last chord : G C Eb A (G Eb)
has the same problem,
either a complex G chord
or a Adim/G or more close a Cm6/G
so this sounds like it's either announcement to the I chord with decoration
or a II chord (Adim) or a IV chord (Cm)

After many tries and simplification I could sustitute these chords with this progression, with these transpositions (notice that the I becomes major in transpositions, sound better in the ear). I think I could play with that.
<code>D7   Eb     Cm6    ->  Gm   (intro)
V    bVI     IVm    ->  I    (relations)
Bb7  Cb(B♮)  Abm6  ->  Eb   (transposed)
G7   Ab      Fm    ->  C    (transposed in C)
</code>
I find this sweet.
Am I doing this right ? did I miss something obvious ?
Comment: sure, these 3 chords are out of it, when I talked about G dorian I meant the following (from the Gm chord an after, not seen here, is an insisting E natural)
Comment: I'm curious... how would you call this G dorian if it has an Eb which is the minor 6th? Dorian has a major 6th. You might be modulating at some point without realizing?
Answer: The last chord can certainly be heard as a type of chord IV leading to Gm: as you say, Cm6/G
The first two chords are not functional in the Roman numeral sense but there's plenty to say about them as regards voice leading if you want to write similar sequences.
Firstly the bass descends by semitone a-ab-g. There are also tritone pairs that descend in major thirds f-b db-g a-eb.
The slide into chord 3 is seamless because of two things. Firstly they share eb-g. Second is the parallelism (planing) ab-bb to g-a. I would argue that in addition there is a db-c with the c octave-displaced.
All composers really do is do stuff with music - if you do some more stuff like this you'll easily find some more sequences that fit/contrast as you like.
It's always worth looking and thinking about what you've written.
Comment: Thanks a lot ! your comment inspired me ! Regarding the movement between notes instead of functional harmony I found that making the 3rd chord in the progression a **major** chord instead of minor gives this ascending vibe (G Ab F Cm in the C version)
Comment: ... and this progression respects more the dorian feel of the piece, since the flat 6th is only a passing tone
Answer: There is very little point in trying to analyse this sort of thing as functional harmony.  Or even in trying to pin labels onto the individual chords.   Just let it be what it is, described by the notation.   We're not in 'chord sequence' territory here. The brief, accurate way to describe these chords is the notation.
Comment: @gui3 keep in mind Laurence's point is about "analyse... as functional harmony." Basically that means you aren't going to analyze as Roman numerals like `ii6 V7 I`, etc. but that still leaves plenty more to analyze. Consonance/dissonance, rhythm, mode, etc. are starting places.
Comment: Yes I may be over-analysing, but I love this progression so much I'd like to remind it in later parts, that's why i'd like to make a chord sequence out of it, simplified but echoing the intro


What are most common effects (pedals) for Post-rock music genre?

Question: What pedals do bands use for post-rock music?
Tons of bands have simillar sound of guitar I want to know how this sound is produced (pedal configuration) and which pedals are used.
I know some basic background like: Boss Digital reverb, Boss Digital Delay, Electro Harmonix Memory Man...what else? what's most common configuration of them?
Example bands: Caspian, Mono, Godspeed, Russian Circles.
Comment: Don't assume that great guitar sound is a result of a particular combination of pedals, amps, guitars, strings, picks, because what we see repeatedly is that a guitarist's sound comes from their fingers and attitude.

They can pick up to a guitar, plug it in, and within seconds sound the same as they would with their regular equipment. People have said that about Hendrix, Stevie Ray Vaughn, Clapton, and Beck. Even as they've transitioned from one style of amp to another, across guitar brands, etc, they are still recognizable. The effects make a lot less difference than you'd expect.
Comment: this genre doesn't require any technic at all =) just to pick some chord with arpeggio rhythm in random manner. post-rock is all about effects and progressions.
Answer: Pedals won't get you 100% there. Lots of people obsess over gear thinking that "this badass Zvex pedal will make me sound like Matt Bellamy." While artists tend to have a standard arsenal for particular genre's of music, your technique is really what makes your music shine. I spent years trying to nail down "my sound" and I ended up disappointed with nearly every pedal I purchased in an effort to get there. But enough banter, I can give you some basic ideas.
Most Post-Rock sounds have lots of gain. A pedal won't get you lots, and lots, of gain in the context that you want it to without sounding artificial or blatty. You need a badass amp (triple Rec or better), active pickups, a compressor, and mad power chord chugging skills. That's about it. Sick post-rock rigs are relatively easy to build with a couple thousand dollars. If you want an econo-rig, well you can get there too. Visit your local guitar center and go find the Blackstar section and grab a Schecter or something comparable. DISCLAIMER: Blackstar fans don't hate. I know they have some higher end stuff too.
As for delays, you listed basic industry standards that work across genres. For post-rock you probably don't want anything too analog (although you did list a Memory Man), so you could go with the Replica (T-Rex), DD-7 (Boss), or any decent digital delay.
Modulation is a great way to add a little colour to your tone. Stone Temple Pilots used this religiously and pulled it off pretty well. Jerry Cantrell snuck a pre-gain phaser into some of his guitar work to fatten up the tone--and that worked really well too. I know these bands aren't really post rock, but I don't think anyone can argue that they don't have influence--and these are all industry strategies that tend to span genres.
Compression is nice, but not entirely needed. Most heavy gain amps will compress themselves when dimed, and it's highly likely that any serious compression occurs post-production. Still might be a good thing to consider, but make sure you know how to use one. Lots of people get frustrated with compressors because they don't entirely understand what they do and consequently how to use them.
In closing I'd suspect that a Post-Rock band's trademark sound is achieved via a standard pattern of pedals, their guitar/amplifier combination, and however the production house EQ's them--which honestly tends to be true for most genres these days.
Comment: I'm concerned about this answer because it is misleading. I think the answerer mistook post rock for some other "normal" rock genre.
Comment: Thnx for sharing great your knowledge. That's what I wanted. Would be great to have similar comment about my mentioned bands.
Comment: I agree with @TylerBailey. Active pickups and "mad power chord chugging skills" isn't what comes to my mind as related to post rock...
Answer: Not sure about the above answers...
What you need is not an amp with huge gain, but instead an amp with lovely cleans. Most post rock bands use heavy reverb and delay, anything from the Boss RV3 (two in one used by Explosions in the Sky at some point) to Eventide's Space/Timefactor or Strymon's seriously high end boxes which can give you an infinite abyss of ambient sound. Modulation effects such as reverb and delay should always be used at the end of a signal chain though, if not through the effects loop, or even in stereo into a separate amp if you're that way inclined to give your sound room to breath.
As has been mentioned, compression is good and should go in your chain where you wish; if you'd like the signal from the guitar to be compressed before it reaches any modulation effects then put it first, or if you want the whole sound compressed, put it at the end.
In response to the comments above about gain, most post rock bands actually rely on fuzz pedals for the huge sounds. Look at This Will Destroy You pedalboard - they use Proco Rats, also Zvex Fuzz Factory. You'll find that a lot fuzz sounds, when put through reverb and delay can become absolutely huge. Where you put it is up to you but I normally put fuzz/drive etc. before the modulation.
Comment: A good clean amp is essential, although I haven't seemed to have much luck with my Roland JC-120 (the king of super clean amps) vs my Rivera (with it's pseudo Fender clean channel). I would say that I much prefer a clean *tube* amp, since it tends to have more dynamic flexibility.
Answer: This is my set-up when I go live with my post rock band. Since I don't have the money to get the all exclusive strymon pedals, I try creating sounds similar to hammock or Caspian with the pedals I have and it has been helping so far.
The chain in which my pedals are, are as follows,

TC Electronic Polytune 2 ( tuner )
Xotic Effects SP Compressor
ISP Decimator 2 ( using this in front of the chain helps me eradicate the noise from the guitar and the compressor, but I rarely use it. )
Fulltone Full drive MOSFET 2 ( Overdrive )
TC Electronic Nova Drive ( distortion & overdrive. I used the fulltime before to get the best overdrive before and after distortion. Distortion after overdrive gives a raw tone. Distortion before overdrive, naturally compresses the tone to give you a less raw tone. I use both now and then )
Visual Sound Visual Volume Pedal ( this is a really really good volume pedal. You also get to know what level your volume is in. Great for live settings )
TC Electronic Dreamscape ( yes, the John petrucci signature one. It is cheap and has 6 different types of variations. Two of each chorus, flanger and vibrato respectively. Only disadvantage, you don't get to use them together at the same Time. But that's not a big thing. )
Vox Delaylab ( delay pedal which is cheaper than the strymons but still half as good. You get good shimmer tones in the ambient mode if you tweak a little and great reverse delay and a 28 second looper and tons of other effects like tape delay, echo, dual delay, phaser delay if you're into that. Soo much to work with )
Joyo Vintage Tremolo ( Joyo is a Chinese company that makes clone pedals. If you want cheap pedals, this is where you go. The best clones possible with true bypass at quarter or even lesser the price of the original it was designed on. I run the tremolo after the delay to get better cleaner tones. )
TC Electronic Hall Of Fame Reverb ( another tc pedal which is brilliant for the genre. But I'm pretty much stuck on the cathedral reverb section because it gives me the best tones. )
TC Electronic Ditto Looper X2 ( its a cheap must have looper. Helps me create loads. It has added effects like reverse delay, 1/2 speed and it let's you store a maximum of one loop that you want to save for later use. It is a 5 minute looper with unlimited overdubs. Best you can get for the price )
I'm building a pedal with a custom stompbox builder here to get separate effects that I need. It has three different circuits. Similar to my dreamscape, but instead of chorus, flanger and vibrato, I have 100% wet reverse delay, organ tones and an octave option with a knob to interchange, a switch to connect effects or select separate effects and three different knobs for rate, fx level ( which would be feedback for delay and fx level for others ) and a mix knob.
Comment: It would be nice if you had sound clips to demonstrate what this produces
Answer: As far as pedals go: Line 6 DL4,
Loop stations such as BOSS RC-30 or RC-50 (russian circles use this a lot as they're a trio),
Boss digital Delay (DD3 or DD6),
and shit tones of reverb.
I hear lots of guys using expression pedals, like digitech whammy, and
on the guitar side of things there are a lot of tele's out there; my Thinline Deluxe has a pretty amazing clean tone, and the partial hollow body definitely gives it a warmer more expansive sound.
Yes, peoples playing styles shine through whatever gear they're using but for genres like post-rock where many times the instruments are creating soundscapes rather than steely-dan licks, pedals and effects are going to help produce the types of sounds that are going to expand the sonic possibilities of the instrument beyond just a guitar and amp set up.
Answer: Pedal placement really comes into play, if you run a fuzz put that first then wah (if you use that) then a reverb. I get some awesome tone from running a big muff->holy grail->dano flange->daddy o-> ibanez de7->boss dd7. Different dirt pedals, multiple delays. if you can find the ibanez de7 grab one put it on a low delay on the longest setting and crank repeats on echo mode. really lush sounds for cheap money. also tube amp or a tube preamp.
Answer: You're looking for an answer that doesn't exist. Post-rock guitarists typically try every pedal and pick the twelve that most help them craft their tone :)
As someone who plays this style, I would mention that having an amp with a high dynamic range is incredibly important. Specifically, when you're hitting the front end of your amp with a wall of smash-mouth, distorted delays and reverbs (that is, if you're not running your modulations/delays through your fx loop), you will quickly be able to tell if your amp is up to the task.
Answer: So this is coming from a post-rock bassist:

A volume pedal is pretty awesome for swells
Delay
Delay (Yes, that's twice)
Reverb
Fuzz
OD
Phaser
Looper

I use each of these in moderation at times, heavily at times.
I run a MXR Carbon Copy for straight delay as it has beautifully dark trails.
For reverb, I use a Nuenabar WET that can be subtle or can create whale songs
For Reverb/Delay I use and Earthquake Devices Dispatch Master. This type of pedal is killer if you want to achieve a post-rock sound. It is very similar to a Boss RV-3. These types of pedals should just be called post-rock-in-a-box.
I run an MXR Bass Fuzz Deluxe for static walls
A Catlainbread SFT Overdrive is great for digging and works really well with the Carbon Copy.
A ditto Looper makes it easier to work as a trio.
I use a script MXR Phase 90 to create breathing swells with my Fuzz pedal
And yes, Post-Rock may be an awful name, but what an amazing genre!
Comment: it would be nice if you had a sound clip of what this setup produces


most effective guitar practice schedule?

Question: I've Googled this question and there is a jumble of answers out there with long articles with complicated answers, so I thought I'd ask for more personal opinions.
I learned the guitar about 13 years ago way back in high school. I played quite a bit, albeit by myself, for the next few years. I used to tab a lot of songs by myself, so my ear-training was pretty good. Then school and work got in the way and I didn't have much time for it. Now I wanna get back into it, but find myself clueless on what to play or practice. I can play some songs here and there, but it doesn't really mean much to me especially since I can't sing along.
I want to practice, but need a schedule to motivate myself. If I just randomly do a song or a scale, I don't think I'll learn much. On the other hand there's just so much to learn. Memorizing the fretboard, changing chords (I suck at barre chords, hands get cramped quickly), techniques (cannot pick very fast...), etc etc.  After so many years I think I better start with the basics again, although maybe not from complete zero.
So that's my question. Your opinions are much appreciated.
Thank you
Answer: I agree with Alex on getting a professional teacher - it's always the best idea if you want some real progress and a real structure to you practice.
Besides this, here are some general tips on creating a schedule:

Think of the things you want to practice and write out the list;
Think how much time you have for one practice session and assign a
period in minutes to each practice stage;
Put things that require the most mental activity at the beginning of your practice session and all the "mechanical" stuff near the end.
Assign at least 50% of your practice session new material!
When you start practicing,
launch a countdown timer (every modern cell phone has this) with the
time assigned for the given stage and don't stop, until the timer tells
you to.

Here is an example practice schedule for 1 hour:

Warm-up / 5 minutes
Exercises from a book you might have / 15 minutes
Learning current new song / 15 minutes
Scales and arpeggios / 10 minutes
Repeating some songs you already know / 10 minutes
Chord changes with metronome / 5 minutes

As you can see, all the new stuff, songs and exercises, are at the beginning, so you can approach them with fresh mind. Also, new material takes more than a half of your practice time - this way you will progress really fast and this progress will be your own motivation. And finally, setting up a timer will keep you focused and will give you a warm feeling of "I did my job for today" at the end.
Good luck in your playing!
Answer: Sounds like what you really need is a teacher: someone who can assess your current skill level and assign you appropriate exercises, help you to learn songs, scales, chords, and theory relevant to your musical interests, and track your progress from an experienced point of view.  A good teacher will give you material to practice and master by your next lesson, so if you simply set up lessons on a regular basis (I recommend once a week if you can, but once every two weeks is ok, too), then your schedule and motivation is clear: learn this material by next week, whereupon you'll get new material to learn by the following week, etc.
Answer: An awesome and inspiring book to get particular great excercises for your practice schedule is Scott Tennant's Pumping Nylon. It's very well structured and the exercises are also very well designed.
The author plays and talks about fingerstyle nylon string guitar, but the left hand patterns and excercises are also great for steel string instruments played with a guitar pick.


Dropbox alternative with NAS

Question: HI
Does anyone know how we can backup some files and folders from windows machine to a nas (To store versions of files ie incremental backups) Then sync the data on the nas to another Windows PC for an off-site copy?
Basically Dropbox with our own NAS and control?
Comment: I love it when someone uses Dropbox as an example of simple LAN management.  You just want a simple file share on your NAS with some type of backup solution.  Your backup can be as simple as a scheduled task that runs to xcopy files around.
Comment: you already have two questions open on this same topic. Please go back and deal with those before posting duplicate questions.
Comment: possible duplicate of [NAS backup - multiple machines](http://serverfault.com/questions/240290/nas-backup-multiple-machines)
Answer: There are several solutions available, depening on your exact needs.
As I understand, you do not have a server machine for NAS, just plain file server. In this case for free solution to keeping files in sync you might adapt a distributed kind of version control system (VCS), which does not require a server, such as Git.
There is some overhead to using a VCS compared to some kind of specialized backup/sync software, however, there are some upsides too, which might be useful to you, depending on your exact needs (keeping info on previous versions of files, for example).

Dropbox alternative with NAS


Django HTML não atualiza no browser

Question: Eu acredito que a estrutura do meu projeto seja um tanto complexa. Como é um framework, não o iniciei do zero.
Meu problema ocorre quando tento fazer alterações no conteúdo de texto de arquivos HTML e inicio o navegador. Alguns arquivos .html aceitam essas alterações, enquanto outros não. Os arquivos HTML que aceitam essas alterações estão no diretório test_project, o mesmo diretório em que executo python manage.py runserver. Eu diria que é obrigatório iniciar o servidor a partir deste diretório. Se eu tentar o diretório principal, que inclui o manage.py primário, recebo o erro no such table: django_session. Por sua vez, os arquivos HTML que não aceitam as alterações estão no diretório qa.
O que devo fazer para atualizar os arquivos HTML em ambos diretórios, test_project e qa?

Espero ter colocado informações suficientes. Obrigado!
.
├── AUTHORS.rst
├── CONTRIBUTING.rst
├── HISTORY.rst
├── LICENSE.md
├── MANIFEST.in
├── Makefile
├── README.rst
├── docs
│   ├── Makefile
│   ├── base.rst
│   ├── conf.py
│   ├── index.rst
│   ├── installation.rst
│   ├── make.bat
│   └── settings.rst
├── manage.py
├── qa
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-37.pyc
│   │   ├── __init__.cpython-38.pyc
│   │   ├── admin.cpython-38.pyc
│   │   ├── apps.cpython-38.pyc
│   │   ├── forms.cpython-38.pyc
│   │   ├── mixins.cpython-38.pyc
│   │   ├── models.cpython-38.pyc
│   │   ├── signals.cpython-38.pyc
│   │   ├── urls.cpython-37.pyc
│   │   ├── urls.cpython-38.pyc
│   │   ├── utils.cpython-38.pyc
│   │   ├── views.cpython-37.pyc
│   │   └── views.cpython-38.pyc
│   ├── admin.py
│   ├── apps.py
│   ├── forms.py
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   ├── 0002_auto_20160412_1336.py
│   │   ├── 0003_auto_20160414_1413.py
│   │   ├── 0004_answer_updated.py
│   │   ├── 0005_auto_20160519_1057.py
│   │   ├── 0006_question_total_points.py
│   │   ├── 0007_answer_total_points.py
│   │   ├── 0008_auto_20160719_0729.py
│   │   ├── 0009_auto_20160919_1528.py
│   │   ├── 0010_auto_20160919_2033.py
│   │   ├── 0011_question_slug.py
│   │   ├── 0012_remove_question_views.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       ├── 0001_initial.cpython-38.pyc
│   │       ├── 0002_auto_20160412_1336.cpython-38.pyc
│   │       ├── 0003_auto_20160414_1413.cpython-38.pyc
│   │       ├── 0004_answer_updated.cpython-38.pyc
│   │       ├── 0005_auto_20160519_1057.cpython-38.pyc
│   │       ├── 0006_question_total_points.cpython-38.pyc
│   │       ├── 0007_answer_total_points.cpython-38.pyc
│   │       ├── 0008_auto_20160719_0729.cpython-38.pyc
│   │       ├── 0009_auto_20160919_1528.cpython-38.pyc
│   │       ├── 0010_auto_20160919_2033.cpython-38.pyc
│   │       ├── 0011_question_slug.cpython-38.pyc
│   │       ├── 0012_remove_question_views.cpython-38.pyc
│   │       └── __init__.cpython-38.pyc
│   ├── mixins.py
│   ├── models.py
│   ├── signals.py
│   ├── static
│   │   ├── css
│   │   │   └── qa.css
│   │   └── qa
│   │       ├── icon.ico
│   │       ├── qa_index.jpeg
│   │       ├── qa_page.jpeg
│   │       ├── question.jpg
│   │       └── user.png
│   ├── templates
│   │   ├── 403.html
│   │   └── qa
│   │       ├── base.html
│   │       ├── create_answer.html
│   │       ├── create_comment.html
│   │       ├── create_question.html
│   │       ├── detail_question.html
│   │       ├── index.html
│   │       ├── profile.html
│   │       ├── update_answer.html
│   │       └── update_question.html
│   ├── urls.py
│   ├── utils.py
│   └── views.py
├── requirements.txt
├── runtests.py
├── setup.py
├── test_project
│   ├── core
│   │   ├── __init__.py
│   │   ├── __pycache__
│   │   │   ├── __init__.cpython-38.pyc
│   │   │   ├── admin.cpython-38.pyc
│   │   │   ├── forms.cpython-38.pyc
│   │   │   ├── models.cpython-38.pyc
│   │   │   ├── tests.cpython-38.pyc
│   │   │   └── views.cpython-38.pyc
│   │   ├── admin.py
│   │   ├── apps.py
│   │   ├── forms.py
│   │   ├── migrations
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       └── __init__.cpython-38.pyc
│   │   ├── models.py
│   │   ├── templates
│   │   │   ├── login.html
│   │   │   └── register.html
│   │   ├── tests.py
│   │   └── views.py
│   ├── db.sqlite3
│   ├── manage.py
│   ├── requirements.txt
│   └── simpleqa
│       ├── __init__.py
│       ├── __pycache__
│       │   ├── __init__.cpython-38.pyc
│       │   ├── settings.cpython-38.pyc
│       │   ├── urls.cpython-38.pyc
│       │   └── wsgi.cpython-38.pyc
│       ├── settings.py
│       ├── urls.py
│       └── wsgi.py
├── tests
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-37.pyc
│   │   ├── __init__.cpython-38.pyc
│   │   ├── settings.cpython-37.pyc
│   │   ├── settings.cpython-38.pyc
│   │   ├── test_mixins.cpython-38.pyc
│   │   ├── test_models.cpython-38.pyc
│   │   └── test_views.cpython-38.pyc
│   ├── settings.py
│   ├── test_mixins.py
│   ├── test_models.py
│   └── test_views.py
└── tree.txt

20 directories, 124 files

Answer: Talvez, você precise fazer um apontamento correto no seus settings na TAG TEMPLATES segue a minha como exemplo:
> TEMPLATE_DIR = os.path.join(BASE_DIR, "templates")
>      TEMPLATES = [
>     {
>         'BACKEND': 'django.template.backends.django.DjangoTemplates',
>         'DIRS': [TEMPLATE_DIR],
>         'APP_DIRS': True,
>         'OPTIONS': {
>             'context_processors': [
>                 'django.template.context_processors.media',
>                 'django.template.context_processors.debug',
>                 'django.template.context_processors.request',
>                 'django.contrib.auth.context_processors.auth',
>                 'django.contrib.messages.context_processors.messages',
>             ],
>         },
>     }, ]

Django HTML não atualiza no browser


Every homomorphism on cohomology groups is induced by some map on spaces

Question: Suppose we have two topological spaces $X$ and $Y$. Let $\alpha ^* :H^n(X,\mathbb{Z})\to H^n(Y,\mathbb{Z})$ be a homomorphism.

1) Is there a continuous map $\alpha : Y\to X$ such that the induced map $H^n(\alpha)$ equals $\alpha ^*$?
2) What if we replace cohomology with homology?
Answer: Not necessarily, in both cases. Take as an example $X=S^2, Y=T^2$. $\pi_2(T^2) = 0$ so any map $S^2\to T^2$ is nullhomotopic, in particular it induces the $0$ map on (co)homology.
However $H^2(S^2) \cong H^2(T^2) \cong \mathbb Z$ (and same in homology)


Obter "ondas" da frequência de som ou música

Question: Como faço para exibir as ondas sonoras de qualquer som (música)? Não sei se é possível obter isso com JS ou alguma outra linguagem. Ondas desse tipo:

Um exemplo é como SoundCloud faz, exibindo uma espécie de onda do áudio que está sendo executado.
Quero armazenar no meu servidor/site, ou seja, tendo o áudio localmente e exibir para o visitante a frequência do som.
Comment: Acredito que não tenha como fazer isso da forma correta sem ter um hardware especial para captar o som, caso seja externo. O que normalmente programas comuns fazem é detectar as mudanças de volume da música e trabalhar com animações em cima dessas informações simulando as ondas sonoras.
Comment: Cara, sua dúvida está ampla demais. Como você vai receber esse som? Como você quer apresentar essas ondas? Poderia tentar especificar um pouco mais?
Comment: @FelipeAvelar fiz edição na minha descrição, obrigado pela sugestão.
Comment: @DirtyOldMan vc sabe o nome de algum programa ou equipamento que realizam isso ?
Comment: @DirtyOldMan, na verdade eu imagino que ele capte a frequência de cada trecho da música e vai gerando o gráfico (ou animação) que ele deseja, não? Um arquivo mp3, por exemplo, contém informações suficientes pra isso. Por isso eu perguntei como ele vai receber esses dados...
Comment: Inclusive, uma das opções, é ele já ter as informações dessas animações prontas e só enviar um json, por exemplo, pra tratar no front-end, enquanto o som toca...
Comment: Já vi isto feito em outras linguagens e sempre me pareceram bem eficientes, acredito que um hardware só para isso seja exagero, desculpe a sinceridade @DirtyOldMan
Answer: A API de áudio do HTML5 permite esse tipo de visualização, com bastante flexibilidade. Eis um exemplo adaptado de um tutorial da MDN, pegando o áudio de um elemento <audio> e desenhando a visualização num <canvas>:

AVISO: O exemplo abaixo não funciona mais inline porque utiliza um arquivo de áudio de outro domínio, causando um aviso de MediaElementAudioSource outputs zeroes due to CORS access restrictions no Chrome (e provavelmente algo semelhante em outros browsers). Se você testar no seu ambiente de desenvolvimento ou servidor, com arquivos locais, funciona. Estranhamente, no preview de edição aqui do site também funciona.

var canvas = document.querySelector('canvas');
var audio = document.querySelector('audio');
var audioCtx = new AudioContext();
var source = audioCtx.createMediaElementSource(audio);
var analyser = audioCtx.createAnalyser();
source.connect(analyser);
source.connect(audioCtx.destination);

// CORS
audio.crossOrigin = "anonymous";

analyser.fftSize = 1024;
var bufferLength = analyser.fftSize;
var dataArray = new Uint8Array(bufferLength);

var w = canvas.width;
var h = canvas.height;
var sliceWidth = w * 1.0 / bufferLength;
canvasCtx = canvas.getContext('2d');
canvasCtx.clearRect(0, 0, w, h);
canvasCtx.fillStyle = 'rgb(200, 200, 200)';
canvasCtx.lineWidth = 2;
canvasCtx.strokeStyle = 'rgb(0, 0, 0)';

function draw() {
    drawVisual = requestAnimationFrame(draw);
    analyser.getByteTimeDomainData(dataArray);

    canvasCtx.fillRect(0, 0, w, h);
    canvasCtx.beginPath();

    var x = 0;

    for(var i = 0; i < bufferLength; i++) {
        var v = dataArray[i] / 128.0;
        var y = v * h/2;
        if(i === 0) {
            canvasCtx.moveTo(x, y);
        } else {
            canvasCtx.lineTo(x, y);
        }
        x += sliceWidth;
    }
    canvasCtx.lineTo(canvas.width, canvas.height/2);
    canvasCtx.stroke();
};

draw();
<audio controls>
  Your browser does not support the audio element.
    <source src="//upload.wikimedia.org/wikipedia/commons/4/43/Goldberg_variations_1_start.ogg" type="audio/ogg" />
</audio>

<canvas width="600" height="150"></canvas>

Crédito do áudio: Wikimedia Commons, trecho inicial da Variação 1 das Variações Goldberg de Bach, BWV 988
Comment: muito obrigado, vc me ajudou muitoooo !! Parabéns. era exatamente isso que eu estava procurando.
Answer: Se a "onda" do áudio for estática (sem animação), você pode usar o WaveSurfer

Download: http://wavesurfer-js.org/dist/wavesurfer.min.js
Documentação: https://github.com/katspaugh/wavesurfer.js/blob/master/README.md

Exemplo:

@bfavaretto permita-me usar o mesmo áudio que o seu? :)

var wavesurfer   = Object.create(WaveSurfer);
var pausePlayBtn = document.getElementById('playPause');
var stopBtn      = document.getElementById('stop');
var progress     = document.getElementById('progress');
var isPaused     = true;

wavesurfer.init({
    container: document.querySelector('#wave'),
    waveColor: 'violet',
    progressColor: 'purple'
});

wavesurfer.on('loading', function (status) {
    if (status === 100) {
        progress.innerHTML = "";
    } else {
        progress.innerHTML = status + "%";
    }
});

wavesurfer.on('ready', function () {
    isPaused = true;

    wavesurfer.play();
    pausePlayBtn.innerHTML = "Pause";

    pausePlayBtn.onclick = function() {
       isPaused = isPaused ? false : true;

       pausePlayBtn.innerHTML = isPaused ? "Pause" : "Play";
       wavesurfer.playPause();
    };

    stopBtn.onclick = function() {
       isPaused = false;
       pausePlayBtn.innerHTML = "Play";
       wavesurfer.stop();
    };
});

wavesurfer.load('https://upload.wikimedia.org/wikipedia/commons/4/43/Goldberg_variations_1_start.ogg');

0

<button id="playPause">Play</button>
<button id="stop">Stop</button>

Crédito do áudio: Wikimedia Commons, trecho inicial da Variação 1 das Variações Goldberg de Bach, BWV 988
Comment: @GuilhermeNascimento vc tb me ajudou bastante. Não tenho palavras p agradecer vc e o bfavaretto, muito obrigado !!
Comment: Guilherme, seu exemplo quebrou, provavelmente quando a wikimedia mudou a política de acesso (eu editei a minha um tempo atrás por isso; veja meu último edit). O wavesurfer permite setar `audio.crossOrigin = "anonymous";` em algum lugar? Isso deve resolver.
Comment: @bfavaretto infelzimente a solução parece que tem quer do lado servidor, depois vou ver melhor.
Comment: Ué, agora parece que está funcionando?! Deve ter sido um problema temporário em algum dos arquivos externos.


Issue with LSI SAS2116 - no drives being detected on Fedora 32 kernel 5.8.*

Question: Last week I updated my kernel using the regular DNF update process. On reboot, none of the drives in my mdadm arrays were detected. I narrowed down the issue to a problem with the kernel and used an older kernel to boot. I waited a week for the next kernel update and ran the process again, hoping it was just a bad kernel, but the problem has not been resolved. Dmesg shows kernel: mpt2sas_cm0: failure at drivers/scsi/mpt3sas/mpt3sas_scsih.c:10790/_scsih_probe()! on both 5.8 kernels. After some research, I'm pretty sure that Fedora has dropped support for sas2116 controllers (https://access.redhat.com/discussions/3722151?page=2), so I either need to find drivers for this card or replace it with a 12gb/s card.
What do you suggest? Where can I find drivers for this card for Fedora 32 and how do I install them, or what would be a good 12gb/s card to replace it with (the card currently drives a 24 bay supermicro backplane with 12 drives installed)? The card I currently use is a LSI 9201-16e.
Comment: Nothing in that link discusses Fedora, and I can't find any reason to think that Fedora dropped support for this device. This looks more like a bug, or possibly a hardware failure. If it works on a 5.7 kernel, then it'll be a bug, and you should consider reporting it as such.
Comment: I looked in Red Hat's Bugzilla (used for Fedora issues as well) and didn't find an open bug, but I am experiencing the problem too, on my LSI 9201-16e, which is a SAS2116 based card.  [RHBZ 1878332](https://bugzilla.redhat.com/show_bug.cgi?id=1878332)  It works on 5.7.17-200, but not on any 5.8 series kernel.  Follow the bug to see Fedora & Red Hat progress..
Answer: The issue is related to how the driver for the newer Broadcom/LSI Tri-Mode cards allocate large amounts of DMA memory for the very high 32455 default queue depth in the latest driver. This is problematic for these older cards as they use the same driver, but do not perform the logic to release all DMA queues then re-request on 32-bit boundary if the original DMA request is not fully allocated.  To work around the issue you can set the kernel argument to lower the queue depth to 10000:
grubby --update-kernel=ALL --args="mpt3sas.max_queue_depth=10000"
You can find more details here: https://bugzilla.kernel.org/show_bug.cgi?id=209177
Comment: While that command will work on some systems, the general answer here is to set the parameter 'mpt3sas.max_queue_depth' equal to 10000 or less, by some means, by the OS loader (likely GRUB). The parameter is a kernel parameter, a parameter used by the kernel to decide how exactly how the kernel interacts with the hardware (its only job). Generally the string 'mpt3sas.max_queue_depth=10000' will appear in the grub.cfg file.
Comment: Yes, as my answer states, `To work around the issue you can set the kernel argument to lower the queue depth to 10000: […] args="mpt3sas.max_queue_depth=10000"'. Which is self evident what the workaround is for any Linux system. This question was for Fedora 32, not general Linux, hence answered as such.


Mean of a sliding window in R

Question: I have a vector of values that I would like to report the average in windows along a smaller slide.
For example, for a vector of the following values:
4, 5, 7, 3, 9, 8

A window size of 3 and a slide of 2 would do the following:
(4+5+7)/3 = 5.33
(7+3+9)/3 = 6.33
(9+8)/3 = 5.67

And return a vector of these values:
5.33, 6.33, 5.67

Is there a simple function that will do this for me? If it also returned the indices of the window starts that would be an added bonus. In this example that would be 1,3,5
Comment: Have you seen [this](http://rss.acs.unt.edu/Rdoc/library/TTR/html/MovingAverages.html)?
Comment: Can you give some background on this "slide" idea?
Comment: @J.M - I hadn't! Thank you! I'm about to see how it works.
Comment: @Shane - Yes! I'm sorry that wasn't clear. The slide is the number of positions/indices you move to start computing the next window of averages. So rather than the next window starting after the end of the last there is some overlap when the slide is smaller than your window size. The idea is to smooth out the data points a bit.
Comment: Thanks, I had the same question. Now, I found it useful the function "rollapply".
Answer: Function rollapply in package zoo gets you close:
> require(zoo)
> TS <- zoo(c(4, 5, 7, 3, 9, 8))
> rollapply(TS, width = 3, by = 2, FUN = mean, align = "left")
       1        3
5.333333 6.333333

It just won't compute the last value for you as it doesn't contain 3 observations. Maybe this will be sufficient for your real problem? Also, note that the returned object has the indices you want as the names of the returned vector.
Your example is making an assumption that there is an unobserved 0 in the last window. It might be more useful or realistic to pad with an NA to represent the missing information and tell mean to handle missing values. In this case we will have (8+9)/2 as our final windowed value.
> TS <- zoo(c(4, 5, 7, 3, 9, 8, NA))
> rollapply(TS, width = 3, by = 2, FUN = mean, na.rm = TRUE, align = "left")
       1        3        5
5.333333 6.333333 8.500000

Comment: @mbq; that is making a strong assumption that the observation is 0. I had been mulling this point and T-Burns is making the same assumption (an unobserved 0). I would prefer perhaps to pad with NA and pass in the `na.rm = TRUE` argument to `mean`. The answer won't be the same as what the OP requested, but it seems more useful. I'll edit my answer to include this.
Comment: BTW, I once wrote about a usage of this function to implement the notion of "quantile loess" : http://www.r-statistics.com/2010/04/quantile-loess-combining-a-moving-quantile-window-with-loess-r-function/
Comment: You may add a 0 at the end of x (`x<-c(x,0)`) to get the last element of answer.
Comment: @ucfagls Yet this is easy to change and as you said this assumption was made by the OP. On the other hand, I would be even more restrictive and removed the last average.
Comment: Thanks! Especially for noting the last value as zero assumption, I hadn't considered that. I definitely care about that last window!!
Answer: Rollapply works great with a small dataset. However, if you are working with several million rows (genomics) it is quite slow.
The following function is super fast.
data <- c(runif(100000, min=0, max=.1),runif(100000, min=.05, max=.1),runif(10000, min=.05, max=1), runif(100000, min=0, max=.2))

slideFunct <- function(data, window, step){
  total <- length(data)
  spots <- seq(from=1, to=(total-window), by=step)
  result <- vector(length = length(spots))
  for(i in 1:length(spots)){
    result[i] <- mean(data[spots[i]:(spots[i]+window)])
  }
  return(result)
}

http://coleoguy.blogspot.com/2014/04/sliding-window-analysis.html
Comment: Quite helpful. But be aware, that window=3 will return the average of 4 (!) values, unless you add a `-1` (to the range) and a `+1` (to the loop).
Comment: Just as a hint, this function is not as fast as you might expect: I modified it to calculate a median instead of the mean and used it for a 17 million row data set with a window size of 3600 (step=1). It took 25 minutes to complete. In addition, I wrote a Go program for the same task and it finished within 21 seconds. But the problem isn't the language, it is the algorithm. For this algorithm, the window size is of critical importance. I think the options from the TTR package are a much better option if you are looking for a simple moving mean calculation (look at the other answers).
Answer: This simple line of code does the thing:
((c(x,0,0) + c(0,x,0) + c(0,0,x))/3)[3:(length(x)-1)]

if x is the vector in question.
Comment: @Henric I use this trick frequently, yet user1414's code return this roll with slide 1, not 2, as intended by OP. Check out `(c(0,0,x)+c(0,x,0)+c(x,0,0))/3` to see what I mean (and how does it work). The proper formula would be: `(c(0,0,x)+c(0,x,0)+c(x,0,0))[1:(length(x)-3)*2+1]/3` (we must cut 0-padding at the beginning and select even elements then.
Comment: This does not return what the asker wanted, but 5.33 5.00 6.33. However, it looks quite interesting. Can you explain your idea, because I don't get it.
Answer: I can do this easily in Matlab and duck while you downvote me:
%given vector x, windowsize, slide
idx1 = 1:slide:numel(x);
idx2 = min(numel(x) + 1,idx1 + windowsize);  %sic on +1 here and no -1;
cx = [0;cumsum(x(:))];  %pad out a zero, perform a cumulative sum;
rv = (cx(idx2) - cx(idx1)) / windowsize; %tada! the answer!

as a side effect, idx1 is the index of the element in the sum. I am sure this can be easily translated into R. The idiom first:skip:last in Matlab gives the array first, first+skip, first+2skip, ..., first + n skip, where the last element in the array is no greater than last.
edit: I had omitted the averaging part (divide by windowsize).
Comment: This marg... comment box is too narrow for this code, so I've posted a new answer.
Comment: Thanks, but MATLAB isn't free!!
Comment: +1 Not tada, rv/windowsize ;-)
Comment: @T-Burns: octave is free, however; also R is close enough to Matlab that this code can easily be translated. In fact, @mbq did that..
Answer: library(zoo)
x=c(4, 5, 7, 3, 9, 8)
rollmean(x,3)

or
library(TTR)
x=c(4, 5, 7, 3, 9, 8)
SMA(x,3)

Comment: it is only one direction
Comment: Does this work for 2D matrices? Like how? If the window size is 3*3 as an example
Answer: shabbychef's answer in R:
slideMean<-function(x,windowsize=3,slide=2){
 idx1<-seq(1,length(x),by=slide);
 idx1+windowsize->idx2;
 idx2[idx2>(length(x)+1)]<-length(x)+1;
 c(0,cumsum(x))->cx;
 return((cx[idx2]-cx[idx1])/windowsize);
}

EDIT: Indices you're looking for are just idx1... this function can be easily modified to return them also, but it is almost equally fast to recreate them with another call to seq(1,length(x),by=slide).
Comment: thanks for translating. I figured it would be an easy exercise, and I learned some R from it
Comment: My updated answer is use `fromo::running_mean` from the bleeding edge version of my [fromo package](https://github.com/shabbychef/fromo/tree/dev).
Answer: This will get you the window means and the index of the first value of the window:
#The data
x <- c(4, 5, 7, 3, 9, 8)

#Set window size and slide
win.size <- 3
slide <- 2

#Set up the table of results
results <- data.frame(index = numeric(), win.mean = numeric())

#i indexes the first value of the window (the sill?)
i <- 1
#j indexes the row of the results to be added next
j <- 1
while(i < length(x)) {
    #This mean preserves the denominator of 3
    win.mean <- sum(x[i:(i+2)], na.rm = TRUE)/win.size
    #Insert the results
    results[j, ] <- c(i, win.mean)
    #Increment the indices for the next pass
    i <- i + slide
    j <- j + 1
    }

Various caveats apply: haven't tested this against anything but your sample data; I believe that appending to data frames like this can get really slow if you have lots of values (because it'll copy the data.frame each time); etc.  But it does produce what you asked for.
Comment: wasn't me either, but as mentioned by yourself, pre-allocation of the result object will help with the speed issue. One trick, if you don't know, or it is tedious/difficult to determine, the size of the result object you need. Allocate something reasonable, perhaps pre-filling with NA. Then fill in with your loop, but add a check that if you are approaching the limit of the preallocated object, allocate another big chunk, and continue filling.
Comment: @mbq; Speed of results, whilst important, isn't the only consideration. Instead of having to reinvent the while and handle all the indexes etc in the custom solutions, the one-linear that is `rollapply` is much easier to understand and grep the intention of. Also, `rollapply` is likely to have had many more eyeballs checking its code than something I might cook up one afternoon. Horses for courses.
Comment: Changing `[i:(i+2)]` to `[i:(i+win.size-1)]` would make the code more general, I think.
Comment: Please don't downvote without providing a comment.  How am I supposed to know what's wrong?
Comment: It wasn't me, but this is slow (but not much slower than `rollapply`).
Comment: ucfagls, thanks for adding some info on pre-allocating when you don't know the ultimate size of the object - that's helpful.  And while I agree that rollapply is probably almost definitely the way to go, I a) wanted to provide an example that would calculate the edge cases with less than three values, and b) just wanted to use `while()`, which I've yet to have a use for ;)
Answer: You are doing a convolution operation. The implementation in R uses FFT internally and you are unlikely to beat it with loops and such things.
> vals=c(4, 5, 7, 3, 9, 8, 0)
> convolve(x=vals, y=c(1, 1, 1)/3, type="filter")
[1] 5.33 5.00 6.33 6.67 5.67

If you want to extract every second result.
> tmp <- convolve(x=vals, y=c(1, 1, 1)/3, type="filter")
> tmp[0:2*2+1]
[1] 5.33 6.33 5.67

Mean of a sliding window in R


jquery ajax: how to keep record not dissapear when the page is refresh

Question: i use this script

this script combine live update and delete record using jquery and ajax
the problem is when I refresh the page, the record will disappear .. how to keep records that show up are not dissapear when the page is reloaded?
Answer: First Check the comment list. Did you put any limit in query, if so then use Order by Primary ID desc.So it would display latest records first.
When you delete any record, check whether it is actually deleted from database or not. Because you are not checking whether record actually deleted or not as per the code you given.
Answer: Assuming you are using update_data.php and delete_data.php to manipulate some database, you could use PHP to render the page initially using the data that is currently on the database.
If that is not the case, and you don't have access to that database (it could be a third party web service, right?), or you don't want to do that for any reason, you could use cookie like Saeed answered.


How to search in mysql so that accented character is same as non-accented?

Question: I'd like to have:
piščanec = piscanec in mysql. I mean, I'd like to search for piscanec to find piščanec also.
So the č and c would be same, š and s etc...
I know it can be done using regexp, but this is slow :-( Any other way with LIKE? I am also using full text searches a lot.
UPDATE:
select CONVERT('čšćžđ' USING ascii) as text

does not work. Produces: ?????
Comment: čšćžđ are not ASCII characters, so it makes sense that they are converted into ????? ;)
Comment: Yes, but this was a proposal of one of the responses.
Answer: It's not straightforward, but you'll probably best off creating your own collation for your fulltrext searches. Here is an example:
http://dev.mysql.com/doc/refman/5.5/en/full-text-adding-collation.html
with more info here:
http://dev.mysql.com/doc/refman/5.5/en/adding-collation.html
That way, you have your collation logic completely independent of your SQL and business logic, and you're not having to do any heavy-lifting yourself with SQL-workarounds.
EDIT: since collations are used for all string-matching operations, this may not be the best way to go: you will end up obfuscating differences between characters that are linguistically discrete.
If you want to suppress these differences for specific operations, then you might consider writing a function that takes a string and replaces - in a targetted way - characters which, for the purposes of the current operation, are to be considered identical.
You could define one table holding your base characters (š, č etc.) and another holding the equivalences. Then run a REPLACE over your string.
Another way is just to CAST your string to ASCII, thereby suppressing all non-ASCII characters.
e.g.
SELECT CONVERT('<your text here>' USING ascii) as as_ascii

Comment: Thank you. At this second I was just reading that page if it ca help. I thought collation is just for sorting, not for other things, I gues I need to read thru it. Is this collation only for full text searches or for everything on the server that is using this mysql?
Comment: Collation deals with string-matching (and thereby implicitly with sorting), so it should suit your needs. You just implement it once and the database uses it wherever string-matching is required. See here: http://dev.mysql.com/doc/refman/5.5/en/charset-general.html
Comment: Huh, thank you, it seems complicated to do. I use unicode utf-8 as our charset but we have characters from latin2 8859-2 and from MS1250 (on the keyboard) so uft-8 was the best choice and I have yet to find out if the collation can be changed. Problem is I do not want to affect sortiong, č comes AFTER c, it is not the same, I'd like just the search to find either c and č the saame (mobile phones usually don't have out letters).
Comment: ok, if the logic is not to be universally applied to all string-matching operations, you may have to do it differently.
Comment: Well to all, just not for the sorting as č is different character than c
Comment: Yes, that is what I am trying to do, find a mysql way of telling characters are identical. Regexp has something like [cč] but it is slow.
Comment: You mean one table only special characters and the other only equivalents, not whole ascii table?
Comment: yes, just the equivalents. Although I would probably try the CONVERT first.
Comment: let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/18216/discussion-between-davek-and-jerry2)
Answer: Declare the column with the collation utf8_generic_ci. This collation considers š equal to s and č equal to c:
create temporary table t (t varchar(100) collate utf8_general_ci);
insert into t set t = 'piščanec';
insert into t set t = 'piscanec';
select * from t where t='piscanec';
+------------+
| t          |
+------------+
| piščanec   |
| piscanec   |
+------------+

If you don't want to or can't use the utf8_generic_ci collation for the column--maybe you have a unique index on the column and want to consider piščanec and piscanec distinct?--you can use collation in the query only:
create temporary table t (t varchar(100) collate utf8_bin);
insert into t set t = 'piščanec';
insert into t set t = 'piscanec';
select * from t where t='piscanec';
+------------+
| t          |
+------------+
| piscanec   |
+------------+
select * from t where t='piscanec' collate utf8_general_ci;
+------------+
| t          |
+------------+
| piščanec   |
| piscanec   |
+------------+

The FULLTEXT index is supposed to use the column collation directly; you don't need to define a new collation. Apparently the fulltext index can only be in the column's storage collation, so if you want to use utf8_general_ci for searches and utf8_slovenian_ci for sorting, you have to use use collate in the order by:
select * from tab order by col collate utf8_slovenian_ci;

Comment: I can not use the general_ci because then all the queries I would get from this field would treat c and č the same which would make sorthing problems like: čebula, česen, cvet. But cvet should be the first as c is before č when sorting.
Comment: If I use the collate utf8_general_ci I do indeed get the results I wanted from a LIKE query. I wonder how much slower this is (have to try) and how it affects the full text search. There I also need to use the collate I guess else piščanec != piscanec.
Comment: Nice thing is that order by still uses out slovenian_ci collate even if I collate the query. Huh.
Comment: Seems for full text search I do not know how to use collate in select :-(
Comment: You can use `utf8_slovenian_ci` for sorting while the column itself is something else: `select * from tab order by col collate utf8_slovenian_ci`
Comment: It works if I put utf8_general_ci on the column and use slovenian_ci for the order by. It does not work if my column has slovenian_ci and I want to match against general_ci. Seems like the column collation is the only relevant thing for full text search. I don't like this because I have to make every order by now in my website have slovenian collation and all the columns to general. In reality the collation should be generally slovenian, just the search should be general_ci so I should just be allowed to use general_ci as collation table in match against, but it DOESN?T work this way :-(
Comment: AH, your last paragraph kind of explains my fears. I have to have the column in general_ci and need to modify all the order by clauses instead. I am not sure if that would make my index work or not if I collate on different collation than the index is stored (normal selects not full text ones I mean here).
Comment: You could add an extra column with 'general' collation and a trigger that makes sure it has the same values as the original, and use the new column for fulltext searches... not optimal but avoids using collate with every order by
Comment: Hm, that is an idea, but then the long text field would be duplicated. And I do not know how to write such trigger. I think maby it is better to stick with order by collation. I think there is no better way although I am not sure about performance impact.
Comment: The trigger is simple, bordering on trivial, but if you don't have enough storage that's ruled out: http://forums.mysql.com/read.php?99,414321,414345#msg-414345 ORDER BY using an explicit collation should not be a lot more expensive than order by the column's own collation because the data will be pretty much sorted already, but you should test it.
Comment: let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/18240/discussion-between-jerry2-and-joni)


Suppes' Axiom of Cardinal Numbers

Question: In Suppes' book, Axiomatic Set Theory he introduces an axiom concerning cardinal numbers,before introducing them, namely that each set is associated with an object known as a cardinal number, and that if two sets have the same cardinal number then they are equipollent.
He states that later on he can obtain the cardinal numbers via another method, using something known as ordinal numbers and the axiom of choice, but he does not state if that will lead exactly to the axiom he's stated so far as I can tell. To anyone familiar with this book (1972) I'd like to ask the question - is there any point reading the section that uses this axiom? Will this axiom be entirely derived later on using the methods of ordinal numbers?
Answer: See Ch.8 : The Axiom of Choice; page 242 :

Theorem 8 : For any set $A$ there is a unique cardinal number $\alpha$ such that $\alpha \approx A$.

This is nothing other than the axiom for cardinal number [page 111] postulating that :

with each set $A$ is associated an object $\mathfrak K(A)$, the cardinal number of $A$, such that with two equipollent sets we associate the same cardinal number.
Comment: Thank you, it seemed like it would be a shame if all of the developments in cardinal arithmetic therein were not proven using accepted axioms.

Suppes' Axiom of Cardinal Numbers


Fingertip-covering picks for fingerstyle guitar

Question: I've seen a couple of videos in which a fingerstyle guitar player appears to have solid white, maybe plastic, picks covering the last segment of his finger.
I haven't been able to find these at the music stores I've been to.  All I've seen there are metal fingerpicks and plastic thumb picks.
Does anyone know what these picks are?
An example can be seen at about 2:47 to 2:50 in this video of the group Mandolin Orange.  I've also seen them on Steve Baughman.
Comment: As far I'm aware, they're just called fingerpicking picks. I picked up a set from my local guitar store not too long ago - they aren't uncommon. A cursory search for "fingerpicking picks" has brought up numerous online shopping options. I think mine specifically are made by Stagg.
Answer: I searched for "finger picks small" on eBay and found some plastic ones, don't know if it answer your question, here's the link
Answer: Finger picks and thumb pics.  They make them in metal, plastic, and just about every other material they use to make pics.  I am surprised that you couldn't find them in the music store.  I have a few sets, got them at Guitar Center.  As suggested you can find them by googling "finger picks" and I see them on Amazon and every other online store.  Sam Ash and Guitar Center would have them.  If you really want them I would go to a store and try some out.  The fit can be an issue if you've never tried them before and you don't want to trow money away.
Comment: Yeah the stores I've checked (in Vancouver BC) have finger picks and thumb picks, but all the finger picks I've been able to find are metal.  I've got some of those, but don't really use them.  The ones I was asking about seem to be quite different from what I've got.  Yeah, I don't really want to just buy them online because I want to try them on first to get the right fit.  Thanks.
Comment: It surprises me that you cannot find plastic.  One of my students had the opposite problem, found plastic easily but not metal.  She has very small fingers and could not adjust the plastic to fit her fingers.


Bounding $\int_0^{\infty} x^p e^{-x} dx$ to find the values of p for integral convergence.

Question:
Find all the values of p for which the integral converges
  $$\int_0^{\infty} x^p e^{-x} dx$$

I am thinking about bounding the integral using
$$\int_0^{\infty} x^p e^{-2x} dx \leq  \int_0^{\infty} x^p e^{-x} dx  \leq  \int_0^{\infty} x^p e^{-0.5x} dx $$
But i do not see those 2 bounds very helpful.
Next option: I was thinking to choose a tangent line as lower bound but can't see one line as upper bound as the original curve runs to infinity.
What could a more adequate approach be here?
Much appreciated
Answer: For $x \in [0,1]$ we have $e^{-1} x^p \leqslant x^p e^{-x} \leqslant x^p$.
This should help you determine convergence and divergence of $\int_0^1 x^p e^{-x} \, dx$ by the comparison test.
For $[1, \infty)$ we have
$$\lim_{x \to \infty} \frac{x^p e^{-x}}{x^{-2}} = \lim_{x \to \infty} \frac{x^{p+2}}{ e^{x}} = 0  $$
Since $\int_1^\infty x^{-2} \, dx $ converges, by the limit comparison test $\int_1^\infty x^p e^{-x} \, dx$ converges for all $p$.
Thus, the values of $p$ for which the integral $\int_0^\infty x^p e^{-x} \, dx $ converges/diverges is dictated by the conditions for convergence/divergence of $\int_0^1 x^p e^{-x} \, dx.$ As you will see this is convergence for $p > -1$ and divergence for $p \leqslant -1.$
Comment: Since $x^pe^{-x} \geqslant e^{-1} x^p$ on $[0,1]$ and $\int_0^1 x^p \, dx $ diverges if $p \leqslant -1$.  For example if $p = -1$ we have $\int_c^1 x^{-1} \, dx   = - \log c \to \infty $ as $c \to 0$.
Comment: That is not a correct conclusion. What happens for example if $p = -1$?  We use the inequalities to apply the comparison test which says if $|f(x)| < g(x)$ and $\int_0^1 g $ converges then $\int_0^1 f$ converges. If $f(x) > g(x) >0$ and $\int_0^1 g$ diverges then $\int_0^1 f$ diverges.  As I showed above if $p = -1$ then $\int_0^1 x^p$ diverges like log and using the left inequality $\int_0^1 x^{-1} e^{-x} > e^{-1}\int_0^1 x^{-1} = \infty$.
Comment: Note that for $p \neq -1$, $\int_c^1 x^{p} = (1 - c^{p+1})/(p+1)$.  If $p < -1$ then $c^{p+1} \to \infty$ as $c \to 0$ and $\int_0^1 x^p$ diverges. Since $x^p e^{-x} > e^{-1}x^p$ by the comparison test $\int_0^1 x^p e^{-x}$ diverges for $p \leqslant -1$.
Comment: Can you please explain little bit more for about the divergence part!
Comment: I found that $$\frac{1}{ep+e} \leq \int_0^1 e^{-x}x^p \leq \frac{1}{p+1}$$ solving $$\frac{1}{ep+e} \leq \frac{1}{p+1}$$ I found $p \leq -1$ Should it mean that the integral converges when $p \leq -1$?
Comment: If $p > -1$ then we see that $c^{p+1} \to 0$ as $c \to 0$ and $\int_0^1 x^p$ converges.  Since $x^p e^{-x} < x^p$, by the comparison test $\int_0^1 x^p e^{-x} $ converges for $p > -1$.
Answer: This is the Gamma Function.   Integrating by parts is one of the main tools...  For $p\in \mathbb{Z_+}$, $\Gamma (p+1)=p!$.  By analytic continuation  $\Gamma$ is defined for all complex numbers except the negative integers. ...


How to create WPF Rounded button using class

Question: I want to create Rounded button using class instead of XAML style
This code work in WinForms app, how i can convert it to WPF code?
<code>   public class RoundButton : Button
    {
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            GraphicsPath grPath = new GraphicsPath();
            grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
            this.Region = new System.Drawing.Region(grPath);
            base.OnPaint(e);
        }
    }
</code>
Comment: Doesn't that kind of defeat the whole purpose of having XAML? If you are using WPF, you should do [something similar to this](https://stackoverflow.com/questions/2601604/wpf-user-control-round-corners-programmatically).
Answer: Assuming you have a really good reason for doing this (like if you really want to custom draw in more complex scenarios like drawing diagrams or similar), you could do something like:
<code>public class RoundButton : Button
{
    public RoundButton()
    {
        DefaultStyleKey = typeof(RoundButton);
    }

    protected override void OnRender(DrawingContext dc)
    {
        double radius = 10;
        double borderThickness = 1; // Could get this value from any of the this.BorderThickness values

        dc.DrawRoundedRectangle(Background, new Pen(BorderBrush, borderThickness), new Rect(0, 0, Width, Height), radius, radius);
    }
}
</code>
But I really, really recommend going down the XAML route instead in this case. Custom drawing does not make sense here at all.
One obvious issue with the above code, for instance, is that for it to work, you have to disable the default button style or a button will be drawn on top of your drawing.
In this case a style for RoundButton doesn't exist and the control does not define a placeholder for where text or other content should go. If you want this, you are better off defining this style with a control template and could just as well put in the visuals there.


Perturbations method to solve differential equations

Question: Hi  I am trying to solve the following differential equation
$ \frac {d^2y }{dt^2}+ \epsilon \frac { dy}{dt}+1=0$
With the conditions  $y (0)=0$ and $dy/dt(t=0)=1$
And what I got is
$y=- \frac {t^2}{2} + \epsilon \frac {t^4}{24} - \epsilon^2 \frac {t^6}{720}+ \dots$  But i am not sure if it is correct or not?
Comment: Following what I think you were doing, $y_0''+1=0 \Rightarrow y_0=-t^2/2$ (plus homogeneous terms that you have neglected completely). Assuming $-t^2/2$ satisfies whatever boundary conditions you want, then $y_1''+y_0'=y_1''-t=0$ so $y_1=t^3/6$. So yeah, you definitely made a mistake.
Comment: Ok Ian thank you so much , and you mean the correct answer is $y=- t^2/2 + € t^3/6 - €^2 t^4/24 +€^3 t^5/60+....$
Answer: You can here compute the exact solution and compare your perturbation results against it. Integrating once gives
$$
y'+ϵy+t=y_0'+ϵy_0+0=1
$$
This is still simple enough that the method of undetermined coefficients works,
$$
y(t)=Ae^{-ϵt}+Bt+C\\
B+ϵ(Bt+C)=1-t\implies B=-\frac1ϵ,~C=\frac{1+ϵ}{ϵ^2}, \\
y_0=0\implies~ A=-C
$$
so that finally
$$
y(t)=\frac{(1+ϵ)(1-e^{-ϵt})-ϵt}{ϵ^2}
=t-(1+ϵ)(\tfrac12t^2-\tfrac16ϵt^3+\tfrac1{24}ϵ^2t^4\mp...)\\
=t-\tfrac12t^2-ϵ(\tfrac12t^2-\tfrac16t^3)+ϵ^2(\tfrac16t^3-\tfrac1{24}t^4)\mp...
$$
Comment: The given initial conditions are satisfied with $y_0=t-\tfrac12t^2$. The other $y_k$ have initial conditions equal to zero, as the given initial conditions do not depend on $ϵ$.
Comment: Ok but I  still confused about the conditions that are given  ..for example the second tearm $y_{1} =(1/6 t^3 - 1/2 t^2)$ it dose meet just the first condition but not the second $y'(0)=1$   could you please explain?
Comment: Ok thank you so much for explaining. And is that true for all situation, I mean the initial condition always satisfied with $y_{0}$ only
Comment: Yes, if it does not depend on $ϵ$. It would be different if for example $y(0)=ϵ$ was given, then $y_1(0)=1$.
Comment: Many thanks for you I got it :)


when I run a remoteapp from the RD Web interface 2012 r2 I get prompted to save or open this remote app

Question: I have Just setup RD Web Access with remote apps on server 2012 r2
when I log in to the rd web interface and select a remote app to run it ask me do I want save or open the remote app instead of just running
How do stop this
Kevin
Answer: To prevent this from happening you MUST use Internet Explorer as your web browser, and you have to enable the RDS ActiveX control when prompted after visiting the remote web access site for the first time.
If you want to avoid the Remote App web site, see here for some other ideas for deploying remote app for your users: https://www.concurrency.com/blog/w/how-to-deliver-remoteapps-from-windows-server-2012
It's a little outdated, but it will give you some ideas.
Comment: Edge apparently also integrates RDP launching now (this may be specific to a beta build of 1707 but I noticed it working last week).


Challenging visualization task: simultaneously visualizing 15 regions by 3 descriptive values

Question: I have a rather challenging visualization task.
15 geographical regions (data points for plot), each described by 3 continuous values and all these values have confidence intervals. The aim is to visualise this data in a way, which allows to compare/rank these regions (e.g. from poor to good or from low disparity to high disparity).
For example:

region A: all descriptive values are very low
region C: two descriptive values very high, one very low
region F: all descriptive values are very high

Generated data
library(tidyverse)

set.seed(1)

#make new data
df = tibble(
  region = c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O"),
  prop = rnorm(15, 50, 20),
  income = rnorm(15, 10, 4),
  sd = rnorm(15, 2, 1))

#add confidence intervals
df = df %>% mutate(
  prop_lower = prop - runif(1, 5, 15),
  prop_upper = prop + runif(1, 5, 15),
  income_lower = income - runif(1, 0.5, 2.2),
  income_upper = income +  runif(1, 0.5, 2.2),
  sd_lower = sd - runif(1, 0.1, 0.6),
  sd_upper = sd + runif(1, 0.1, 0.6))

#reorder columns
df = df[c("region", "prop", "prop_lower", "prop_upper", "income", "income_lower", "income_upper", "sd", "sd_lower", "sd_upper")]

<--  -->
 region      prop prop_lower prop_upper    income income_lower income_upper        sd  sd_lower sd_upper
      A 37.470924  30.074630   43.06027  9.820266    8.2283755    11.809923 3.3586796 2.8692222 3.857334
      B 53.672866  46.276572   59.26221  9.935239    8.3433489    11.924897 1.8972123 1.4077549 2.395867
      C 33.287428  25.891134   38.87677 13.775345   12.1834548    15.765003 2.3876716 1.8982143 2.886326
      D 81.905616  74.509322   87.49496 13.284885   11.6929947    15.274542 1.9461950 1.4567376 2.444849
      E 56.590155  49.193861   62.17950 12.375605   10.7837152    14.365263 0.6229404 0.1334831 1.121595
      F 33.590632  26.194338   39.17998 13.675909   12.0840194    15.665567 1.5850054 1.0955481 2.083660
      G 59.748581  52.352287   65.33792 13.128545   11.5366552    15.118203 1.6057100 1.1162527 2.104364
      H 64.766494  57.370200   70.35584 10.298260    8.7063699    12.287918 1.9406866 1.4512293 2.439341
      I 61.515627  54.119333   67.10497  2.042593    0.4507032     4.032251 3.1000254 2.6105680 3.598680
      J 43.892232  36.495938   49.48158 12.479303   10.8874130    14.468961 2.7631757 2.2737184 3.261830
      K 80.235623  72.839329   85.82497  9.775485    8.1835950    11.765143 1.8354764 1.3460191 2.334131
      L 57.796865  50.400571   63.38621  9.376818    7.7849279    11.366476 1.7466383 1.2571810 2.245293
      M 37.575188  30.178894   43.16453  4.116990    2.5251004     6.106648 2.6969634 2.2075060 3.195618
      N  5.706002  -1.690292   11.29535  8.087400    6.4955097    10.077057 2.5566632 2.0672059 3.055318
      O 72.498618  65.102324   78.08796 11.671766   10.0798762    13.661424 1.3112443 0.8217870 1.809899

Best option I have found for plotting so far
library(patchwork)

#panel 1
A = df %>%
ggplot(aes(x = prop, y = income, color = region, label = region))+
  geom_errorbarh(aes(xmin = prop_lower, xmax = prop_upper, height = 0), alpha = 0.8)+
  geom_linerange(aes(ymin = income_lower, ymax = income_upper), size = 0.5, alpha = 0.8) +
  geom_text(size = 3.5, alpha = 0.8, segment.alpha = 0,
  nudge_x = 2,
  nudge_y = 0.5)+
  geom_point(aes(), size = 1.5)+
  theme_classic()+
  theme(legend.position = "none")

#panel 2
B = df %>%
ggplot(aes(x = region, y = sd))+
  geom_linerange(aes(ymin = sd_lower, ymax = sd_upper), size = 0.5, alpha = 0.8) +
  geom_point(aes(), size = 1.5)+
  theme_classic()+
  theme(legend.position = "none")

#panel 1 and 2
A/B + plot_layout(heights = c(6, 2))

The problem is that you have to check multiple plot panels before making any conclusions about a region.
Or should I think out of the box and do something completely different?
E.g. trying to visualise these regions on a map? Any strategies for this (how to choose the colours etc)?
A random example from google photos

How you guys visualise such data? Any promising three-axis plots?
Provided solutions so far
cdalitz suggested multiple coordinate plot. should be doable with CIs while doing 3 separate ggplots, later connection lines and labels can be added in a graphical program. I made a scheme.
Comment: Can you provide a small example dataset for people to work with? It can be fake data, if yours are confidential. Do you want the CIs to show up in the plot?  What do you mean by the CIs should be "comparable"?
Comment: Good point, Monica! I edited the original post by providing my best solutions so far.
Comment: I forgot one answer: Showing CIs allows easy interpretation - is there a significance between the regions in a certain measure or not. But maybe this is a mission impossible.
Comment: Have you tried a parallel coordinates plot? In R, it is available in the function *parcoord* of the builtin library *MASS*.
Comment: Seems promising. Would it allow to plot CI-s also?
Comment: You state that your aim is to find a plot that will allow you to rank the regions.  No plot will do that for you.  You need to decide how to rank regions based on a substantive understanding of the variables (see: [Creating an index of quality from multiple variables to enable rank ordering](https://stats.stackexchange.com/q/9358/)).
Comment: Thank you for the link! Seems that just finding a visualization method would be a good start. "Ranking" can later be done in discussion.
Answer: Consider a multivariate analysis as a descriptive statistic.  Use canonical variates to simultaneously predict the 14 indicator variables for 15 regions from the other variables.  The first canonical variate is the linear correlation of the other variables having the maximum $R^2$ with the best linear combination of the indicators.  Then interpret the region loadings to see to what extent regions differ from one another, and interpret the coefficients of the three variables to see how regions vary with respect to those variables.
Comment: A small worked example would probably help a lot here.


Decrease number length by rounding in java

Question: There's a functionality in my project that does a multiplication of 3 different big decimals.
Sometimes, the result could give some really large numbers like:
213215648783612154.334
or
421342342342342344.123

The thing is: the column which keeps record of this value is defined like NUMBER(8,3). Is there a way to decrease the length of this number by doing some rounding operations? I really don't want to redefine the column because it's being used in other parts of the system.
Comment: What value you wan to be stored for `421342342342342344.123`? Remember maximum allowed value is `99999.999`
Comment: What's about just take a smaller maximum in your random function?
Comment: When you create your answer BigDecimal you can give it a rounding scale.
Comment: I know that i can give a rounding scale, but can i give it so the length of my number decreases? From like (14,3) to (8,3)?
Comment: How on earth do you want these numbers to fit in 8 digits, even with a lot of rounding ? The only rounding which can do that is something like `if (number>99999999) { number = 99999999; }`, but it's certainly not what you want.
Comment: Rounding or truncating?
Answer: You have a basic design or logic flaw in your system.
If you have a database that expects values as NUMBER(8,3), then it is saying "I have space for 8 digits, 3 of them are decimals". The largest value that can be stored in that column is 99999.999.
You cannot store any larger value. Period.
So, what is the issue? Either:

your program logic is wrong, and the values it is calculating like 213215648783612154.334 are just plain broken.... or
your database implementation is badly designed because it should be able to store larger values than planned.

Which one you fix depends on your particular situation.
Answer: Answer is: It is impossible to round in some meaningful way. Because max value is 99999.999
You can try encode instead rounding. But all other code that work with this column MUST be aware of encoding.
For example you can use first 5 digits as mantissa and last 3 as exponent (and hide sign somewhere). But i want to look at faces of your colleagues if you try it.
Answer: hmm sure you can just cut off some of the numbers even though it might give you some wrong data hehe.
String number= Mynumber.tostring(); //assuming mynumber is the object that stores the number
number= number.substring( (number.length()-(number.length()-9)) , number.length()); //adding 1 to 8 because of the '.'
System.out.pritnln(number);

input =
213215648783612154.334

output:
12154.334


How can I import/rewrite settings/content types/blocks/etc from live with the newly developed features on dev?

Question: I have a site that's already up and running. On my local dev environment I occasionally develop new features for that site.
I have certain configs(blocks, settings, etc) that I need to add to the live site. However, I can't seem to figure out a way to import them without deleting the current blocks/settings/etc that already exist on the live site.
Is there some way that I could import them on the live site without deleting them beforehand?
Answer: IMHO, using git for that works quite well.
You have a production branch and a development branch (and possibly many feature branches). Locally, you are on the develop branch, you make your changes there, export and commit your changes there
Before you do a deployment, you switch to production branch, do a config export ,sync it down, commit it, merge develop into production, do a local config import to make sure that things are consistent and then deploy.
A useful presentation for this is https://de.slideshare.net/nuvoleweb/advanced-configuration-management-with-config-split-et-al, for example slide 39, although that focuses more on working with multiple developers, but the process with production is similar.


Look and you shall find (a correlation)

Question: I have several hundred measurements. Now, I am considering utilizing some kind of software to correlate every measure with every measure. This means that there are thousands of correlations. Among these there should (statistically) be a high correlation, even if the data is completely random (each measure has only about 100 datapoints).
When I find a correlation, how do I include the information about how hard I looked for a correlation, into it?
I am not at a high level in statistics, so please bear with me.
Comment: This is a great example of why one needs multiple hypothesis testing.
Comment: @tmo `R` on this machine takes 18 seconds to obtain 1000 realizations of the null permutation distribution of the max correlation coefficient for a 300 by 100 matrix `x`: `correl <- function(x, k=1) {
  n <- dim(x)[2] * (dim(x)[2]-1) / 2;
  v <- cor(x);
  sort(v[lower.tri(v)])[(n-k+1):n]
}; sim <- replicate(1000, correl(apply(x,2,sample)))`
Comment: Presumably one can use the permutation procedure to generate a null distribution for significance thresholds for the largest correlation, a different threshold for the second largest correlation, and so on. Hopefully this would only take a few hours in Python or R. (Ha! Famous last words.) But surely someone must already have done this and saved the code somewhere?
Answer: This is an excellent question, worthy of someone who is a clear statistical thinker, because it recognizes a subtle but important aspect of multiple testing.
There are standard methods to adjust the p-values of multiple correlation coefficients (or, equivalently, to broaden their confidence intervals), such as the Bonferroni and Sidak methods (q.v.).  However, these are far too conservative with large correlation matrices due to the inherent mathematical relationships that must hold among correlation coefficients in general.  (For some examples of such relationships see the recent question and the ensuing thread.)  One of the best approaches for dealing with this situation is to conduct a permutation (or resampling) test.  It's easy to do this with correlations: in each iteration of the test, just randomly scramble the order of values of each of the fields (thereby destroying any inherent correlation) and recompute the full correlation matrix.  Do this for several thousand iterations (or more), then summarize the distributions of the entries of the correlation matrix by, for instance, giving their 97.5 and 2.5 percentiles: these would serve as mutual symmetric two-sided 95% confidence intervals under the null hypothesis of no correlation.  (The first time you do this with a large number of variables you will be astonished at how high some of the correlation coefficients can be even when there is no inherent correlation.)
When reporting the results, no matter what computations you do, you should include the following:

The size of the correlation matrix (i.e., how many variables you have looked at).
How you determined the p-values or "significance" of any of the correlation coefficients (e.g., left them as-is, applied a Bonferroni correction, did a permutation test, or whatever).
Whether you looked at alternative measures of correlation, such as Spearman rank correlation.  If you did, also indicate why you chose the method you are actually reporting on and using.
Comment: This is a pretty thorough descriptiion of p-value adjustment methods but what is left unsaid is the criteria for adjustment.  Traditionally it has been familywise error rate.  But that is a strict criterion and is not useful when you are looking at thousands of comparisons.  In that case the false discovery rate first suggested by Benjamini is now commonly used.
Comment: What if we just want to look at correlations of very well defined pairs of variables (e.g. $corr(x_1,y_1)$,...,$corr(x_n,y_n)$, where each $x_i$ and $y_i$ are variables) but don't care about all the other possible combinations (i.e., don't care about $corr(x_i,y_j)$ $\forall i \not= j$)? Do we still need a correction?
Comment: @Jase Yes, you do. The amount of correction depends on the interrelationships among the variables.  Simulation-based methods are about the only practicable way to determine these corrections.
Comment: Wow nice.  Will this method that you discussed also correct the standard errors for serial correlation and heteroscedasticity issues?
Comment: @Jase It would be difficult to interpret correlation coefficients in a heteroscedastic model. Your comment appears to refer to a linear model in a time series setting, rather than estimation of multivariate correlation coefficients.
Comment: How important is it to report the permutation test if the number of observations is very large (say N = 100.000)? I find that the correlation for the permuted observations is very close to 0 and thus it seems redundant to report this if that is always the case for large N. I am using permutation testing in the context of finding the highest Pearson corr. for pairwise comparisons (see http://stackoverflow.com/questions/33650188/efficient-pairwise-correlation-for-two-matrices-of-features/33651442#33651442).
Comment: +1. The link for "standard methods to adjust the p-value" is broke. Could you please repair it? Thanks.
Answer: From your follow up response to Peter Flom's question, it sounds like you might be better served by techniques that look at higher level structure in your correlation matrix.
Techniques like factor analysis, PCA, multidimensional scaling, and cluster analysis of variables can be used to group your variables into sets of relatively more related variables.
Also, you may want to think theoretically about what kind of structure should be present. When your number of variables is large and the number of observations is small, you are often better relying more on prior expectations.
Comment: (+1) Good advice in light of the OP's comment to @Peter Flom's response.
Answer: This is an example of multiple comparisons.  There's a large literature on this.
If you have, say, 100 variables, then  you will have 100*99/2 =4950 correlations.
If the data are just noise, then you would expect 1 in 20 of these to be significant at p = .05.  That's 247.5
Before going farther, though, it would be good if you could say WHY you are doing this.  What are these variables, why are you correlating them, what is your substantive idea?
Or, are you just fishing for high correlations?
Comment: The reason why I wanted to do it like this was to have an open mind towards understanding my data, so maybe in a way I am fishing for correlations, which I did not think of before, for the purpose of getting enlightened. I am certainly not doing this to satisfy my boss or something abitrary. I would rather not get into the specifics of the data, as I want a general answer to this question, so I can use it in all situations in the future.
Answer: Perhaps you could do a preliminary analysis on a random subset of the data to form hypotheses, and then test those few hypotheses of interest using the rest of the data. That way you would not have to correct for nearly as many multiple tests. (I think...)
Of course, if you use such a procedure you will be reducing the size of the dataset used for the final analysis and so reduce your power to find real effects. However, corrections for multiple comparisons reduce power as well and so I'm not sure that you would necessarily lose anything.
Comment: (+1)  This is a great idea generally.  For large correlation matrices, however, there are so many statistics and so many of them can simultaneously be spuriously large that it usually pays to adjust.  Otherwise you wind up chasing a large number of misleadingly "significant" correlations that just disappear in the hold-out data.  (Run a simulation with, say, a few hundred draws from 50 uncorrelated standard normal variates.  It's an eye-opener.)

Look and you shall find (a correlation)


Iteratively Training an ARIMA model

Question: The Context
Let's say for argument's sake that I have a time series dataset, $X_t$, that is stationary, exhibits strong autocorrelation and is a good candidate for an ARIMA-type model.
I have a series of observations for this time series variable, $(X_{1,0},X_{1,1},...X_{1,N})$ which is evenly distributed in time and has no gaps.
I also have a second series of observations for this time series variable, from a different and non-overlapping time period, $(X_{2,0},X_{2,1},...X_{2,N})$, such the time $t$ at $X_{2,0}$ is much greater than the time $t$ at $X_{1,N}$.
The time series between $X_{1,N}$ and $X_{2,0}$ is unobservable.
I expect the same ARIMA model to be a good fit to both of these series (since it is just the same time series, measured from a different starting point).
The Problem
In Python, how can I fit my ARIMA model to both series of observations simultaneously? And if a third series, $(X_{3,0},X_{3,1},...X_{3,N})$, becomes available how can I improve the fit of the ARIMA model given the new data?
I've seen a number of different approaches online but I'm not convinced by any of them.
They seem to suggest concatenating the series together and treating them as a single time series, which I don't believe is a good option because the series are not contiguous.
The alternative I've seen is to use a library like pmdarima which has an .update() method. It's unclear to me whether pmdarima simply concatenates the new series onto the old series, and even if it doesn't, it seems like it would just refit the model to the new series using the old parameters as a starting point, rather than fitting to the whole set of observations.
I may be missing something here, this seems like it should be such a common problem and should be readily solved.
Comment: See https://stats.stackexchange.com/q/23036/159
Answer: You have three vectors $X_1, X_2, X_3$ generated by the same data generating process. There can be three cases:

The time gaps between $X_1, X_2, X_3$ are short and of known length.
The time gaps between $X_1, X_2, X_3$ are short but of unknown length.
The time gaps between $X_1, X_2, X_3$ are long.

In case of 1, fill in the gaps between $X_1, X_2, X_3$ by an appropriate number of NA values to make one long vector $Y$. Use the usual ARIMA fitting routine. The state-space representation and Kalman filtering in the fitting routine should be able to deal with NA values without a problem. This works in R e.g. using forecast::auto.arima. Hopefully it will work in Python as well.
In case of 2, I am not sure what to do...
In case of 3, the dependence between $X_1, X_2, X_3$ is negligible. Create a long vector $e$ that consists entirely of NA values. Concatenate $X_1, e, X_2, e, X_3$ into one looong vector $Y$. Placing the $e$ vector in between the $X$s effectively breaks up time dependence between them during fitting. (The idea is not mine. I have borrowed it from some old post probably by Rob J. Hyndman.) Proceed further as in case 1.
Comment: ah ok, makes sense. In Case 3 It seems like the length of the vector $e$ should be set as long enough for the impact of the last element of $X_2$ on the first element of $X_3$ to be approximately zero? So it wouldn't necessarily need to be determined by the actual length of time between $X_2$ and $X_3$?
Comment: @AndySmith, yes, I think so.

Iteratively Training an ARIMA model


How to achieve clean HTML markup?

Question: If you visit official website of Dries Buytaert https://dri.es/ and look into the source you will see very clean and minimal markup with no unnecessary tags and classes, eg:

When I create a simple custom block it has lots of junk under each field,  eg:

How to strip and delete all the junk and leave or add only classes and wrappers you need?
I did look up Fences, but it's latest version is in alpha since 2016 (and not sure if it does that) and cannot figure out how to strip at least classes with Display Suite extras module, it seem that it doesn't do anything, went though all settings.
Did Dries use any of known public modules or is it all custom code?
Comment: This is no junk, this is the HTML and CSS required and defined by the theme and modules you use. If you want a more minimal markup, you have to create your own theme with your own templates, but remember that modules like QuickEdit or Layout Builder require a specific markup structure based upon the markup of the `stable` core theme.
Comment: This would best be done with custom templates. A problem to look out for is some actions require those divs and wrappers, such as Ajax callbacks and quick actions. If you change the markup and get errors, that's something to look for.
Comment: @Hudri can you post this as an answer, please. Both comments useful.
Comment: Do not use Fences, Display suite etc. you do not need them.
Answer: A lot of those classes are added by the classy base theme templates. You'll be able to get rid of them with a theme based on stable instead.
Answer: This is no junk, this is the HTML and CSS (classes) required and defined by the theme and modules you use.
If you want a more minimal markup, you have to create your own theme with your own templates, but remember that modules like QuickEdit, Views or Layout Builder require a specific markup structure based upon the markup of the stable core theme.
Regarding dri.es: He seems to be using a custom, minimal theme and a very reduced setup with many modules disabled (e.g. QuickEdit will not work with his theme).

How to achieve clean HTML markup?


Jenkins pipeline resumes but nothing happens

Question: We have a Jenkins pipeline with several stages (pipeline as code). One of these stages creates ~40-50 downstream jobs and starts them in a parallel step.
Unfortunatelly our jenkins master reboots every night. After this reboot every job in the queue is lost and the currently running downstream jobs are stopped with an error.
After a reconnect of the child nodes the pipeline is in resume state (=> console output: resuming build) but nothing happens.
Now I have following questions:

What exactly happens when the pipeline tries to resume? Does the pipeline starts from stage 1 again?
Is it possible to requeue the downstream jobs that were in the queue before?
Comment: Have you added checkpoints to your build? Resume option will start from the checkpoint it failed.
Comment: Checkpoints plugin only seems to be available in the Cloudbees version not the open source version of Jenkins.
Answer: Just in each job that you use in the flow choose "don't not allow the pipeline to resume if the master restarts". In such matter this issue will not happen (with resume state).
<code>options {
  disableResume()
}
</code>
As solution to resuming - use some "queue" checker. For example:

for each build request create a unique named json/yaml file (config of build to launch) in some folder that you'r main job will check for file existence.
If you found such file - launch the main job (with configuration "not allow concurrent builds"). Make some timeout for the job
In the end of main job's launch - delete the file...

Or use some SQS queue if that is in AWS...


Como passar uma função como parâmetro em Action Script?

Question: Alguém sabe me dizer qual tipo de objeto permite eu fazer uma matriz  de valor e uma função parecida com o código abaixo e action script 3?
Se fosse em Java daria pra fazer alguma coisa tipo essa:
Minha Interface:
package test;

public interface MyInterface {

    public void alert();
}

E minha classe com a utilização da Interface:
package test;

import java.util.HashMap;
import java.util.Map;

public class MyClass {

    public static void main(String[] args) {
        Map<Integer, MyInterface> map = new HashMap<>();

        map.put(1, new MyInterface() {
            @Override
            public void alert() {
                System.out.println("valor 1");

            }
        });

        map.put(2, new MyInterface() {
            @Override
            public void alert() {
                System.out.println("valor 2");

            }
        });
    }

}

Comment: Não entendi. A função já existe na tal classe?
Comment: Existe.. eu queria passar qualquer função com argumento da minha matriz entendeu?

pode ser algo desse tipo também..
map.put(valor, alert("teste"));
Comment: Removi minha resposta porque a pergunta agora é outra. Não tinha sacado que era do Map de Java que você estava falando. Vou deixar pra alguém que manja mais Java responder...
Comment: Não cara se voce conhecer algum objeto que eu possa usar ou alguma outra forma, me ajuda ae @bfavaretto
Comment: Cara, meu Java não é dos melhores, e meu AS3 está bem enferrujado, não uso há anos. Mas fiz uma tentativa em uma nova resposta, veja aí se funciona.
Answer: Você pode tentar usar uma array em vez do HashMap, e objetos literais como valor:
var map = [];
map.push({
    alert: function() { trace("aaaaa") }
});
map.push({
    alert: function() { trace("bbbbb") }
});
map[0].alert(); // aaaaa
map[1].alert(); // bbbbb

Comment: beleza brother, vou testar aqui qualquer coisa eu te falo =D
Comment: Pensei em algumas alternativas, mas não achei uma melhor que essa, rsrs. Seu AS tá enferrujado não!