operation

How to create a file using javascript in Mozilla Firefox

爱⌒轻易说出口 提交于 2019-12-01 03:43:52
I want to write a function in javascript which creates a file and write some content to it, iam working with firefox, can anybody help me in this case. Thanks... flpmor You can write files in JavaScript in Firefox, but you have to use an XPCOM object (internal browser API). This is not allowed for JavaScript loaded from a web page, and it is intended to be used by JavaScript running inside a Firefox add-on (with high level of privileges). There is a way for unprivileged (web page) JavaScript to request more privileges and if the user grants it (there will be a pop up dialog asking for

java Bit operations >>> shift

北城余情 提交于 2019-12-01 00:38:06
问题 Why if int x = -1 // binary: 11111111111111111111111111111111 x = x >>> 31; we have 00000000000000000000000000000001 but if int x = -1 x = x >>> 32; we have 11111111111111111111111111111111 (again -1) but not 00000000000000000000000000000000 ? 回答1: From Section 15.19 of JLS: If the promoted type of the left-hand operand is int, only the five lowest-order bits of the right-hand operand are used as the shift distance . It is as if the right-hand operand were subjected to a bitwise logical AND

How to create a file using javascript in Mozilla Firefox

旧巷老猫 提交于 2019-12-01 00:24:37
问题 I want to write a function in javascript which creates a file and write some content to it, iam working with firefox, can anybody help me in this case. Thanks... 回答1: You can write files in JavaScript in Firefox, but you have to use an XPCOM object (internal browser API). This is not allowed for JavaScript loaded from a web page, and it is intended to be used by JavaScript running inside a Firefox add-on (with high level of privileges). There is a way for unprivileged (web page) JavaScript to

MongoDB - $addToSet on a list of Embedded Document

我怕爱的太早我们不能终老 提交于 2019-11-30 19:06:18
I have a list of (mongodb) Embedded Documents within one Document and I am interested in adding a new embedded document to the list of the existing ones. As far as I have researched, I can use $addToSet, what I can't figure out is how does MongoDB decide if the new document already exists in the list of embedded documents or if it's a new one, i.e. how does MongoDB decide if 2 embedded documents are equal? p.s. the embedded documents I have are not just values, they are quite complex structures, so I was wondering if there is any place I can define what the equality between 2 of them means...

Operator associativity in C specifically prefix and postfix increment and decrement

冷暖自知 提交于 2019-11-30 18:01:06
问题 In C operation associativity is as such for increment, decrement and assignment. 2. postfix ++ and -- 3. prefix ++ and -- 16. Direct assignment = The full list is found here Wikipedia Operators in C My question is when we have int a, b; b = 1; a = b++; printf("%d", a); // a is equal to 1 b = 1; a = ++b; printf("%d", a); //a is equal to 2 Why is a equal to 1 with b++ when the postfix increment operator should happen before the direct assignment? And why is the prefix increment operator

Converting KB to MB, GB, TB dynamically

梦想与她 提交于 2019-11-30 12:13:27
public String size(int size){ String hrSize = ""; int k = size; double m = size/1024; double g = size/1048576; double t = size/1073741824; DecimalFormat dec = new DecimalFormat("0.00"); if (k>0) { hrSize = dec.format(k).concat("KB"); } if (m>0) { hrSize = dec.format(m).concat("MB"); } if (g>0) { hrSize = dec.format(g).concat("GB"); } if (t>0) { hrSize = dec.format(t).concat("TB"); } return hrSize; } This is a method that should return size in GB,MB, KB or TB. Input value is in KB. for example result for 1245 should be like 1.21MB but what I get is 1.00MB. You are performing integer division .

Converting KB to MB, GB, TB dynamically

可紊 提交于 2019-11-29 17:46:09
问题 public String size(int size){ String hrSize = ""; int k = size; double m = size/1024; double g = size/1048576; double t = size/1073741824; DecimalFormat dec = new DecimalFormat("0.00"); if (k>0) { hrSize = dec.format(k).concat("KB"); } if (m>0) { hrSize = dec.format(m).concat("MB"); } if (g>0) { hrSize = dec.format(g).concat("GB"); } if (t>0) { hrSize = dec.format(t).concat("TB"); } return hrSize; } This is a method that should return size in GB,MB, KB or TB. Input value is in KB. for example

postgreSQL - in vs any

旧城冷巷雨未停 提交于 2019-11-28 20:23:09
I have tried both 1) smthng = any (select id from exmplTable) 2) smthng in (select id from exmplTable) and I am getting the same results for my data. Is there any difference for the two expresions ? No, in these variants are same: You can see - the execution plans are same too: postgres=# explain select * from foo1 where id in (select id from foo2); ┌──────────────────────────────────────────────────────────────────┐ │ QUERY PLAN │ ╞══════════════════════════════════════════════════════════════════╡ │ Hash Semi Join (cost=3.25..21.99 rows=100 width=4) │ │ Hash Cond: (foo1.id = foo2.id) │ │ ->

Equalizer not always supported, even when api >= 9?

自闭症网瘾萝莉.ら 提交于 2019-11-28 13:21:16
before enabling equalizer capabilities, I check for api level to make sure it's equal or greater than 9. From the reports I'm getting from my users, it seems that some exceptions are thrown anyway : the code eq = new Equalizer(0, mp.getAudioSessionId()) can raise : Caused by: java.lang.UnsupportedOperationException: Effect library not loaded at android.media.audiofx.AudioEffect.<init>(AudioEffect.java:355) at android.media.audiofx.Equalizer.<init>(Equalizer.java:149) and the code eq.getBandLevelRange() can raise : Caused by: java.lang.UnsupportedOperationException: AudioEffect: invalid

string.upper(<str>) and <str>.upper() won't execute

一笑奈何 提交于 2019-11-28 12:55:47
I have the following bit of code: def test(): fragment = '' fragment = raw_input('Enter input') while fragment not in string.ascii_letters: fragment = raw_input('Invalid character entered, try again: ') fragment.upper() print fragment*3 However when I run it, say for an input value of p , fragment gets printed as 'ppp' - all lower case, i.e. the fragment.upper() line does not run. The same thing happens if I replace that line with string.upper(fragment) (and adding import string at the beginning). Can someone tell me what I'm doing wrong? Strings are immutable . So functions like str.upper()