Explain hash rocket in this context
I've just written this code, that works although I am not entirely sure why:
scope = scope.where(Sequel.qualify(:meeting_graphs, :id) => query.ids)
I am specifically talking about the hash rocket.
Previously the code was this, which makes perfect sense:
scope = scope.where(id: query.ids)
First thing I do not understand is why it does this not work when I
replace the hash rocket with a colon which I thought was the preferred
syntax:
scope = scope.where(Sequel.qualify(:meeting_graphs, :id): query.ids)
Sequel.qualify returns an object which also confuses me as I thought it
would return a symbol.
Can anyone explain?
Thursday, 3 October 2013
Wednesday, 2 October 2013
Determining whether iOS application was launched via Siri
Determining whether iOS application was launched via Siri
I've been looking forever, but haven't found … Do you know if there's a
way to determine whether my iOS app was launched thru Siri or thru a
regular icon click launch ?
I need to know because I want to automate a "startup" action only when my
app is launched from Siri, not from a regular "app icon click" launch …
I was thinking that maybe application:didFinishLaunchingWithOptions or
some other API would allow my app to know how it was launched, but that
doesn't seem to be the case (or I just missed it !?).
Any idea if there's some trick available that I couldn't use until Apple
publishes some official/public Siri API ?
Thanks for any insight,
I've been looking forever, but haven't found … Do you know if there's a
way to determine whether my iOS app was launched thru Siri or thru a
regular icon click launch ?
I need to know because I want to automate a "startup" action only when my
app is launched from Siri, not from a regular "app icon click" launch …
I was thinking that maybe application:didFinishLaunchingWithOptions or
some other API would allow my app to know how it was launched, but that
doesn't seem to be the case (or I just missed it !?).
Any idea if there's some trick available that I couldn't use until Apple
publishes some official/public Siri API ?
Thanks for any insight,
Help Factoring Quadrinomial
Help Factoring Quadrinomial
I know factoring questions are a dime a dozen but I can't seem to get this
one.
$-2x^3+2x^2+32x+40$
Factor to obtain the following equation:
$-2(x-5)(x+2)^2$
Do I have to use division (I'd prefer not to)? The way the question is
worded, it seems I should just be able to pull factors out. This is the
farthest I could make it:
$-2(x^3-x^2-16x-20)$
$-2[x^2(x-1)-4(4x+5)]$
$-2[(x^2-4)(x-1)(4x+5)]$
I know factoring questions are a dime a dozen but I can't seem to get this
one.
$-2x^3+2x^2+32x+40$
Factor to obtain the following equation:
$-2(x-5)(x+2)^2$
Do I have to use division (I'd prefer not to)? The way the question is
worded, it seems I should just be able to pull factors out. This is the
farthest I could make it:
$-2(x^3-x^2-16x-20)$
$-2[x^2(x-1)-4(4x+5)]$
$-2[(x^2-4)(x-1)(4x+5)]$
GitHub Windows Client - Where is the pull/push commands?
GitHub Windows Client - Where is the pull/push commands?
I've been using Github for mac for a while and was just about to help a
colleague to install it on Windows.
problem is. I cannot find any menu or any button to initiate "push" or
"pull" as I can on mac. Only way I see it is to open a shell and execute
"git pull" But then, what's the point of the UI?
Any help?
I've been using Github for mac for a while and was just about to help a
colleague to install it on Windows.
problem is. I cannot find any menu or any button to initiate "push" or
"pull" as I can on mac. Only way I see it is to open a shell and execute
"git pull" But then, what's the point of the UI?
Any help?
Google Translate Activity not working anymore
Google Translate Activity not working anymore
I wrote a program that invokes Google Translator android application via
Intent.ACTION_VIEW. The problem is that invoking the Google Translator App
does not work anymore, although it did once.
The code is identical to the code given here:
Returning Translated Text from Google Translate Activity
(yes, I tried to replace my code by that code, the Google Translator App
behaves as if it does not receive any data.)
Currently I cannot specify the text and the two languages. The best I can
do is to use ACTION_SEND, but it ignores the two languages:
Intent i = new Intent();
i.setAction(Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_TEXT, "What is going on?");
i.putExtra("key_text_input", "What time is it?");
i.putExtra("key_text_output", "");
i.putExtra("key_language_from", "en");
i.putExtra("key_language_to", "es");
i.putExtra("key_suggest_translation", "");
i.putExtra("key_from_floating_window", false);
i.setComponent(new ComponentName("com.google.android.apps.translate",
"com.google.android.apps.translate.translation.TranslateActivity"));
What actually when I ran this code happened was: the Google Translator
asked me if I want to translate from English and translated "What is going
on?" to French.
So: how do I pass the languages to the Google Translate App now?
I wrote a program that invokes Google Translator android application via
Intent.ACTION_VIEW. The problem is that invoking the Google Translator App
does not work anymore, although it did once.
The code is identical to the code given here:
Returning Translated Text from Google Translate Activity
(yes, I tried to replace my code by that code, the Google Translator App
behaves as if it does not receive any data.)
Currently I cannot specify the text and the two languages. The best I can
do is to use ACTION_SEND, but it ignores the two languages:
Intent i = new Intent();
i.setAction(Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_TEXT, "What is going on?");
i.putExtra("key_text_input", "What time is it?");
i.putExtra("key_text_output", "");
i.putExtra("key_language_from", "en");
i.putExtra("key_language_to", "es");
i.putExtra("key_suggest_translation", "");
i.putExtra("key_from_floating_window", false);
i.setComponent(new ComponentName("com.google.android.apps.translate",
"com.google.android.apps.translate.translation.TranslateActivity"));
What actually when I ran this code happened was: the Google Translator
asked me if I want to translate from English and translated "What is going
on?" to French.
So: how do I pass the languages to the Google Translate App now?
Tuesday, 1 October 2013
Rails nested forms STI autosave
Rails nested forms STI autosave
I have one class "Section" and many other classes "SectionText",
"SectionQuote" etc using STI, elements that compound a Post. (Post
has_many sections). I'm using a autosave custom method via Ajax for build
new sections nested on Post, but I think this isn't a better choice!
I need autosave the sections, when user click on another component. What's
the better way to solve this? Thanks...
I have one class "Section" and many other classes "SectionText",
"SectionQuote" etc using STI, elements that compound a Post. (Post
has_many sections). I'm using a autosave custom method via Ajax for build
new sections nested on Post, but I think this isn't a better choice!
I need autosave the sections, when user click on another component. What's
the better way to solve this? Thanks...
Copy Excel Row if Cell is equal to a value
Copy Excel Row if Cell is equal to a value
I'm trying to copy and paste into a different workbook and spread that
data over different sheets inside of the new workbook. I've got my VBA
working, but it only works about 25% of the time. I continually get an
error on "Run-time error '1004': Select method of Range class failed".
Here is the script:
Sub CopyData()
Dim i As Range
For Each i In Range("A1:A1000")
Windows("data_1.xls").Activate
Sheets("data_1").Activate
If i.Value = 502 Then
i.Select
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Copy
Windows("DataOne.xls").Activate
Sheets("502").Range("A39").End(xlUp).Offset(1, 0).PasteSpecial
End If
If i.Value = 503 Then
........
End If
Next i
End Sub
The failure happens on i.Select every time. Do I need to bring Next i up
to the end of every End If?
I'm trying to copy and paste into a different workbook and spread that
data over different sheets inside of the new workbook. I've got my VBA
working, but it only works about 25% of the time. I continually get an
error on "Run-time error '1004': Select method of Range class failed".
Here is the script:
Sub CopyData()
Dim i As Range
For Each i In Range("A1:A1000")
Windows("data_1.xls").Activate
Sheets("data_1").Activate
If i.Value = 502 Then
i.Select
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Copy
Windows("DataOne.xls").Activate
Sheets("502").Range("A39").End(xlUp).Offset(1, 0).PasteSpecial
End If
If i.Value = 503 Then
........
End If
Next i
End Sub
The failure happens on i.Select every time. Do I need to bring Next i up
to the end of every End If?
Maximizing a ratio of convex functions by minimizing a difference?
Maximizing a ratio of convex functions by minimizing a difference?
Given that $g(.),h(.)$ are convex real functions whose domain is the set
of all real matrices while the range is the set of real numbers:
Is maximizing the term $g(X)/h(X)$ w.r.t X the same as minimizing
$h(X)-\nu g(X)$ for some scalar $\nu$? Is this always valid- why or why
not? Otherwise, is the problem ill-posed, and if so why?
I was thinking there is a different trade-off between how much, $g(X)$ is
maximized while $h(X)$ is minimized in both the formulations.
Given that $g(.),h(.)$ are convex real functions whose domain is the set
of all real matrices while the range is the set of real numbers:
Is maximizing the term $g(X)/h(X)$ w.r.t X the same as minimizing
$h(X)-\nu g(X)$ for some scalar $\nu$? Is this always valid- why or why
not? Otherwise, is the problem ill-posed, and if so why?
I was thinking there is a different trade-off between how much, $g(X)$ is
maximized while $h(X)$ is minimized in both the formulations.
$p$-subgroup of $G$ with $p$ a prime.
$p$-subgroup of $G$ with $p$ a prime.
If $H$ is a $p$-subgroup of a finite group $G$ then $[N_G(H) : H] ¡Õ
[G:H]\operatorname{mod} p$.
Proof:
Let S be the set of left cosets of H in G. H acts on S by left
translation, $h ¡¤ aH = haH$, then $|S| = [G : H]$. So $xH¡ôS_0 ⇐¢¡
hxH=xH ¢£h¡ôH ⇐¢¡ x^{−1}hxH=H ¢£h¡ôH ⇐¢¡
x^{−1}Hx=H ⇐¢¡ x¡ô N_G(H)$ $|S_0| = [N_G(H) : H]$ By the fact
that $ |H|=p^n$ and H acts on S we have $|S|¡Õ|S_0|$ mod p. So
$[G:H]¡Õ[N_G(H):H]$ modp.
Is it correct my proof?.
And If p divides $[G : H]$ then $N_G(H) ¡Á H $
Proof:
$0¡Õ[G:H]¡Õ[N_G(H):H]¡Ã1$. So $[N_G(H) : H] ¡Ã 1$, thus $ N_G(H) ¡Á H$ .
Is it correct?
Please help!!! T_T
If $H$ is a $p$-subgroup of a finite group $G$ then $[N_G(H) : H] ¡Õ
[G:H]\operatorname{mod} p$.
Proof:
Let S be the set of left cosets of H in G. H acts on S by left
translation, $h ¡¤ aH = haH$, then $|S| = [G : H]$. So $xH¡ôS_0 ⇐¢¡
hxH=xH ¢£h¡ôH ⇐¢¡ x^{−1}hxH=H ¢£h¡ôH ⇐¢¡
x^{−1}Hx=H ⇐¢¡ x¡ô N_G(H)$ $|S_0| = [N_G(H) : H]$ By the fact
that $ |H|=p^n$ and H acts on S we have $|S|¡Õ|S_0|$ mod p. So
$[G:H]¡Õ[N_G(H):H]$ modp.
Is it correct my proof?.
And If p divides $[G : H]$ then $N_G(H) ¡Á H $
Proof:
$0¡Õ[G:H]¡Õ[N_G(H):H]¡Ã1$. So $[N_G(H) : H] ¡Ã 1$, thus $ N_G(H) ¡Á H$ .
Is it correct?
Please help!!! T_T
Subscribe to:
Posts (Atom)