java.lang.NoClassDefFoundError: com.applovin.sdk.AppLovinSdk

Question: Hi I get the following exception: 06-10 10:53:36.643: E/AndroidRuntime(10415): java.lang.NoClassDefFoundError: com.applovin.sdk.AppLovinSdk I imported the external lib and also copy pasted the lib to /libs folder. but I still get this error. I imported the lib as : import com.applovin.sdk.AppLovinSdk; and the program falls at this line : AppLovinSdk.initializeSdk(this); . What am I missing?
lines before the error:
06-10 10:53:36.603: I/dalvikvm(10415): Could not find method com.applovin.sdk.AppLovinSdk.initializeSdk, referenced from method sk.wblade.psy.GalleryActivity.onCreate
06-10 10:53:36.603: W/dalvikvm(10415): VFY: unable to resolve static method 230: Lcom/applovin/sdk/AppLovinSdk;.initializeSdk (Landroid/content/Context;)V
06-10 10:53:36.603: D/dalvikvm(10415): VFY: replacing opcode 0x71 at 0x0003
06-10 10:53:36.613: I/dalvikvm(10415): Could not find method com.applovin.adview.AppLovinInterstitialAd.show, referenced from method sk.wblade.psy.GalleryActivity.onResume
06-10 10:53:36.613: W/dalvikvm(10415): VFY: unable to resolve static method 229: Lcom/applovin/adview/AppLovinInterstitialAd;.show (Landroid/app/Activity;)V
06-10 10:53:36.613: D/dalvikvm(10415): VFY: replacing opcode 0x71 at 0x0012
06-10 10:53:36.633: D/AndroidRuntime(10415): Shutting down VM
06-10 10:53:36.633: W/dalvikvm(10415): threadid=1: thread exiting with uncaught exception (group=0x40a9b228)

Comment: http://stackoverflow.com/questions/16636039/java-lang-classnotfoundexception-after-changing-nothing-in-the-project-but-upgra/16636127#16636127. try this if it helps
Comment: did you update your adt to rev 22?
Comment: 22.0.1 is my current version
Answer: project right click properties-> Java BuildPath select Library and add external .jar the follow these step.
Go to Project->Properties->Java Build Path than select Order and export tab. Set external .jar library checked and up it into top of the list. And clean and rebuild..It works for most of the cases
Answer: There is a bug in ADT 22. If you use this you have to check the Android Private Libraies in the Order and Export tab in Preferences/Java Build Path.
You can read about this in detail here:
Libraries do not get added to APK anymore after upgrade to ADT 22


accesing sqlite database using vb .net

Question: I am new to VB .net and working with SQLite.  I am not able to access Test1.db3, the code below simply creates a new file Test1.db3, therefore when I go to read the file I receive a response saying table 'Users' doesn't exist.  I am using VS Express 2013.
<code>Sub Main()

    Dim Path As String = "J:\Location\SQLITE\"
    Dim dataBase As String = "test1.db"
    Dim cs As String = Path & dataBase
    Dim myConnection As New SQLiteConnection()
    Dim cadeomSQL As String = "Data Source=" & cs & ";"

    myConnection.ConnectionString = cadeomSQL
    myConnection.Open()

    Dim sSQL As String = "SELECT * FROM Users"
    Using cmd As New SQLiteCommand(sSQL, myConnection)

        Dim rdr As SQLiteDataReader = cmd.ExecuteReader()

        Using rdr
            While (rdr.Read())
                Console.WriteLine(rdr.GetString(0) & rdr.GetString(1) & rdr.GetString(2))
            End While
        End Using
    End Using
    myConnection.Close()
End Sub
</code>
Any advice will be much appreciated
Comment: I dont see your schema where you create the users table in sqllite db. You need to create the table before accessing it
Comment: Thanks qamar, The database and table already exist within the test.db.  I am simply trying to get information from it.  Is this not possible?
Answer: Try this !
<code>  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim dataBase As String = "test1.db"
    Dim Path As String = $"J:\Location\SQLITE\{dataBase}"
    Dim cadeomSQL As String = $"Data Source={Path};Version=3;New=False;Compress=True;"
    Dim myConnection As New SQLiteConnection()

    myConnection.ConnectionString = cadeomSQL
    myConnection.Open()

    Dim sSQL As String = "SELECT * FROM Users"
    Using cmd As New SQLiteCommand(sSQL, myConnection)

        Dim rdr As SQLiteDataReader = cmd.ExecuteReader()

        Using rdr
            While (rdr.Read())
                Console.WriteLine($"{rdr.Item(0)} {rdr.Item(1)} {rdr.Item(2)} {vbNewLine}")
            End While
        End Using

    End Using
    myConnection.Close()
End Sub
</code>

accesing sqlite database using vb .net


Bass guitar - One finger per fret or not?

Question: I have seen a few questions about this on guitar, but none on bass.
When I started guitar, I instinctively used my four fingers to play stuff (five if you count the thumb for over-neck awesomeness) and that seems to be the correct technique.
I got into bass a few months ago and tried to have the same approach.It's quite a stretch (especially on lower frets) but over time it got somewhat manageable. However, I got a teacher who told me I should go about doing things like fifths and octaves with my pinky instead of my ring finger. Is he wrong? Or is it just a preference thing?
Answer: As a beginning bass player I've been working through Ed Friendland's Hal Leonard Bass Method, which starts out using just first, second, and fourth fingers spanning three frets.  He introduces one finger per fret (spanning four frets) as an advanced technique in volume two, and teaches that you should pivot between second and third fingers rather than stretching your fingers across all four.
I picked up this book partly to practice exactly this.  Previously I depended completely on one finger per fret.  My left wrist and hand have been feeling a lot of pressure, and cramping up sometimes when I play something repetitive close to the nut.  Working on the more relaxed technique seems to be helping.
More advice along the same lines:

,

Anyway, so my (limited) experiences agrees with advice I've seen in Friedland's book and elsewhere, and (it sounds like) with your teacher: for versatile technique that doesn't stress the left hand too much, most people probably need to learn both ways.
Answer: Well, I'll have to disagree with your teacher. Do aim at one finger per fret as a default!
The three-fret technique is essentially a variation of the standard way to finger notes on double bass, due to Franz Simandl. Double bass requires about five times as much force as electric bass (apart from having a considerably longer scale), so it's really tough to apply the 1-finger-per-"fret" principle. Some guys can actually pull this off and achieve marvellous results, but for most players it's just not practical to torture the ring finger and pinky with having to work on their own; the Simandl technique groups them both together to a single, more powerful unit.
This is completely different on electric bass. If you have difficulties pressing down the string with the ring finger or pinky alone, then there's either something wrong with you technique or the action of your bass is set too high. Indeed, it's very rare for players to actually use the pinky and ring finger together, rather they'll just skip the ring finger.
So, force isn't really the issue.
What's quite a different issue is the spread of the hand. It's a matter of fact that even on electric bass, the position where your index is on the first fret while your pinky fingers the fourth is extremely uncomfortable. Don't do that, ever! You don't need to. No matter where your hand is and which finger targets what fret, the hand should always be nicely loose and flexible. Don't spread out fingers while they aren't actually used; only keep them ready. While pressing the pinky, the whole hand may in fact be a good bit higher up the neck than when the index finger is playing. It's still nominally the same position, and the move of the entire hand within an inch won't slow you down.
It turns out many bassists, by being lazy and using three-finger technique, actually miss the goal of a relaxed hand. The three-finger technique, like the chord technique used by many guitarists, has a tendency to encourage a firm broomstick-grasp like grip. Actually this kind of technique can give good results (especially à la Hendrix – screaming bends and thumb auxiliary bass notes), but on bass it's most of all limiting. A more open hand is much better for melodic bass lines, not always just playing pentatonic scales or merely switching between fifths, and it gives a better basis for switching to other positions.
Answer: Like everything else in music, fingering is definitely a preference thing. There are some ways that are more economical than others, but it ultimately boils down to what is more comfortable for the player. In general, the one-finger-per-fret rule still applies for bass.
In a lot of music genres, bass players do a lot of roots, fifths and octaves. If you're looking for an economic fingering pattern, you'd probably end up with:

Index finger on root
Ring finger on fifth
Pinky on octave

It looks just like how an average guitar player fingers a power chord.
You'd also notice that your middle finger is free to be used on the fourth/seventh - this allows you to play hammer-on the fifth/octave in a bassline. Pretty common technique used in more songs than I know.
Once you get used to this fingering, I guess you'd naturally feel more comfortable with ring finger on the fifth, and pinky on the octave. Again - not a sacred rule, but just what makes sense economically.
Answer: I teach that there are essentially three fundamental fretspans to learn on a standardly-tuned bass guitar: three-frets, four-frets and five-frets.
Three-fret span is incredibly useful, as it limits your vocabulary in a way that gets you thinking in terms of very useful basslines.  It makes the root, fifth, and octave extremely playable in a way that is conducive to creating grooves.  It also allows for convenient neighbor tones for these, but forces you to focus on other aspects of the groove than the melody.
Four-fret span is useful to expand out of that cage into more technically-proficient lines.  However, when doing so, it is important not to lose site of the groove in the process.
Finally, five-fret spans are great as they encompass a full major third on each string.  If you master a five-fret span, on a four string bass every note within an perfect twelfth ascension from your lowest note will be accessible to you without shifting.  On a five string bass, this expands to every note within a two octave distance of that root accessible without shifting.  This opens up enormous melodic possibilities – but as with the four-fret span, has a tendency to shift the focus away from basic groove.
In practice, I use all of these at different times.  However, I recommend starting with becoming a master of the three-fret span.  This is not because it is simpler, but rather because it will focus you on playing fundamental lines of bass playing, and on learning to groove before learning to stretch melodically.
Answer: Dependent mostly on the length of fingers. One finger per fret works pretty well on guitar, but not so on bass. it is more noticeable on the bottom 4 or 5 frets (one of the reasons I prefer 5 string - no real need to play down there!). Playing scalar stuff, o.f.p.fret does actually work at the bottom, but for playing I, IV, V as you do a lot I might use index and ring/pinky. Your teacher isn't wrong, maybe he finds that best, but there's certainly nothing wrong with beefing up the pinky, which may otherwise stay as weak as it ever was. Bassically, whatever feels right for you will be good - provided you give other options the opportunity.
Answer: Since I have long fingers with good joint flexibility, I decided to adopt OFPF from the beginning when I learned bass. I am very careful about stretching and finger warmup  exercises before each practice session. I have experimented with optimum finger placement on the neck to minimize and distribute the strain as evenly as possible across all four fingers. For my first and fourth finger reaches I pivot on the thumb; I don't go for a long stretch on either end. This technique has served me very well as I learn and play the bass.
Answer: I played one finger per fret on fretted bass, but when I started to play fretless found playing octaves with first and fourth fingers made intonation easier - shrug


Can anyone tell me what's wrong with this htaccess code

Question: I am not able to get through with this code...I need to capture the request but with this code I am able to redirect but it cannot find the particular search page.
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /searcha\.php\?name=(www\.)?([^/\ ]+)[^\ ]*\ HTTP/
RewriteRule ^.*$ http://www.mydomain.com/%2? [R=301,L]

can any one tell me what is I am missing??
Comment: in your regex you have [A-Z]+... are sure you always have all caps for you directories?

Please give an example of what it should be finding.
Comment: @DBruns, since the condition is using `%{THE_REQUEST}`, the [A-Z]+ actually matches "GET" (or "POST", or whatever the request method was)
Answer: In your RewriteRule, you don't capture anything, but then you reference %2...?  RewriteRule won't operate on the captured data from the regex in RewriteCond.
Update: Actually, now that I'm reading your code more closely, it looks like you don't need the RewriteCond.  If you're just trying to rewrite one URL as another, you can do something like this:
RewriteRule ^searcha\.php\?name=(www\.)?([^/\ ]+)[^\ ]* http://www.mydomain.com/%2 [R=301,L]
(You might have to tweak that regex some more since I'm not sure what you're trying to match)
Comment: could you give some example??
Comment: ok I will explain I am going to launch an SEO site wich gives you lots of information on SEO by searching any URLS

so when on my search page when some one enter say www.google.com
then it should catch that URL to searcha.php where processing will happen and address line should rewrite to www.mydomain.com/www.google.com

this is what I am looking into
Comment: Do you intend searcha.php to do anything?  Because if you rewrite the URL, it will never actually get hit.  You might be better off redirecting in PHP by sending a "Location" header (see http://www.php.net/header).


Where do I find a good .NET library for synchronise files over FTP, HTTP and SMB

Question: I need a .NET library to synchronise files from a server to a client (one way).
Requirements:

Should be a .NET library
Needs to be deployed via ClickOnce (that is, no instalation, no COM etc.)
Needs to support HTTP and/or FTP and/or SMB
Open Source, Free or Commercial
Comment: I'm looking for a car that seats four, costs 2000 bucks, gets 100 miles/gallon and makes my insurance company stop raising their rates.  It's been a while, I'm considering settling for two of those right now.
Answer: Sync Framework will work for this.
Comment: It can be included in a .NET app as a dll reference and then deployed via click once.
Comment: Still it's an installation... right? http://www.microsoft.com/downloads/details.aspx?FamilyId=109DB36E-CDD0-4514-9FB5-B77D9CEA37F6&displaylang=en
Comment: Isn't that in your requirement that is needs to be deployed via ClickOnce? Maybe I'm missing the question here, but ClickOnce is just a windows install that handles the install process and subsequent updates.
Comment: You convinced me. I'm looking at it now. I was hoping that there would be a small assembly for my needs. An entire framework is a bit to overwhelming for my current needs.
Comment: Sync framework only supports SMB, neither HTTP or FTP. I know I was not clear on that one.


Is my sample homogeneous?

Question: I have a sample of 110 values between 0 and 180. These represent total degrees in an arc, and I want to be able to figure out whether or not I have a widely variable sample of arc sizes or if I have a more homogeneous sample. I have a mean of 93.65 degrees and a standard deviation of 22.8 degrees. Can I tell this from the standard deviation? It seems homogeneous to me, but I don't know how to justify or negate this.
Comment: (1) What do these values represent? Of particular importance is whether values of $x$ and $x+180$ would be considered the same for any $x$. (2) Exactly what do you mean by "homogeneous"?
Comment: The SD tells you something about how *spread* out the values are. Whether that contains any information about how "alike" they are depends on what you mean by "alike"! What do you mean?
Comment: Do you maybe want to test for uniformity? There are many tests for circular uniformity, which test whether or not it is reasonable to assume that the data is uniform across all angles. However, this requires, as @whuber suggests, that 179 degrees is very close to 1 degrees. However, you seem to suggest that the range is bounded, which would suggest that a linear test for uniformity in the range 0-180 would be appropriate, if this is what you mean by homogeneity.
Comment: 1) These values are areas described in terms of "total degrees", but they are limited. There can be no value lower than 0 and no value higher than 180, as the items being measured are arcs located in semi-circles.
2) By homogenous, I mean, does the standard deviation shed any light on how alike, or unalike, the values are?
Answer: Putting aside any potentially important issues relating to the suitability of means and standard deviations when your data are angles for a moment, let's address the more general issue -- standard deviation really isn't a measure of homogeneity.
It's quite possible to have two variables, one which might be regarded as homogeneous-but-somewhat-noisy and a second which clearly isn't homogeneous ... yet the second may well have a smaller standard deviation than the first.
In the diagram below, the data from which the green density was computed has a (slightly) smaller standard deviation than the more homogeneous-looking one marked in black.

Unless you can give a precise definition of what you mean by homogeneous, from which a suitable measure of homogeneity might be devised (and perhaps even then), the degree to which your data are "homogeneous" might be better assessed by a display, such as a kernel density estimate (or perhaps by a histogram with a moderately large number of bins).

Is my sample homogeneous?


Showing topological spaces are homeomorphic (quotient spaces)

Question: What is a correct strategy for tackling homeomorphism problems between spaces? I have been trying to prove many problems that topological spaces are homeomorphic and I always follow the same strategy. However the strategy I use feels different to others. Here is one example of a problem I came across, similar to the ones I have been doing.
Consider the topological space $Y$ obtained from the closed unit interval $[0,1]$ by identifying $0$ and $1$. In other words $Y=[0,1]/ \sim$ Where the equivalence classes of $\sim$ are singletons $\{s\}$ for $ 0<s<1$ and the set $\{0,1\}$. Consider the map $f(t)=e^{2\pi it},0 \leq t \leq 1$. The equivalence classes are precisely the level sets of $f$. $f$ induces a homeomorphism of $Y$ and $S^1$.
Now I will show my approach. Before this I will ask what does it mean that "$f$ induces a homeomorphism of $Y$ and $S^1$? I constantly see a phrase like this and do not know what it means. I ignore this and define a homeomorphism between the quotient space of $g:[0,1] \rightarrow Y$.
So here is my approach: I first define the set of equivalence classes. Let $Y=\{\{x\}|0<x<1\} \cup \{0,1\}$. Which is the union of the equivalence classes under the relation $\sim$. Now I define a homeomorphism $f:Y \rightarrow S^1$ given by $f(\{0,1\})=(1,0)$ and $f(\{x\})=(\cos 2\pi x,\sin2\pi x)$. Then $f$ is injective and surjective. Also $f$ is a bijection from a compact space $Y$ to a Hausdorff space $S^1$. Therefore it suffices to show $f$ is continuous, to show it is a homeomorphism. Now consider the quotient map $f \circ g$ which is what I believe is the "induced map". I would appreciate it someone would explain the "induced map" concept to me. $f$ is continuous if and only if $f \circ g$ is continuous, by a theorem. Now $f \circ g$ is continuous because the component functions in $(\cos 2\pi x,\sin2\pi x),(1,0)$ are continuous. Thus $f$ is a homeomorphism.
So this is my approach to do these problems, but everytime I do a problem like this I get confused because when I look at the way other people do similar problems, they do it completely differently. To me it feels awkward defining a map on the sets that are equivalence classes, the members of $Y$. I never see anyone else do it like this. So what is a better strategy?
Edit: One of the users has said that this approach I have taken is incorrect. I am unsure what to do here and how to remedy this. Here is the comment that makes me concerned and leads me to believe I have been doing these homeomorphism problems incorrectly.
"Finally, your method introduces a third space, the real unit circle, that we must show is homeomorphic to the other two.  This choice is not actually improving the situation, since now we need to prove that at least two (composite) maps are homeomorphisms."
Does this mean my approaches for this problem Show torus homeomorphic to $S^1 \times S^1$ and this problem Real projective plane isomorphic to quotient space of sphere were incorrect after all?
Comment: $f$ induces a homeomorphism just means that $f$ is defined on a domain slightly different than the spaces one is trying to show are homeomorphic (in your example, $f$ is defined on $[0,1]$, rather than $[0,1]/0\sim 1$), but that $f$ is well defined on the domain space (in this case, $[0,1]/0\sim1$) and that the restriction of $f$ to that domain space is a homeomorphism with its image.
Comment: People use whatever is simplest to them. It's really as simple as that. If induced homeomorphisms are simplest for you, use them! Otherwise, don't. It's fine either way.
Comment: For a general approach, there is none! That's the fun of math! There are a lot of techniques that apply in different situations. But I have to emphasize, do not let perfect be the enemy of good. I much prefer a solution that just constructs a homeomorphism from scratch and proves all of the desired properties than a cutesy solution ripped off the internet. The first builds character in a way the second can never.
Comment: @DonThousand thanks for the comment. Do most people use this "induced map" to define their homeomorphisms rather than my strategy which defines the map on eqiuvalence classes? Is there any reason doing so would be more beneficial for solving the problem? Also do you think my strategy is ok defining the homeomorphism explicitly on equivalence classes?
Comment: @DonThousand Do you know if the induced map is sometimes called "identification map"?
Comment: No, that's different.
Answer: First, you are expected to know that the image of $f(x) = \mathrm{e}^{2\pi \mathrm{i} t}$ with domain $t \in [0,1]$ is a circle, with the only failure of injectivity at $0$ and $1$.
This is a function from $[0,1]$ to a the complex unit circle.  $Y$ is a quotient of $[0,1]$ producing a circle.  $f$ is not given as a bicontinuous bijection between the unit complex circle and the abstract quotient circle.  However, with the definition of $Y$ it completely specifies the construction of one.  (That is, it "induces" one.  Another way to translate "induces" is "this is not the thing we formally require, but, except for details that should be obvious to one working in this area, contains all the 'interesting work' done by such a thing").
To complete $f$ to a homeomorphism, we need a map from $Y$ to the complex unit circle, $S^1$, or we need a map from $S^1$ to the complex unit circle.  In either case, that map should be (1) well-defined, (2) bijective, and (3) bicontinuous.
If we construct $g : Y \rightarrow (0,1) \cup \{0,1\}$, then $f \circ g : Y \rightarrow S^1$ is the induced map that we are to show is a homeomorphism.  Notice that this is only well defined if $f(0) = f(1)$, i.e., the composition is well-defined.  Then we show it's bijective, then that it's continuous.
If we instead construct $h : (0,1) \cup \{0,1\} \rightarrow Y$, then $h \circ f^{-1} : S^1 \rightarrow Y$ is the induced map that we are to show is a homeomorphism.  Notice that the domain of $h$ must be chosen so that $f^{-1}$ can be injective; to be well-defined, we again require $f(0) = f(1)$.
However, very few people write this formally.  As my translations of "induce" indicate -- the omitted details are the details that anyone who is ready to work with this material should be able to fill in without great effort.  It is a good thing to practice enough to notice that the quotient is introducing an obstruction to well-definedness (in one direction) and bijectivity (in the other direction).
Finally, your method introduces a third space, the real unit circle, that we must show is homeomorphic to the other two.  This choice is not actually improving the situation, since now we need to prove that at least two (composite) maps are homeomorphisms.
Comment: In the problem on this page:  Paragraph 2: the spaces $Y$ (quotient of unit interval) and $f([0,1]) = S^1$ (complex unit circle) are defined.  Paragraph 4: $f$ is redefined to have image the real unit circle -- there are now two $f$s with incompatible images.  While it is sometimes helpful to show two spaces are homeomorphic by passing through a third space (which is, for some reason, easier to get to and from), this is not the case here.  Regardless, you do not get to use the symbol $f$ in your proof except in the way it is already given -- from $[0,1]$ to the complex unit circle.
Comment: @ernesto : A difficulty with https://math.stackexchange.com/questions/4125054/show-torus-homeomorphic-to-s1-times-s1 is that $g$ is used without definition.  Here, on this page, $S^1$ has been defined as the complex unit circle.  If this is the definition you are using, you should be finding a map $\Bbb{T}^2  \rightarrow \Bbb{C}^2: (x,y) \mapsto \left( \mathrm{e}^{2\pi\mathrm{i} x},\mathrm{e}^{2\pi\mathrm{i} y} \right)$.  Your $f$ on that page is a map to $\Bbb{R}^2 \times \Bbb{R}^2$, which requires applying the problem on this page to finish going to $\Bbb{C}^2$.
Comment: Hi eric thanks for the help. I was wondering if you could explain why my solution in this link is correct  https://math.stackexchange.com/questions/4125054/show-torus-homeomorphic-to-s1-times-s1 but my attempt at this problem is wrong. This makes me worried that I have been doing these problems incorrectly all along.
Comment: Would have it been correct if I defined the homeomorphism as $f(\{x\})=e^{2 \pi i x}$ and $f(\{0,1\})=1$ instead?
Comment: Hi eric, I was wondering if my choice of map would go through if we consider $S^1$ to be a subspace of $\mathbb{R}^2$ instead of the complex plane? Thanks


OpenWrt allow IPv6 rule to access a server with global IPv6 on local area

Question: First of all, I have a domain with dns configured to point to my device global address witch is set to static with my ISP gloabl prefix as xxxx:xxxx:xxxx:de01::3/64 in dhcpcd.conf.
I'm using Openwrt router as my main router plugged in my ISP ONT. I have internet connection in IPv4 and IPv6 working: I can ping or ping6 to internet.
From OpenWRT, my ISP give me a Prefix Delegated xxxx:xxxx:xxxx:de00/56.
When I replace the OpenWRT router by my ISP router, my ISP (or itself, I don't know) give to it the address xxxx:xxxx:xxxx:de01::1/64.
With the ISP router my server is reachable at address xxxx:xxxx:xxxx:de01::3 from the internet (my mobile phone in 4G) when I allow trafic from the firewall, but since I see /56 prefix from my ISP, I'm a little bit confused.
I try to put IPv6 assignment length to 64 and IPv6 assignment hint to 1 on lan interface, and now my OpenWRT router has the same address that my ISP give to the original router (xxxx:xxxx:xxxx:de01::1/64 on LAN1).
So I try to configure a Trafic rule from WAN 443 to LAN xxxx:xxxx:xxxx:de01::3 443 on the Firewall, but my server stay unreachable from my mobile phone.
I'm probably missing something because I'm new to IPv6, and can't understand what's happening since I test a lot of configuration without to acheive what I want.
I someone can't help me to understand deeply what's going on?
This is my config (OpenWRT 19.07):
network:
config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fda0:71fe:ea0f::/48'

config interface 'lan'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ifname 'lan1'
        option ip6class 'wan6'
        option ip6assign '64'
        option ip6hint '1'

config interface 'wan'
        option ifname 'lan0'
        option proto 'dhcp'
        option vendorid 'neufbox_NB6V-MAIN-bypassed'

config interface 'wan6'
        option ifname 'lan0'
        option proto 'dhcpv6'
        option reqprefix 'auto'
        option reqaddress 'try'

firewall:
config defaults
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'REJECT'
        option synflood_protect '1'

config zone
        option name 'lan'
        list network 'lan'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'ACCEPT'

config zone
        option name 'wan'
        list network 'wan'
        list network 'wan6'
        option output 'ACCEPT'
        option mtu_fix '1'
        option input 'REJECT'
        option forward 'REJECT'
        option masq '1'

config forwarding
        option src 'lan'
        option dest 'wan'
config rule
        option name 'Allow-DHCP-Renew'
        option src 'wan'
        option proto 'udp'
        option dest_port '68'
        option target 'ACCEPT'
        option family 'ipv4'

config rule
        option name 'Allow-Ping'
        option src 'wan'
        option proto 'icmp'
        option icmp_type 'echo-request'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-IGMP'
        option src 'wan'
        option proto 'igmp'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-DHCPv6'
        option src 'wan'
        option proto 'udp'
        option src_ip 'fc00::/6'
        option dest_ip 'fc00::/6'
        option dest_port '546'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-MLD'
        option src 'wan'
        option proto 'icmp'
        option src_ip 'fe80::/10'
        list icmp_type '130/0'
        list icmp_type '131/0'
        list icmp_type '132/0'
        list icmp_type '143/0'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Input'
        option src 'wan'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        list icmp_type 'router-solicitation'
        list icmp_type 'neighbour-solicitation'
        list icmp_type 'router-advertisement'
        list icmp_type 'neighbour-advertisement'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Forward'
        option src 'wan'
        option dest '*'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-IPSec-ESP'
        option src 'wan'
        option dest 'lan'
        option proto 'esp'
        option target 'ACCEPT'

config rule
        option name 'Allow-ISAKMP'
        option src 'wan'
        option dest 'lan'
        option dest_port '500'
        option proto 'udp'
       option target 'ACCEPT'

config rule
        option name 'Support-UDP-Traceroute'
        option src 'wan'
        option dest_port '33434:33689'
        option proto 'udp'
        option family 'ipv4'
        option target 'REJECT'
        option enabled '0'

config include
        option path '/etc/firewall.user'

config rule
        option name 'server_80'
        list proto 'tcp'
        option src 'wan'
        option src_port '80'
        option dest 'lan'
        option dest_port '80'
        option target 'ACCEPT'
        list dest_ip 'xxxx:xxxx:xxxx:de01::3'
        option family 'ipv6'

config rule
        option name 'Server_443'
        list proto 'tcp'
        option src 'wan'
        option src_port '443'
        option dest 'lan'
        option dest_port '443'
        option target 'ACCEPT'
        list dest_ip 'xxxx:xxxx:xxxx:de01::3'
        option family 'ipv6'

Comment: Could you plese edit your question? It is hard to decode the setup when all ip-adresses is substituted with x'es. Use the subnet range `2001:db8::/32` instead. That range is dedicated to documentation like proof of concept.
Comment: The firewall rules look OK. Can you access IPv6 sites from this server?
Comment: Also, if the ISP is giving you a `/56`, you should set up IPv6 Prefix Delegation to break it into `/64` networks for use in your network. That will give you 256 `/64` networks.
Comment: @MichaelHampton thanks for your awnser. I see I have to forward Wan to Lan, it works but this way it's opening the firewall to all my IPv6 local device with Global address, so I try to restrict all trafic in traffic rules and then open 443 to my global ipv6 device. But unfortunatly all traffic from wan to my device stay blocked.
Answer: So, I make it work by adding custom rules in firewall.user.
To open a specific port on specific Lan device with Global IPv6 I do:
ip6tables -t filter -I FORWARD 1 -p tcp --dport 443 -d xxxx:xxxx:xxxx:de01::3 -j ACCEPT


Proving associative property, floor function

Question: I need to prove the following operation is associative:
$x*y = xy \pmod 5$
I came up with the equation that $x*y=xy-5[\![xy/5]\!]$
I'm having difficulty proving that $x*(yz)=(xy)*z$. After expanding and then trying to simplify, I have that $x*(yz)=xyz-5z[\![xy/5]\!]$ and $(x*y)*z=xyz-5x[\![yz/x]\!]$ , but cannot then show that the two are equal.
Comment: Are you familiar with modular arithmetic?
Comment: not so much unfortunately
Comment: I figured, because the question basically reads "show that multiplication modulo $5$ is associative", which is almost a direct consequence of regular multiplication being associative, no floor function needed.
Comment: Just so you know, the remainder of $a$ divided by $b$ is $a \pmod b$.
Answer: Try to build up $(x*y)*z$ and $x*(y*z)$ in small steps:
From your description we have $xy = 5a + (x*y)$ and $yz = 5b + (y*z)$
for suitable integers $a$ and $b$ (these were the values of the
$\mathrm{floor}$ function but that is not really important here).
When you calculate
$$(x*y)z = (xy - 5a)z$$
and
$$x(y*z) = x(yz - 5b)$$
you will find that both have the same remainder $\mod 5$.
Answer: Here's a different way of looking at this problem. By the Division Theorem, we can state any number $x$ as $5q+r$ where $q \in \mathbb{Z}$ and $0<r<5$. Here, $r$ is the remainder of dividing $x$ by $5$. We'll say that if $x=5q+r$, then $x \equiv r \pmod 5$.
Thus, $x*y \equiv xy \pmod 5$. We want to show that $x*(y*z)=(x*y)*z$. The key to doing this is letting $x=5q_x+r_x$, $y=5q_y+r_y$, and $z=5q_z+r_z$. This means the following:
$$xy=(5q_x+r_x)(5q_y+r_y)=25q_xq_y+5q_xr_y+5q_yr_x+r_xr_y=5(5q_xq_y+q_xr_y+q_yr_x)+r_xr_y$$
$$yz=(5q_y+r_y)(5q_z+r_z)=25q_yq_z+5q_yr_z+5q_zr_y+r_yr_z=5(5q_yq_z+q_yr_z+q_zr_y)+r_yr_z$$
Thus, $xy \equiv r_xr_y \pmod 5$, meaning $x*y=r_xr_y$, and $yz \equiv r_yr_z \pmod 5$, meaning $y*z=r_yr_z$. We can know multiply the former by $z$ and the latter by $x$ to find that this operation is associative.
$$x(y*z)=(5q_x+r_x)r_yr_z=5(q_xr_yr_z)+r_xr_yr_z$$
$$(x*y)z=r_xr_y(5q_z+r_z)=5(r_xr_yq_z)+r_xr_yr_z$$
Thus, as you can see, $x(y*z) \equiv (x*y)z \equiv r_xr_yr_z \pmod 5$. This means $x*(y*z)=(x*y)*z=r_xr_yr_z$, which proves associativity as we wanted to.
For more on modular arithmetic, I highly recommend Khan Academy. It's where I learned modular arithmetic and it's really helpful later on, especially in abstract algebra because cyclic groups have a lot to do with modular arithmetic.


How to localize your own contrib module

Question: Things have changed since I last localized a Drupal contrib module of mine. In D9/10, having a translations folder with .po files no longer seems to be the usual route. Yes, it can be done for local custom modules by specifying the location in the info.yml but I'm looking for a solution for regular, d.o hosted contrib modules. Right now I don't even need many languages, just one, the (Commerce) module in question applies to a single country, so the translation should obviously come directly for anybody installing the module.
I'm aware of this question but it's unanswered.
Answer: With some perseverance, I succeeded. The required steps are partly as described in the linked other question, have your .po files in a translations folder inside your module. But instead of adding the fixed path to the info.yml file, use the following hook in your .module:
function MODULE_locale_translation_projects_alter(&$projects) {
  $folder = \Drupal::service('extension.list.module')->getPath('MODULE');
  $projects['MODULE'] = [
    'info' => [
      'interface translation server pattern' => $folder . '/translations/%language.po',
    ],
  ];
}

You may use a different naming scheme for the files, I decided the language code was enough for me.
This way, it will be loaded from the actual folder, no matter whether it's in custom or not.

How to localize your own contrib module


How to replace movie clip in flash animation via actionscript code

Question: For example, I've created in Flash CS a movie clip CampfireMC, which contains child movie clip:
m_fire:FireMC

FireMC is an animation of flame
CampfireMC controls playback of m_fire, for example, last frame of CampfireMC uses action code:
m_fire.gotoAndStop(m_fire.totalFrames)

And the question is how to replace (not delete/add, as m_fire.gotoAndStop(m_fire.totalFrames) will not work in this case) FireMC to another animation FireMC2?
I've tried the following trick, but it doesn't work
var campfire:CampfireMC = new CampfireMC();
campfire.m_fire = new FireMC2();
campfire.gotoAndPlay(0)

Answer: not sure if the concept of "replacing" actually exists in Actionscript. changing the reference of m_fire would actually delete the previous reference and add a new one. this is what you do when you assign a new FireMC2 object to the m_fire variable, you delete the previous FireMC instance and add a new FireMC2 object.
the description of your problem seems to suggest that FireMC2 shares some functionality with FireMC , also I wonder if you shouldn't tackle the problem differently. instead of trying to replace one with the other , isn't it possible to encapsulate the extra functionality in a new MovieClip or even a new FireMC method and either add the new MovieClip or call the method , instead of trying to replace FireMC


Up and bottom keys block

Question: I have one Jscript that uses up and down keys but when user click up or down page is scrolling but how to block scroll when user click up or down?
Answer: Use
<code>return false;
</code>
At the end of the event handler.  See this quirksmode.org article for more information.

Up and bottom keys block


Bitwise Operations: Collapsing two values into one.

Question: Alright, so I'm having a hard time thinking of a way to do this. Perhaps someone here can help!
Here is the problem: I need to figure out a way to use bitwise operations (or any sort of equation) to turn a single number into an x and y that represents an offset spiraling 0,0 (see image).
Related image:

So $f(n) = x$ and $g(n) = y$, for example, would yield something like $f(25) = -2$ and $g(4)= 1$.
I need a way to store those two values within a byte, either through bitwise operations (much like how RGB values are stored and retrieved within an integer) or through some other mathematical equation.
If the numbers need to be repositioned or something, that is fine too.
Any help to point me in the right direction?
Comment: The square (-3,-3) actually has a value of 48, not 49. That tripped me up for a fair bit of time...
Comment: If I understand correctly, you are considering a [pairing operation](http://en.wikipedia.org/wiki/Pairing_function) that combines two signed integers into one unsigned integer (the correspondence $(x,y)\mapsto n$) in the manner suggested by the illustration, and you are looking for explicit formulas for the pairing operation and the projections back $n\mapsto x$ and $n\mapsto y$. The reference to bitwise operations seems spurious; one could use them if convenient but not necessarily. The "diagonal" values $(0,8,24,48,80,\ldots)=(4(n^2+n))_{n\in\mathbf N}$ suggest they are of limited utility.
Comment: @El'endia Starman -- Woops! Yep, you're right, my bad. Fixed!
Comment: @Marc van Leeuwen - Interesting about the diagonals. I devised a way to collapse the values using bitwise operators (two nibbles with a min/max of -7/7 each, collapsed into a single byte). However, the mathematical approach is far more interesting.
Answer: KK so each x,y intercept increase/decrease has a difference of 8.
A x+ and a y+ or a x- and a y- has a difference of 2 Where X would be a greater value.
A x+ and a y- or a x- and a y+ has a difference of 2 Where Y would be a greater value.
Realized Just now...
On the Y+ difference Scale
1 - 0 = 1
10 - 1 = 9
27 - 10 = 17
52 - 27 = 25
And so on.. (Difference of 8 Like I said before)
Now on the X+ difference Scale
3 - 0 = 3
14 - 3 = 11
33 - 14 = 19
60 - 33 = 27
And So on...(Dif of 8)
Now... These are the x+ and the y+ intercept values..
If I want to combine these values like so..
X...Y...Diff ..Actually means
3 , 1 = 2.......1x and 1y
11, 9 = 12.....2x and 2y
19, 17 = 30...3x and 3y
27, 25 = 56..4x and 4y


How to add a theme suggestion to the textfield input based on the name of the view?

Question: I am using the following hook in a custom module:
MY_MODULE_theme_suggestions_input_alter(&$suggestions, array $variables) {

  $suggestions[] = 'input_'. $element['#type']. '__'. 'form_id__' $element ['#form_id']. '__'. $element['#name'];
}

With which I get something similar (In my case I have an exposed filter using search api):
input-textfield-form-id-views-exposed-form-search-api-fulltext.html.twig

How can I get the suggestion in the following way?
input-textfiel--viewName--search-api-fulltext.html.twig

Where viewName is the name of the view from which the field is exported.
How can I access the view information from this hook?
Answer: If the View is displayed as a page, you can get the View ID from the current route parameters:
$view_id = \Drupal::routeMatch()->getParameter('view_id');
if ($view_id) {
  $suggestions[] = 'input_'. $element['#type']. '__'. $view_id . '__'. $element['#name'];
}

If it's a block, I can't think of a nice way to do it generically. One non-nice way would be to alter the form, and add a property to each element which can then be picked up in the suggestions hook.
Something like this:
function MODULE_form_views_exposed_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  // You could check that the current display is a block here too if you need to
  $view_id = $form_state->getStorage()['view']->id();
  _MODULE_add_view_id_to_input_elements($form, $view_id);
}

function _MODULE_add_view_id_to_input_elements(array &$root_element, $view_id) {
  $input_types = ['textfield', 'submit', '...'];

  if (in_array($root_element['#type'], $input_types)) {
    $root_element['#MODULE_view_id'] = $view_id;
  }

  foreach (\Drupal\Core\Render\Element::children($root_element) as $key) {
    _MODULE_add_view_id_to_input_elements($root_element[$key], $view_id);
  }
}

And then in the suggestions hook:
if (isset($element['#MODULE_view_id'])) {
  $suggestions[] = 'input_'. $element['#type'] . '__' . $element['#MODULE_view_id'] . '__'. $element['#name'];
}

This isn't particularly pleasant, but the exposed form elements themselves don't carry any context so you have to wedge it in there somehow I guess. Hopefully there's a cleaner method out there somewhere.
Comment: what is that $element ? it is undefined in MY_MODULE_theme_suggestions_input_alter
Answer: Thanks to Clive answer, this would be rather :
function MYMODULE_theme_suggestions_input_alter(&$suggestions, array $variables) {
  $view_id = \Drupal::routeMatch()->getParameter('view_id');
  if ($view_id) {
    $suggestions[] = 'input_'. $variables['element']['#type']. '__'. $view_id . '__'. $variables['element']['#name'];
  }
}

Comment: in my case , the suggestion is added on twig debug, but the template is not taken


Firebase Functions returns error "Error: Unexpected end of form at Multipart._final"

Question: I started using Firebase Functions and ran into a problem. Namely, when I created my API (running locally), deployed to Firebase Functions using firebase deploy --only functions and called from my frontend - in the function logs an error is displayed:

Error: Unexpected end of form
at Multipart._final (/workspace/node_modules/busboy/lib/types/multipart.js:588:17)
at callFinal (node:internal/streams/writable:696:27)
at prefinish (node:internal/streams/writable:725:7)
at finishMaybe (node:internal/streams/writable:735:5)
at Multipart.Writable.end (node:internal/streams/writable:633:5)
at onend (node:internal/streams/readable:693:10)
at processTicksAndRejections (node:internal/process/task_queues:78:11)

My goal is to receive the file in the API and process it using the easy-template-x bibiotech. When I used multer for this, the problem was the same
index.js
const functions = require('firebase-functions');
const routes = require('./src/routes/routes');
const express = require('express');
const cors = require('cors');
const app = express();
app.use(cors());
app.use(express.json());

app.use('/', routes);

app.listen(3009, () => {
    console.log('Listening on 3001...');
});

exports.app = functions.https.onRequest(app);

routes.js
const checkErrors = require('../controllers/checkErrors');
const express = require('express');
const router = express.Router();

router.post('/checkErrors', checkErrors);
module.exports = router;

And checkErrors.js
const {TemplateHandler} = require('easy-template-x');
const handler = new TemplateHandler();
const busboy = require('busboy');

const checkErrors = async (req, res) => {
    const bb = busboy({headers: req.headers});
    let templateBuffer = null;
    let jsonData = '';

    bb.on('file', (fieldname, file, filename, encoding, mimetype) => {
        file.on('data', (data) => {
            templateBuffer = data;
        });
    });

    bb.on('field', (fieldname, val) => {
        jsonData += val;
    });

    bb.on('finish', async () => {
        jsonData = JSON.parse(jsonData);
        console.log(jsonData);
        const templateTags = await handler.parseTags(templateBuffer);
        const templateTagsNames = templateTags.map(({name}) => name);

        //Znajdź brakujące wartości w Excel i je zidentyfikuj
        const missingValues = [];
        jsonData
            .filter((row) => {
                return !templateTagsNames.every((name) => Object.keys(row).includes(name));
            })
            .forEach((row) => {
                templateTagsNames.forEach((templateName) => {
                    if (!row.hasOwnProperty(templateName)) {
                        missingValues.push({fieldName: templateName, rowNum: row.rowNum + 1});
                    }
                });
            });

        res.json({
            errors: missingValues,
        });
    });

    return req.pipe(bb);
};

module.exports = checkErrors;

Comment: What version you're using of busboy?
Comment: I'm using the ^1.6.0 version
Comment: Can you try to downgrade to v1.4.3. There's a known issue on 1.6.0 version > see this [link](https://github.com/expressjs/multer/issues/1144) for reference
Comment: I could not find v.1.4.3, so I installed v1.4.0 and the problem did not go away. Is there any way to upload a .docx file as a string and then convert it to Buffer on the server? Maybe this will allow me to bypass FormData
Comment: The error message suggests that the file being uploaded is not being parsed correctly by the `busboy` library. This could be due to the file being corrupted or incomplete, or an issue with the headers being sent with the request. To troubleshoot the issue, you can try checking the file, verifying the headers, using a different library for parsing the multipart form data, or enabling debug logs for `busboy`.
Answer: I ran into this issue today for several hours and tried just about everything to fix it. It seems there have been some breaking changes in Google Cloud / Firebase Functions which prevent express middleware from handling raw multipart data like it should. I found a different module which is able to handle this correctly.
Use express-multipart-file-parser in your project instead of BusBoy. Here is an example:
const fileParser = require('express-multipart-file-parser')
const bodyParser = require('body-parser');
const { Readable } = require('stream');
const admin = require("firebase-admin");

const express = require('express');
const app = express();

app.use(fileParser);
app.use(cors({ origin: true }));
app.use(bodyParser.urlencoded({ extended: true }));

app.post('/upload/', (req, res) => {
    const storage = admin.storage().bucket();

    const file = req.files[0];
    console.log(file); // you can see the file fields here, lots of good info from the parser

    // convert the file buffer to a filestream
    const fileStream = Readable.from(file.buffer);

    // upload to firebase storage
    const fileUpload = storage.file("/test/"+file.originalname);

    // create writestream with the contentType of the incoming file
    const writeStream = fileUpload.createWriteStream({
        metadata: {
            contentType: file.mimetype
        }
    });

    // pipe the filestream to be written to storage
    fileStream.pipe(writeStream)
      .on('error', (error) => {
        console.error('Error:', error);
      })
      .on('finish', () => {
          console.log('File upload complete');
      });
});

I was really glad to finally come up with my own solution to this, as I couldn't find one anywhere on the internet as this seems like a recent change/issue with Firebase Functions. I hope this helps someone.
Don't forget to set up proper response codes, as this is just a demo solution. Also, don't trust the incoming original filename as it could be crafted maliciously.
Answer: I think the answer to this is posted here:
Firebase Cloud Function: "Unexpected end of form" error with multipart/form-data


Pick weight - functional difference, or just personal preference?

Question: I'm at the very beginning of learning to play guitar, and I recently needed to buy some more picks. This was more complex than I was expecting, since there are apparently many different weights of picks available.
I've gotten the impression that people generally categorize picks into three types: thin (or light), medium, and thick (or heavy). However, sometimes they're classified by a specific thickness (0.60mm, etc). As an aside, is there a particular thickness threshold for each of these types?
I ended up buying a few picks of different thicknesses, just to see what I liked, but I'm curious if there's a particular reason to use a certain type. Do the different picks produce audibly different sounds, or are they useful for different styles of playing for some reason? Or is it just something that comes down to a personal preference for which feel you like?
Comment: You left out Jazz picks which can be up to 3.0 mm thick, then tapered.
Comment: Another thing to experiment with: the shape of the tip. You can cut or file the tips (I like 'em pointy) to change the feel and the sound (sharper angles have more "edge").
Comment: Shape is important, as luser droog said. I like less pointy though. I'm a fan of very round picks.
Answer: You are right that picks are generally thin, medium, heavy. Some picks are by mm, but it's really just a different measurement of the same thing. Some manufacturers will add super / extra thin or heavy.
You do get a different sound with different picks. There is a maximum amount of force you can apply with a pick, given it's thickness. This will affect the tone you are generating.
I think that heavier picks have a strong advantage, as you can make them "softer" by not gripping them as tightly. They get more "give" although, it's really in your fingers, the effect is the same. You cannot make a thin pick stronger though. When I was learning, I liked thin picks though as they were easier to play fast with. However, technique solves that problem.
It is largely personal though. I suggest you try a couple out and see what works for you.
Comment: You can make a thin pick stronger: By bending it perpendicular to the strum direction (i.e. around your thumb/finger).  I find when I try to soften my grip on the thicker picks I end up shaking my guitar over my head trying to get it back out of the body, which really breaks up the song.  Your technique solution sounds interesting.  I may have to give that a try some day...
Comment: @Kendrick, that's interesting. I had never thought of that. I'll have to give that a go. In order to stop losing your picks, try an electric guitar! ;o) Really though, it's all in the technique. With some practice, you'll find you don't lose it so much.
Comment: +1 Kendrick, I've just realised that's what I often do with medium picks (curling them so they go stiff). Also some electric guitars have f-holes and they are even worse for retrieving small objects from. :)
Answer: They definitely produce different sounds.  A harder pick will give you a harsher sound, and a softer pick will give you a more mellow sound.
It's generally easier to play softly or slowly with a soft pick, because it will bend and allow you to move smoothly across the strings.  Likewise a hard pick allows you to play more loudly because less energy will be absorbed by the pick bending.
Beyond the rigidity of the pick, there's also its thickness.  Again, the thicker the pick the louder you can play, and it's easier to play softly with a thin pick.  I find the thickness is much more about your personal preference than the sound, however; the material controls the sound more.
I prefer a medium-weight, fairly elastic pick for most of my playing.
Answer: Generally, for lead playing, people use 0.7 - 1mm picks.  If the picks flex too much, it's harder to play faster picking runs.
If you're an acoustic player who strums a lot, you might go with a light to medium thickness.
I personally only ever use heavy picks, around the 1mm mark.
Answer: This answer has already been comprehensively answered, and I would like to say that, for me at least, it is down to a degree of preference, and the way you want to play will reflect in your preference. I like jangly warm sounds, hence I go for very light picks.
May I also note that if you are beginning to play a twelve string, then it is easier (because it is easier to move between strings), and makes a brighter sound using a lighter pick.
Hope this helps.
Answer:
This is not only about thickness of pick. Generally thick, will produce louder more accented sound, softer will be more mellow and easier for strumming across the strings.
But this also relation between pick thickness and You strings gauge. Thicker strings need thicker picks to produce decent sound.
As mentioned before direction is also important perpendicular or parallel to strings
Picks comes in different shapes too. Oval endings vs. pointed endings
Moreover i have noticed that material used affects tone - but i cannot give any general rules here (different kinds of plastic and it's finish, different materials - bone, wood)

I myself use:

1.14 plastic pick with oval endings parallel on .12 gauge strings for jazz (semi-hollow guitar)
0.9 plastic pick with pointed ending perpendicular on .11 gauge strings for rock/blues (i.e. pointed ending for me is must have for artificial harmonics)
sometimes 0.6 oval plastic pick for nylon stringed guitar (but most of time i play with my fingernails)

Generally i experiment with picks and this is my advice to You. Pick is important part of producing Your sound - so take some experimentations and have fun :)
Answer: I once saw a guy in Acoustic Guitar suggest that beginners all start with medium strings and medium picks, saying that they shouldn't bother to move to heavy or lighter strings or picks until you can explain why you need to go that way.
I like a 1mm ultex pick (Dunlop or Clayton) because I like the feel of them and, especially on acoustic, they bring out more high end. I hate hate hate hate the feel of thin picks flopping around on me, and the lag between when I was expecting the note to sound and when the bend of the thin pick snaps and the note actually comes. But honestly, especially on electric, it's much more about how it feels in my hand and much less about how it sounds.
Answer: Different weight and material picks will produce different results in playing. In my experience not so much in tone for an electric guitar since that is really mostly a function of the amp, pickups, and other effects.  You can shape the sound electronically.
For me the real issue are related to tactile sensation of the pick attacking the string.   And for this the thickness is only one of several dimensions related to pick performance.
All other things being equal, thinner picks will typically flex more and this is not very good for playing fast lead, or shredding, in any genre.  On the other hand you would not get a great result using a super heavy or thick pick on an acoustic playing folk guitar, or Tommy from the Who.  For that a thinner pick tat flexes would be better.  The difference is in your arm, hand, and your attack of the strings with the pick.  When playing fast leads you typically want to move the hand a little as possible, keeping the pick very close to the string(s).  For this technique a floppy pick might actually bend and never "pick" through the string!  Like wet spaghetti.  However, that also depends on the gauge string you are using.  For example a Jazz player using gauge 13s, a thin pick, and a loose gentile touch will not likely every be able to pick a note.  But a metal player using a thin pick on gauge 8s with a heavy hand will manage to push through.
In short, to some extent your question is not fair.  "The Pick" and its action should be judged relative to the guitar, string gauge, and style of playing.  Different techniques, e.g. strumming vs. tremolo picking require different picks.
That being said there are some other variables missed in the discussion.  The thickness is only one factor in flexion.  Material is another.  The make picks out of stone, metal, various types plastic or other synthetic material.  I typically use Jazz III by dunlop but there are different types.  One made of plastic is very thick but will start to flex when heated up.  The warmth of my hand after and hour of playing is enough to cause enough flex that I can feel it.  The other type is make of a more rigid material (don't recall the exact name) and it is as rigid as steel for as long as I use it.  Never flexes.
Other variables are the tapering of the pick and that comes in two directions.  There is the tapering to a point in the plane of the pick, which gives it its shape.  Then there is a tapering of the "thickness" out to the edge of the pick.  Both are important.  It doesn't matter if your pick is thin or thick if it's so round you can't get it to hit the strings, or so pointed that it hooks the strings and you get stuck.  For my the second type of taper is critical for a good pick.  Thicker is not better without the tapering.  Dunlop makes a purple tortex that is... as thick as a brick.  More to the point these types of pick have equal thickness all the way out to the very edge.  It's like trying to pick a string with a dinner plate.  It feels horrible.  Not sure who uses them.  Having the center of the pick be fat will ensure it does not flex but you want some tapering so the part that actually hist the string is thin.  That will cause the pick to slip right off the string, or the string to slide right off the pick depending on how you look at it.  And this makes for easy, clean, very fast picking.
Again, as for tone I think this is mainly the amp talking but you will hear differences on an acoustic.  However I would not trust a simple mapping of pick thickness to tone since an equally important factor is how the pick is held.  If you play flat pick then thick will create a heavier sound and thin will be weak and nasally.  But many players, especially electric shredders, hold their picks sideways so the edge strikes the string rather than the flatter part.  Mike Batio is an extreme example of this.  In this case the thickness is not as big a factor.
I think the most important take away is that pick type has to adjust to string gauge.  In my 40+ years of playing these two always go together.  I use Gauge 11 round and a Jazz III pick for lead and rhythm playing of all genres of music and that has worked for me.
Answer: For 40 years I've heard people go back and forth on this one.
I remember way, way back in the day, a "cool kid" I knew got an Ibanez Roadster. One of the first "modern" electric guitars I ever saw. He did this thing I'd never seen a guitar player do before; he played FAST. It sounded so cool.
He used a thin pick. Said you had to. So, as I was just starting to learn, that was religion to me. Thin picks = fast.
Goes to show how misleading "advice" can be. Years later I came to understand what he had done was "tremolo pick" a heavily distorted guitar, which is something that a thin pick can indeed facilitate. But it's not really alternate picking.
In my formative guitar years, I was a devoted student of the Randy Rhoads school of guitar, and later, Yngwie Malmsteen (and to lesser degrees Tony Iommi, Buck Dharma, Angus Young and Alex Lifeson). I was still very young, but found out that for the most part, the players I gravitated towards preferred heavy picks. Malmsteen claimed it was because "when I move the pick, I want it to do what I want it to do. If it bends, it will not be instant." He was adamant, and of course nobody in the world was delivering what he was, so I simply took it as gospel. Strangely, at the time, many of my guitar playing friends, even the older ones (they being 16) still insisted on thin picks. They just said Yngwie was wrong. Some of the early metal guys were using the thin ones I think, one of the early players from Venom for example.
Over the years, I standardized on heavy picks for the same reason; if the pick flexes, it gets in the way of the extremely fine and precise commands I'm issuing from my brain to my fingers.
But, for some reason on an acoustic guitar, when I strum, I gravitated to medium picks. For some reason a heavy pick (like a purple tortex) just doesn't feel quite right when I play a big dreadnought strummer. Not to mention, the thinner pick creates a different tone when moved across the strings, and I prefer it when banging around some Zeppelin acoustic songs and whatnot.
Light picks, I find them useless. I know there's a reason they exist and I know a lot of people like them, but for me, they do nothing. (I can't stand that in guitar center, if you ask for a pick, they hand you one of the GC branded ones and it's usually lighter-than-medium).
So to me, there is an absolute difference in attack, decay, and overall tone, between picks, and for me, the playable range is towards the heavy side (again, purple tortex is my standard), moving to the green tortex for acoustic if I'm feeling inclined that way at the time.
I know a guy, he's the lead guitar player for a band called Toxik. Grew up one town over from him. He uses very heavy jazz picks, purple tortex weight, but they're short. I don't like them at all (I have a couple of them in my studio). But that's preference. Josh is a guitar player that was way ahead of his time when Toxik was big. Nobody sounded like him, he was an innovator. Maybe one of the reasons for his distinct tone was that he was a heavy metal guy, really a predecessor of progressive thrash, that used a jazz pick.
Something else I found along the way, after experimenting with Herco picks (which Jimmy Page used), Fender picks (which are a kind of slippery plastic), and Tortex picks (and many, many others), the material is also relevant. For me, the Tortex pick is the absolute winner for tone, grip, attack, and feel. So that might be something else to keep in mind.
Lots of options out there, try 'em all. Picks are for the most part cheap, can't hurt to pick up a bag of a variety of weights, sizes and materials (they make metal ones etc) and give 'em all a run. They bring out different characteristics and can even incline you to play differently, which can help you discover something you may not have known about your playing self.
Answer: I have used many picks of different gauge (thickness) and materials but once I tried V-Picks (stiff acrylic) I couldn't go back to any other pick. Although available in various gauges the many shapes along with special edging define these picks and the sound you can obtain. I had been using what I thought was heavy to extra heavy (around .96mm - 1.20mm). After getting a sample order of about 15 picks immediately switched to 2.75 - 3.0mm (for electric as you might want to try something lighter to acoustic) and have never looked back. The sizes, shapes, and ghost (similar to a sand blasted edge) are what I focus on for different sounds. These picks are actually available in heavier gauges but I'm pretty much stuck on different shapes and edges from the 2.75 - 3.0 range. When I try using picks of lighter gauges which I had been using for years it's no contest for me whether playing jazz, blues, rock, etc etc etc. The material is the key as I do have a few 1.50mm but 95% of the time am using various 2.75 - 3.0mm V-Picks. I have no personal or business affiliation with the manufacturer.
Comment: This doesn't actually answer the question at all, and just reads like a promo.
Comment: @DrMayhem - it does from the 'just personal preference?' part !!
Answer: I've found that when playing different styles, particularly "heavier" music, that the heavier picks hold up better.  For instance, I've broken light pics by galloping with them.


Why is Granger test implication different from significances of coefficients?

Question: I am running a simple Granger causality test on a VAR(4) model. I obtain the following coefficients for it
Di = Di.l1 + Dc.l1 + Di.l2 + Dc.l2 + Di.l3 + Dc.l3 + Di.l4 + Dc.l4 + const

        Estimate Std. Error t value Pr(>|t|)
Di.l1 -0.0329008  0.0909051  -0.362  0.71796
Dc.l1  0.5837770  0.2205362   2.647  0.00906 **
Di.l2  0.1883112  0.0886601   2.124  0.03546 *
Dc.l2  0.0380220  0.2163601   0.176  0.86076
Di.l3  0.1363833  0.0901364   1.513  0.13255
Dc.l3 -0.0123208  0.2107619  -0.058  0.95347
Di.l4  0.2173102  0.0849079   2.559  0.01156 *
Dc.l4 -0.2605697  0.2134410  -1.221  0.22424
const  0.0005628  0.0021497   0.262  0.79388

Clearly the first lag of the Dc is significant here. Which, from my understanding, would mean Dc Granger causes Di.
However, when I run causality(VAR-model-of-interest, cause="Dc") I obtain the following.
    Granger causality H0: Dc do not Granger-cause Di

data:  VAR object VAR4
F-Test = 1.9381, df1 = 4, df2 = 276, p-value = 0.1043

Which means that I assume that there is NO Granger causality.
Should I trust the test over the significances of the coefficients and if yes, why?
Thank you very much in advance!
Answer: You have a situation where multiple coefficients are jointly not statistically significantly different from zero while one of them is individually statistically significantly different from zero. Thus you cannot reject $H_{0A}\colon \beta_1=\beta_2=\beta_3=\beta_4=0$ even though you can reject $H_{0B}\colon \beta_1=0$ at a chosen significance level (say, 5%). Of course, it is impossible that $H_{0A}$ holds while $H_{0B}$ does not. However, at the level of precision that you are able to achieve, you get seemingly conflicting results. This is due to estimation imprecision and can happen much more generally than just in testing for Granger causality. The question is likely covered in your favourite introductory econometrics textbook.
One way out is to decide upfront which of the two hypotheses you are going to test and to stick to it. I suppose in your case it is $H_{0A}$.
Comment: @Silke, what do you think about my answer? If it is helpful and clear, you may accept it by clicking on the tick mark to the left. Otherwise, you may ask for further clarification. This is [how Cross Validated works](https://stats.stackexchange.com/tour).
Comment: Thank you very much for this answer! Very helpful!
Comment: @Silke, you are welcome!


Using value outside of domain to get the correct answer?

Question: If X is uniformly distributed on the interval [1,5] and $Y=e^X$, then find $f_Y(8)$
Then $f_Y(y) = \frac{1}{4y}$ $ln(1) \le y \le ln(5)$
$f_Y(8) = \frac{1}{4*8}=\frac{1}{32}$ which is the answer in the back of the book.
however ln(5) = 1.61
So why is this a valid question? Shouldn't the fact that y always being smaller than 8, restrict me from plugging in that value?
Comment: No, $Y$ takes on values in $[e^1,e^5]$ and $8$ is well within that interval.
Answer: Note that $Y$ takes on values in $[e^1,e^5]$.
Then, for $y \in [e^1,e^5]$,
$F_Y(y)=P(Y \leq y) = P(e^X \leq y) = P(X \leq \ln y) = \frac{\ln y - 1}{5-1}$. For $y < e^1, F_Y(y)=0$ and for $y>e^5$, $F_Y(y) = 1$.
Differentiating this with respect to $y$ gives the density of $y$ as $f_Y(y)= \frac{1}{4} \frac{1}{y}$ on $[e^1,e^5]$ and $f_Y(y) =0$ otherwise.
Evaluating at $y=8$ gives $f_Y(8)=\frac{1}{32}$.


To prove : $\lim_{n \to +\infty} a_{n} $ diverges, where $a_{n}= (-1)^n$ from $\varepsilon$ definition

Question: How to prove : $\lim_{n \to +\infty} a_{n}$ diverges, where $a_{n}= (-1)^n$ from $\varepsilon$ definition.
My way :
From definition :
$a = \lim_{n \to +\infty} a_{n} = \forall \varepsilon>0 \exists N(\varepsilon) \in \mathbb{N} : \forall n \geq N(\varepsilon) \implies \mid a_{n} -a \mid < \varepsilon$ ---(1)
Taking the negation of (1) statement we get :
$a \neq  \lim_{n \to +\infty} a_{n} = \exists \varepsilon>0 \forall N(\varepsilon) \in \mathbb{N} \exists n \geq N(\varepsilon) : \mid a_{n} -a \mid \geq \varepsilon$ ---(2)
We've to prove (2).
We've to divide the statement (2) into two parts :
(i) $\forall a \geq 0 \exists \varepsilon>0 \forall N(\varepsilon) \in \mathbb{N} \exists n = 2N+1\geq N(\varepsilon) : \mid a_{n} -a \mid \geq \varepsilon$ ---2(a)
(ii) $\forall a < 0 \exists \varepsilon>0 \forall N(\varepsilon) \in \mathbb{N} \exists n = 2N\geq N(\varepsilon) : \mid a_{n} -a \mid \geq \varepsilon$ ---2(b)
From 2(a) and 2(b) we get :
$\forall a \mathbb{R} \exists \varepsilon>0 \forall N(\varepsilon) \in \mathbb{N} \exists n \geq N(\varepsilon) : \mid a_{n} -a \mid \geq \varepsilon$ ---(3)
But, I'm confused to choose the proper $\varepsilon$ so that my work would be true. I'm stuck here. Please help me.
My previously asked the same question got downvoted due to lack of enough data, so I deleted the previous post and asked again with my detailed work.
Comment: Suppose it converges to $L$, then let $\epsilon = 1/4$.  Derive a contradiction.
Comment: Hint: if you draw the graph of the sequence you will see that you can always choose points whose distance is 2; this should suggest you to work with an epsilon less than 2.
Answer: Suppose on the contrary that $\lim_{n \to \infty}a_n = a $
Let $\epsilon = 1$. Note that $a_n \in \{1,-1\}$ and the sequence alternative between the two values. Hence if it converges, then we have $|1-a|<1$ and $|-1-a| < 1$.
It is equivalent to  $|a-1|<1$ and $|a+1| < 1$.
We can rewrite it as $-1 < a-1 < 1$ and $-1 < a+1 < 1$.
$0 < a < 2$ and $-2 < a < 0$.
Hence there is no such $a$ that satisfies the system of inequalities as $a$ can't be positive and negative at the same time. We conclude that $a_n$ diverges.

Remark:
Suppose you can't decide which $\epsilon$ to pick, you can also work with arbitrary $\epsilon>0$ first.
$|a-1| < \epsilon$ and $|a+1| < \epsilon$.
$1-\epsilon < a <  1+\epsilon$ and $-1 -\epsilon < a < -1+ \epsilon$.
To make it infeasible, choose $\epsilon >0$ such that $-1 + \epsilon \le  1-\epsilon$ and we conclude that we can pick $0<\epsilon \le 1$.
Comment: I didn't understand the last line, can you please explain in a bit details please? "To make it infeasible, choose ϵ>0 such that −1+ϵ≤1−ϵ and we conclude that we can pick 0<ϵ≤1" How do we get that equation here : −1+ϵ≤1−ϵ ? @siong thye goh
Comment: we have $1-\epsilon < a < 1 + \epsilon$ and $-1 - \epsilon < a < -1 + \epsilon$.  This means we need $a \in (-1-\epsilon, -1 + \epsilon)$ and $a \in (1-\epsilon, 1 + \epsilon)$ . These are two intervals on the real number lines. We don't want them to intersect. The interval $(-1-\epsilon, -1 + \epsilon)$ is on the left and $(1-\epsilon, 1+ \epsilon)$ is on the right. We want the upper end point of the interval on the left to be bounded above by the lower end point of the interval on the right.
Comment: Understood thanks. But, one last question why do we want to make it infeasible? What's the explanation behind it? @siong thye goh
Comment: we want to find a contradiction, that is we want to show that no $a$ satisfies both inequality at the same time.
Answer: Convergent means:
There exists $a$ a number such that for every $\epsilon > 0$ there exists $N= N_{\epsilon}$ such that for every $n > N_{\epsilon}$ we have $|a- a_n| < \epsilon$.
The negation of the above statement: for every $a$ number there exists $\epsilon> 0$ such that for every $N_{\epsilon}$ there exists $n > N_{\epsilon}$ such that $|a-a_n| \ge \epsilon$.
Let's show that this negation is true: Take any $a$ real number. We'll show that $\epsilon =1$ works. Indeed, take any $N$. Take now any natural number $n > N$. Now let's show that at least one of the inequalities
$$|a_n - a| \ge 1$$
or
$$|a_{n+1} - a| \ge 1$$
holds. Indeed, we have
$$|a_n - a| + |a_{n+1} - a| \ge |a_{n} - a_{n+1}| = 2$$
so at least one of the inequalities is true.


Recovery of SSH session after system crash

Question: I was editing a file over SSH when my computer crashed and I got the BSOD. I was SSHing through Putty. I would really like to recover if possible. I don't know if there is anyway to restore the SSH session and save from there. Any help would be appreciated.
Comment: What was the remote computer's operating system? Is it some Linux server? How did you edited the file? With `emacs`, `vi` or what? Did you consider redoing again the `ssh` and restarting the editor?
Answer: No, there is no way to restore your session, unless you used something like screen.
But there might be a way to restore your file, but that depends on the editor you used. Editors like Vim and Emacs store the changes of unsaved files, and will notify you the next time you open the file.
Thus all you have to do in this case is open the same file again. In other cases the changes might just be gone.


Erro de parse no Less, diz que minha classe/mixin não está definida

Question: Estou usando ruby 1.9.2 e rails 3 e gem less 2.6.0. Já importei o mixins e o variables e mesmo assim o erro persiste.

Less::ParseError: #gradient > .vertical is undefined

Trecho do arquivo slider.less:
.slider-track {
    position: absolute;
    cursor: pointer;
    #gradient > .vertical(#f5f5f5, #f9f9f9);
    .box-shadow(inset 0 1px 2px rgba(0,0,0,.1));
    .border-radius(@baseBorderRadius);

Comment: O que você tem aí é um [mixin paramétrico](http://lesscss.org/features/#mixins-parametric-feature). Precisa ter uma definição desse `.vertical(@cor1; @cor2)` em algum lugar.
Comment: Poderia ser um erro de sintaxe no seu LESS? Pode postar o trecho do arquivo onde aparece essa regra?
Comment: editei a pergunta, obrigado pela atenção.
Comment: Qual é a intenção com `#gradient > .vertical(#f5f5f5, #f9f9f9);`? Qual é o CSS que você espera gerar?
Comment: pra ser sincero eu não tenho certeza, por isso eu não consigo resolver sozinho, é um código que já veio pronto no Silder para Bootstrap (bootstrap.slider).
Comment: valeu cara, me ajudou :)
Comment: @bfavaretto não compensa colocar como resposta? :)
Comment: @MaiconCarraro Feito. Espero que isso salve a pergunta do fechamento
Answer: Esse .vertical(#f5f5f5, #f9f9f9) é o que o Less chama de mixin pramétrico, que é como uma função que recebe parâmetros. Ele precisa ser declarado em algum lugar. Imagino que você esteja querendo algo assim:
.vertical(@cor1, @cor2) {

  /* Fallback (could use .jpg/.png alternatively) */
  background-color: @cor1;

  /* SVG fallback for IE 9 (could be data URI, or could use filter) */
  background-image: url(fallback-gradient.svg);

  /* Safari 4, Chrome 1-9, iOS 3.2-4.3, Android 2.1-3.0 */
  background-image:
    -webkit-gradient(linear, left top, left bottom, from(@cor1), to(@cor2));

  /* Safari 5.1, iOS 5.0-6.1, Chrome 10-25, Android 4.0-4.3 */
  background-image:
    -webkit-linear-gradient(top, @cor1, @cor2);

  /* Firefox 3.6 - 15 */
  background-image:
    -moz-linear-gradient(top, @cor1, @cor2);

  /* Opera 11.1 - 12 */
  background-image:
    -o-linear-gradient(top, @cor1, @cor2);

  /* Opera 15+, Chrome 25+, IE 10+, Firefox 16+, Safari 6.1+, iOS 7+, Android 4.4+ */
  background-image:
    linear-gradient(to bottom, @cor1, @cor2);

}

Compatibilidade com múltiplos browsers baseada nas dicas do CSS Tricks


Letter arrangements of "AAABBC" with length two

Question: "AAABBC" has 3 repetitions of "A" and two repetitions of "B".
So total number of arrangements of it with length 2 will be:
AA,AB,AC,BA,BB,BC,CA,CB
Using permutation we need to do something like:
${P(6,2)\over 3!2!}$
because we have 3 repetitions of "A" and 2 "B".
but then we get ${6*5*4!\over4!*2!*3!}$ which is not divisible.
Just wondering what's wrong with my logic?
Comment: I don't get why your formula should hold at all? It doesn't really make any sense to me. Where did you get $\frac{6!}{2!3!4!}$ from?
Comment: $ \frac{6!}{2!3!(6-2)!} $
Answer: How many $A$s and $B$s you have doesn't matter as long as you have at least two of them when you are making strings of length two.  If you had two $C$s there would be $3^2$ strings because you have three choices for each letter.  Since you have only one $C$ you can't make $CC$ so there are $3^2-1=8$ two letter strings.
Answer: If we were arranging all six letters in the string AAABBC, we would have to select three of the six positions in the string to fill with an A, two of the remaining three positions to fill with a B, and fill the final position with the C.  We can do this in
$$\binom{6}{3}\binom{5}{2}\binom{1}{1} = \frac{6!}{3!3!} \cdot \frac{5!}{2!3!} \cdot \frac{1!}{1!0!} = \frac{6!}{3!2!1!0!} = \frac{6!}{3!2!1!}$$
ways.  The factor of $3!$ in the denominator represents the number of ways we could permute the three A's among themselves without producing an arrangement distinguishable from the given arrangement; the factor of $2!$ represents the number of ways we could permute the two B's among themselves without producing an arrangement distinguishable from the given arrangement; the factor of $1!$ represents the number of ways we could permute the only C among the C's without producing an arrangement distinguishable from the given arrangement.
The factor $P(6, 2)$ in your numerator represents the number of ordered arrangements of two elements of a set with six different elements.  However, we only have three distinguishable elements in the string AAABBC.
In a string of length $2$, we can have at most two identical letters, so it does not make sense to divide by the factor $3!2!$.  Moreover, it only makes sense to divide by the factor $2!$ if the two letters in the string are identical.  However, some of the strings we could form, such as AB, contain different letters.
There are two strings of length two we could form with identical letters, namely AA and BB.
There are $P(3, 2) = 3 \cdot 2 = 6$ strings we could form with two different letters chosen from A, B, and C.
In total, there are $2 + P(3, 2) = 8$ strings of length two that can be formed from the letters of the string AAABBC.


ElasticSearch Java API Search Error

Question: The each searchRequest.toString() and each error info.
I think if you see the summary at bottom before check those search body and error,  should be more easy to understand my problem.
SEARCH BODY
{
"from" : 0,
"size" : 12,
"query" : {
    "custom_filters_score" : {
        "query" : {
            "bool" : {
                "must" : {
                    "term" : {
                        "2474" : [ "20", "17" ]
                    }
                },
                "should" : {
                    "term" : {
                        "productName" : {
                            "value" : "xxx",
                            "boost" : 3.0
                        }
                    }
                }
            }
        },
        "filters" : [ {
            "filter" : {
                "terms" : {
                    "availableStock" : [ 0 ]
                }
            },
            "boost" : -10.0
        } ]
    }
},
"filter" : {
    "bool" : {
        "must_not" : {
            "term" : {
                "ecPrice" : -1
            }
        }
    }
},
"sort" : [ {
    "_score" : {
        "order" : "desc"
    }
} ],
"facets" : {
    "productBrandName" : {
        "terms" : {
            "field" : "productBrandName",
            "size" : 10
        }
    }
},
"highlight" : {
    "pre_tags" : [ "" ],
    "post_tags" : [ "" ],
    "fields" : {
        "productName" : { },
        "drugTreatment" : { }
    }
}

}
ERROR:
 QueryParsingException[[hy_index] [bool] query does not support [must]];

SEARCH BODY
{
"from" : 0,
"size" : 12,
"query" : {
    "custom_filters_score" : {
        "query" : {
            "bool" : {
                "should" : {
                    "term" : {
                        "2474" : [ "20", "17" ]
                    }
                }
            }
        },
        "filters" : [ ]
    }
},
"filter" : {
    "bool" : {
        "must_not" : {
            "term" : {
                "ecPrice" : -1
            }
        }
    }
},
"sort" : [ {
    "_score" : {
        "order" : "desc"
    }
} ],
"facets" : {
    "productBrandName" : {
        "terms" : {
            "field" : "productBrandName",
            "size" : 10
        }
    }
},
"highlight" : {
    "pre_tags" : [ "" ],
    "post_tags" : [ "" ],
    "fields" : {
        "productName" : { },
        "drugTreatment" : { }
    }
}

}
ERROR
QueryParsingException[[hy_index] [bool] query does not support [should]]

SEARCH BODY
{
"from" : 0,
"size" : 12,
"query" : {
    "custom_filters_score" : {
        "query" : {
            "bool" : {
                "should" : [ {
                    "term" : {
                        "productName" : {
                            "value" : "xxx",
                            "boost" : 3.0
                        }
                    }
                }, {
                    "term" : {
                        "2474" : [ "20", "17" ]
                    }
                } ]
            }
        },
        "filters" : [ {
            "filter" : {
                "terms" : {
                    "availableStock" : [ 0 ]
                }
            },
            "boost" : -10.0
        } ]
    }
},
"filter" : {
    "bool" : {
        "must_not" : {
            "term" : {
                "ecPrice" : -1
            }
        }
    }
},
"sort" : [ {
    "_score" : {
        "order" : "desc"
    }
} ],
"facets" : {
    "productBrandName" : {
        "terms" : {
            "field" : "productBrandName",
            "size" : 10
        }
    }
},
"highlight" : {
    "pre_tags" : [ "" ],
    "post_tags" : [ "" ],
    "fields" : {
        "productName" : { },
        "drugTreatment" : { }
    }
}

}
ERROR
QueryParsingException[[hy_index] [_na] query malformed, must start with start_object];

SEARCH BODY
{
"from" : 0,
"size" : 12,
"query" : {
    "custom_filters_score" : {
        "query" : {
            "bool" : {
                "should" : {
                    "term" : {
                        "productName" : {
                            "value" : "撒",
                            "boost" : 3.0
                        }
                    }
                }
            }
        },
        "filters" : [ {
            "filter" : {
                "terms" : {
                    "availableStock" : [ 0 ]
                }
            },
            "boost" : -10.0
        } ]
    }
},
"filter" : {
    "bool" : {
        "must_not" : {
            "term" : {
                "ecPrice" : -1
            }
        }
    }
},
"sort" : [ {
    "_score" : {
        "order" : "desc"
    }
} ],
"facets" : {
    "productBrandName" : {
        "terms" : {
            "field" : "productBrandName",
            "size" : 10
        }
    }
},
"highlight" : {
    "pre_tags" : [ "" ],
    "post_tags" : [ "" ],
    "fields" : {
        "productName" : { },
        "drugTreatment" : { }
    }
}

}
This one has no error.
Now, Summary.
No matter I use should or must at "term" : {"2474" : [ "20", "17" ]}.
It always get error when I set "term" : {"2474" : [ "20", "17" ]} in query body.
Once I remove "term" : {"2474" : [ "20", "17" ]} from query body, it works fine.
Why?
Comment: +1 for your clear question ..!
Comment: @BlackPOP guess i am stupid, that day i got this error by using `QueryBuilders.termQuery(String name, String...values)`. but after you asid it should be `terms` instead `term`, i just can't find the method `termQuery` with parameters `String name, String...values`, just `String name, String value`...
Comment: You almost found the answer..! It happens...Cheers..!
Answer: Term query expect only one value.  Terms mean more than one value..  Try lik this
 "terms" : {"2474" : [ "20", "17" ]}

Change term query to terms.. Refer following url
,http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html

ElasticSearch Java API Search Error


Load Balancer is not accessible outside cluster

Question: I have setup 3 master and 6 worker nodes using the same IP segment, 172.26.10.XX.
For load balancer services, I'm using Kube-Vip for load balancer with configuration namespace specifics as below: -
Data
====
cidr-private-app:
----
172.26.10.XX/27
range-global:
----
172.26.16.XX-172.26.16.XX
range-public-app:
----
172.26.14.XX-172.26.14.XX

BinaryData

When I try to expose a service LB with IP 172.26.10.XX, I can access the in/out cluster with no problem. But when I come to expose a service with LB IPs 172.26.16.XX and 172.26.14.XX, I can access them only in the cluster nodes and not outside the cluster. Something wrong? All the advice is appreciated.
Noted:
K8S: v1.27.7+k3s2 KUBE-VIP: 0.6.4 Firewall rules : Allow/All communication server to server with Ips segment 172.26.10.XX, 172.26.16.XX and 172.26.14.XX
Restart all node and checking configuration firewall.
I'm expecting the LB can surf IP address with difference IP segment.
Answer: Problem
172.26.16.0 is a different subnet than 172.26.10.0/27. Hosts inside the cluster will have routing information for the 172.26.16.0 subnet since kube-vip adds the correct routes. Hosts outside the cluster will not know where to find this subnet unless specifically told (something is updating their routes). For hosts missing a route, they'll use the default route which is generally a router on the network. If that router doesn't know where to find 172.26.16.0 it will either drop the packets or route them out its default route.
When you use an IP inside the subnet the hosts are configured with, other hosts will see they're sending information to a host in the same network and they'll use ARP to look up the MAC address of the destination and send frames to that host.
You can examine these routing tables on nodes inside and outside the cluster
ip route show table all

tldr; you need a router to cross between networks. Your Kubernetes nodes are acting as routers so that's why communication works from inside the cluster
Solution
Probably easiest is to use IPs that are part of the host subnet if you want hosts outside the cluster to be able to reach the IPs. For instance, if your hosts are in subnet 172.26.10.0/27, use 172.26.10.24/29 (.24 - .31) for your VIPs.
Another option; setup static routes on hosts outside Kubernetes that tell them they can find the VIP network using the Kubernetes nodes as a gateway. If your nodes are 172.26.10.1, .2, .3, then hosts outside k8s would have a route like 172.26.16.0/24 via 172.26.10.1
Another option; setup routes on the router hosts outside k8s use and have the router send traffic to the VIP network back out (your router will probably need an IP address for each subnet configured on the same interface)
Another option; add secondary IPs to each host outside k8s that's in the same subnet as the load balancer VIPs.
Another option; setup a routing protocol like RIP or OSPF so hosts outside k8s can learn about networks inside the k8s cluster (some CNIs do this like Calico w/ BGP)


Determining parametric equation given 3 points

Question: Determine parametric equations for the plane through the points $$A(2, 1, 1), B(0, 1, 3), C(1, 3, −2)$$
Comment: @Jean-ClaudeArbaut I think i know where to go with this now. so            AB = (0-2, 1-1, 3-1) and AC = (1-2, 3-1, -2-1)
Comment: What did you try? Hint: a point $M$ is in the plane $(ABC)$ iff the vectors $\overrightarrow{AM}$, $\overrightarrow{AB}$, $\overrightarrow{AC}$ are coplanar, which happens only when their determinant vanishes. For a parametric equation, notice that $A$ is in the plane, and  $\overrightarrow{AB}$, $\overrightarrow{AC}$ are two noncollinear vectors parallel to the plane, thus $M=A+\lambda\overrightarrow{AB}+\mu\overrightarrow{AC}$ is rather obvious.
Comment: make the ansatz $$ax+by+cz+d=0$$
Answer: you have to solve the system
$$2a+b+c+d=0$$
$$b+3c+d=0$$
$$a+3b-2c+d=0$$
or a parametric form $$[x,y,z]=[2,1,1]+s[-2,0,2]+t[-1,2,-3]$$
or
$$x=2-2s-t$$
$$y=1+2t$$
$$z=1+2s-3t$$
Comment: I got the points AB (-2, 0, 2) and AC (-1,2,-3) but how do i form it into the x, y, and z equations?
Comment: I'm not sure how to get the first number for the equations.                        x= ?-2s-1t         y= ?-0s-3             z= ?+2s+1t
Comment: the equation is $$[x,y,z]=OA+sAB+tAC$$
Comment: Oh okay! So        x= 2-2s-1t               y= 1-0s-3              z= 1+2s+1t    Thank you!


Localized Storyboards with Base.lproj

Question: What's the best way to update my localized storyboard's .strings files when working with iOS 6 and the new localization? My project created the strings files nicely when I switched to the new Base.lproj mechanism, but it does not update the .strings files on the fly.
Thanks!
–f
Answer: From Apple's "Internationalization and Localization Guide", at the bottom of it all:
Inside the Base.lproj directory of your project type
ibtool MainStoryboard.storyboard --generate-strings-file NewStuff.strings

Then merge from NewStuff.strings to your Storyboard.strings files and translate.
EDITED LINK:
https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/MaintaingYourOwnStringsFiles/MaintaingYourOwnStringsFiles.html#//apple_ref/doc/uid/10000171i-CH19-SW22
Comment: that link points to a document that has been retired. Not easy to see where the relevant information is now.
Answer: Add the script below to "Build Phases"->"Run Script"

#!/bin/sh
# cls.sh - script to  Create Locale Strings auto

storyboardExt=".storyboard"
stringsExt=".strings"
newStringsExt=".strings.new"
oldStringsExt=".strings.old"
localeDirExt=".lproj"

# Find storyboard file full path inside project folder
for storyboardPath in `find ${SRCROOT} -name "*$storyboardExt" -print`
do
    # Get Base strings file full path
    baseStringsPath=$(echo "$storyboardPath" | sed "s/$storyboardExt/$stringsExt/")

    # Create strings file only when storyboard file newer
    if find $storyboardPath -prune -newer $baseStringsPath -print | grep -q .; then
        # Get storyboard file name and folder
        storyboardFile=$(basename "$storyboardPath")
        storyboardDir=$(dirname "$storyboardPath")

        # Get New Base strings file full path and strings file name
        newBaseStringsPath=$(echo "$storyboardPath" | sed "s/$storyboardExt/$newStringsExt/")
        stringsFile=$(basename "$baseStringsPath")
        ibtool --export-strings-file $newBaseStringsPath $storyboardPath
        iconv -f UTF-16 -t UTF-8 $newBaseStringsPath > $baseStringsPath
        rm $newBaseStringsPath

        # Get all locale strings folder
        for localeStringsDir in `find ${SRCROOT} -name "*$localeDirExt" -print`
        do
            # Skip Base strings folder
            if [ $localeStringsDir != $storyboardDir ]; then
                localeStringsPath=$localeStringsDir/$stringsFile

                # Just copy base strings file on first time
                if [ ! -e $localeStringsPath ]; then
                    cp $baseStringsPath $localeStringsPath
                else
                    oldLocaleStringsPath=$(echo "$localeStringsPath" | sed "s/$stringsExt/$oldStringsExt/")
                    cp $localeStringsPath $oldLocaleStringsPath

                    # Merge baseStringsPath to localeStringsPath
                    awk 'NR == FNR && /^\/\*/ {x=$0; getline; a[x]=$0; next} /^\/\*/ {x=$0; print; getline; $0=a[x]?a[x]:$0; printf $0"\n\n"}' $oldLocaleStringsPath $baseStringsPath > $localeStringsPath

                    rm $oldLocaleStringsPath
                fi
            fi
        done
    else
        echo "$storyboardPath file not modified."
    fi
done

Comment: From [http://forums.macrumors.com/showthread.php?t=1467446](http://forums.macrumors.com/showthread.php?t=1467446)
Comment: Thanks! This one seems to have issues with paths that contain spaces. I keep getting "no file or directory" errors when running that script from the build phase and the outputs indicates that it broke on the space between "Macintosh" and "HD".
Comment: Just put quote(") to the broke path in cls.sh, like "${SRCROOT}"

Localized Storyboards with Base.lproj


Gelfand's theorem

Question: Gelfand's theorem for matrices says that if $X$ is a complex square matrix, and $\|X\|$ is the operator 2-norm for $X$, then $\|X^n\|^{1/n}\to \rho(X)$, where $\rho(X)$ is the spectral radius of $X$.
This is easy to show using normal matrices, using the fact that $\|X^2\|=\|X\|^2$ for normal matrices. Can one deduce the general case from the case using normal matrices?
Comment: There is a proof on Wikipedia: https://en.wikipedia.org/wiki/Spectral_radius#Gelfand's_formula
Comment: @Math1000 Thank you, but I'd be interested if there's another proof that just builds on the case for normal matrices
Answer: This is doable, but I'm not sure if the effort worths it.
Let $A$ be a complex square matrix. Since both spectral radius and operator norm are unitarily invariant, we may assume that $A$ is triangular. Denote the entrywise absolute value of any matrix/vector/scalar $X$ by $|X|$. Clearly, $|A|$ is still triangular and $\rho(A)=\rho(|A|)$.
For any given $\epsilon>0$, we can always choose a positive diagonal matrix $D$ whose diagonal entries of $D$ are smaller than $\epsilon$, such that $B:=D+|A|$ has distinct eigenvalues.
Entrywise absolute value of matrix/vector has the property that $|XY|\le|X||Y|$ entrywise. Since $|A|\le B$, we have $|A^nv|\le|A|^n|v|\le B^n|v|$ for every $n\ge0$ and every vector $v$. In particular, if $v$ is a unit singular vector for the largest singular value of $A^n$, we see that
$$
\|A^n\|=\|A^nv\|=\||A^nv|\|\le\|B^n|v|\|\le\|B^n\|.\tag{1}
$$
Since $B$ has distinct eigenvalues, we may diagonalise it as $B=P\Lambda P^{-1}$. It follows that
\begin{align}
\lim_{n\to\infty}\|B^n\|^{1/n}
&=\lim_{n\to\infty}\|P\Lambda ^nP^{-1}\|^{1/n}\\
&\le\lim_{n\to\infty}(\|P^{-1}\|\|P\|)^{1/n} \|\Lambda ^n\|^{1/n}\\
&=\lim_{n\to\infty}\|\Lambda ^n\|^{1/n}\\
&=\rho(\Lambda)=\rho(B).\tag{2}
\end{align}
(Technically, normality of $\Lambda$ is used in last line.) Combining $(1)$ and $(2)$, we get
$$
\lim_{n\to\infty}\|A^n\|^{1/n}\le\rho(B)<\rho(A)+\epsilon.
$$
Let $\epsilon\to0$, we get $\lim_{n\to\infty}\|A^n\|^{1/n}\le\rho(A)$. Clearly, we also have $\rho(A)\le\lim_{n\to\infty}\|A^n\|^{1/n}$ (because $\rho(A)^n=\rho(A^n)\le\|A^n\|$). The proof is now complete.
Answer: Let $A\in M_n$, $u$ be a non-zero real. Then $\lim_{k\rightarrow\infty}(u||A^k||)^{1/k}=\rho(A)$ iff $\lim_{k\rightarrow\infty}||A^k||^{1/k}=\rho(A)$. Then we may choose any norm on $M_n$; there is an invertible $P$ s.t. $P^{-1}AP=diag(\lambda_1I_{n_1}+N_1,\cdots,\lambda_pI_{n_p}+N_p)$ is in Jordan form. We put $||U||=||P^{-1}UP||_{\infty}$.
Step 1. Consider a Jordan block $J_n=\lambda I+N$ where $N$ is nilpotent.
Case 1. $\lambda\not= 0$. If $k\geq n-1$, then $||J_n^k||_{\infty}=||\lambda^kI+\cdots+\binom{k}{j}\lambda^{k-j}N^j+\cdots+\binom{k}{n-1}\lambda^{k-n+1}N^{n-1}||_{\infty}$. Since $\binom{k}{j} \leq k^{j}$, there is $\tau>0$, that depends on $n$ but not on $k$, s.t. $||J_n^k||_{\infty}\leq \tau|\lambda|^kk^{n-1}$.
On the other hand, since we chose the $\infty$ norm, $||J_n^k||_{\infty}\geq ||\lambda^kI||_{\infty}=|\lambda|^k||I||_{\infty}$.
Case 2. $\lambda=0$. Then $J_n^k=0$ when $k\geq n$.
Finally $(||J_n^k||_{\infty})^{1/k}$ tends to $|\lambda|$.
Step 2. $||A^k||= \max_{j\leq p} ||(\lambda_jI_{n_j}+N_j)^k||_{\infty}$; according to Step 1, $(\max_{j\leq p} ||(\lambda_jI_{n_j}+N_j)^k||_{\infty})^{1/k}$  tends to $\rho(A)$.
Assume (for example) that $|\lambda_1|=\rho(A)$; then $||A^k||\geq |\lambda_1^k|=(\rho(A))^k$.
And we are done.

Gelfand's theorem